You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2016/10/07 20:52:39 UTC
[12/31] airavata git commit: correcting the registry code,
testing not yet complete
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/api/ttypes.py
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/api/ttypes.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/api/ttypes.py
index ff33544..c53ac73 100644
--- a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/api/ttypes.py
+++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/api/ttypes.py
@@ -21,6 +21,7 @@ import apache.airavata.model.appcatalog.appinterface.ttypes
import apache.airavata.model.appcatalog.computeresource.ttypes
import apache.airavata.model.appcatalog.storageresource.ttypes
import apache.airavata.model.appcatalog.gatewayprofile.ttypes
+import apache.airavata.model.appcatalog.userresourceprofile.ttypes
import apache.airavata.model.data.movement.ttypes
import apache.airavata.model.workflow.ttypes
import apache.airavata.model.data.replica.ttypes
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/job/ttypes.py
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/job/ttypes.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/job/ttypes.py
index 111d241..52478a6 100644
--- a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/job/ttypes.py
+++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/job/ttypes.py
@@ -27,7 +27,7 @@ class JobModel:
- processId
- jobDescription
- creationTime
- - jobStatus
+ - jobStatuses
- computeResourceConsumed
- jobName
- workingDir
@@ -43,7 +43,7 @@ class JobModel:
(3, TType.STRING, 'processId', None, None, ), # 3
(4, TType.STRING, 'jobDescription', None, None, ), # 4
(5, TType.I64, 'creationTime', None, None, ), # 5
- (6, TType.LIST, 'jobStatus', (TType.STRUCT,(apache.airavata.model.status.ttypes.JobStatus, apache.airavata.model.status.ttypes.JobStatus.thrift_spec)), None, ), # 6
+ (6, TType.LIST, 'jobStatuses', (TType.STRUCT,(apache.airavata.model.status.ttypes.JobStatus, apache.airavata.model.status.ttypes.JobStatus.thrift_spec)), None, ), # 6
(7, TType.STRING, 'computeResourceConsumed', None, None, ), # 7
(8, TType.STRING, 'jobName', None, None, ), # 8
(9, TType.STRING, 'workingDir', None, None, ), # 9
@@ -52,13 +52,13 @@ class JobModel:
(12, TType.I32, 'exitCode', None, None, ), # 12
)
- def __init__(self, jobId=None, taskId=None, processId=None, jobDescription=None, creationTime=None, jobStatus=None, computeResourceConsumed=None, jobName=None, workingDir=None, stdOut=None, stdErr=None, exitCode=None,):
+ def __init__(self, jobId=None, taskId=None, processId=None, jobDescription=None, creationTime=None, jobStatuses=None, computeResourceConsumed=None, jobName=None, workingDir=None, stdOut=None, stdErr=None, exitCode=None,):
self.jobId = jobId
self.taskId = taskId
self.processId = processId
self.jobDescription = jobDescription
self.creationTime = creationTime
- self.jobStatus = jobStatus
+ self.jobStatuses = jobStatuses
self.computeResourceConsumed = computeResourceConsumed
self.jobName = jobName
self.workingDir = workingDir
@@ -102,12 +102,12 @@ class JobModel:
iprot.skip(ftype)
elif fid == 6:
if ftype == TType.LIST:
- self.jobStatus = []
+ self.jobStatuses = []
(_etype3, _size0) = iprot.readListBegin()
for _i4 in xrange(_size0):
_elem5 = apache.airavata.model.status.ttypes.JobStatus()
_elem5.read(iprot)
- self.jobStatus.append(_elem5)
+ self.jobStatuses.append(_elem5)
iprot.readListEnd()
else:
iprot.skip(ftype)
@@ -171,10 +171,10 @@ class JobModel:
oprot.writeFieldBegin('creationTime', TType.I64, 5)
oprot.writeI64(self.creationTime)
oprot.writeFieldEnd()
- if self.jobStatus is not None:
- oprot.writeFieldBegin('jobStatus', TType.LIST, 6)
- oprot.writeListBegin(TType.STRUCT, len(self.jobStatus))
- for iter6 in self.jobStatus:
+ if self.jobStatuses is not None:
+ oprot.writeFieldBegin('jobStatuses', TType.LIST, 6)
+ oprot.writeListBegin(TType.STRUCT, len(self.jobStatuses))
+ for iter6 in self.jobStatuses:
iter6.write(oprot)
oprot.writeListEnd()
oprot.writeFieldEnd()
@@ -224,7 +224,7 @@ class JobModel:
value = (value * 31) ^ hash(self.processId)
value = (value * 31) ^ hash(self.jobDescription)
value = (value * 31) ^ hash(self.creationTime)
- value = (value * 31) ^ hash(self.jobStatus)
+ value = (value * 31) ^ hash(self.jobStatuses)
value = (value * 31) ^ hash(self.computeResourceConsumed)
value = (value * 31) ^ hash(self.jobName)
value = (value * 31) ^ hash(self.workingDir)
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/process/ttypes.py
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/process/ttypes.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/process/ttypes.py
index 868b383..f5fe908 100644
--- a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/process/ttypes.py
+++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/process/ttypes.py
@@ -38,7 +38,7 @@ class ProcessModel:
- experimentId
- creationTime
- lastUpdateTime
- - processStatus
+ - processStatuses
- processDetail
- applicationInterfaceId
- applicationDeploymentId
@@ -48,7 +48,7 @@ class ProcessModel:
- processResourceSchedule
- tasks
- taskDag
- - processError
+ - processErrors
- gatewayExecutionId
- enableEmailNotification
- emailAddresses
@@ -65,7 +65,7 @@ class ProcessModel:
(2, TType.STRING, 'experimentId', None, None, ), # 2
(3, TType.I64, 'creationTime', None, None, ), # 3
(4, TType.I64, 'lastUpdateTime', None, None, ), # 4
- (5, TType.LIST, 'processStatus', (TType.STRUCT,(apache.airavata.model.status.ttypes.ProcessStatus, apache.airavata.model.status.ttypes.ProcessStatus.thrift_spec)), None, ), # 5
+ (5, TType.LIST, 'processStatuses', (TType.STRUCT,(apache.airavata.model.status.ttypes.ProcessStatus, apache.airavata.model.status.ttypes.ProcessStatus.thrift_spec)), None, ), # 5
(6, TType.STRING, 'processDetail', None, None, ), # 6
(7, TType.STRING, 'applicationInterfaceId', None, None, ), # 7
(8, TType.STRING, 'applicationDeploymentId', None, None, ), # 8
@@ -75,7 +75,7 @@ class ProcessModel:
(12, TType.STRUCT, 'processResourceSchedule', (apache.airavata.model.scheduling.ttypes.ComputationalResourceSchedulingModel, apache.airavata.model.scheduling.ttypes.ComputationalResourceSchedulingModel.thrift_spec), None, ), # 12
(13, TType.LIST, 'tasks', (TType.STRUCT,(apache.airavata.model.task.ttypes.TaskModel, apache.airavata.model.task.ttypes.TaskModel.thrift_spec)), None, ), # 13
(14, TType.STRING, 'taskDag', None, None, ), # 14
- (15, TType.LIST, 'processError', (TType.STRUCT,(apache.airavata.model.commons.ttypes.ErrorModel, apache.airavata.model.commons.ttypes.ErrorModel.thrift_spec)), None, ), # 15
+ (15, TType.LIST, 'processErrors', (TType.STRUCT,(apache.airavata.model.commons.ttypes.ErrorModel, apache.airavata.model.commons.ttypes.ErrorModel.thrift_spec)), None, ), # 15
(16, TType.STRING, 'gatewayExecutionId', None, None, ), # 16
(17, TType.BOOL, 'enableEmailNotification', None, None, ), # 17
(18, TType.LIST, 'emailAddresses', (TType.STRING,None), None, ), # 18
@@ -86,12 +86,12 @@ class ProcessModel:
(23, TType.STRING, 'userName', None, None, ), # 23
)
- def __init__(self, processId=thrift_spec[1][4], experimentId=None, creationTime=None, lastUpdateTime=None, processStatus=None, processDetail=None, applicationInterfaceId=None, applicationDeploymentId=None, computeResourceId=None, processInputs=None, processOutputs=None, processResourceSchedule=None, tasks=None, taskDag=None, processError=None, gatewayExecutionId=None, enableEmailNotification=None, emailAddresses=None, storageResourceId=None, userDn=None, generateCert=thrift_spec[21][4], experimentDataDir=None, userName=None,):
+ def __init__(self, processId=thrift_spec[1][4], experimentId=None, creationTime=None, lastUpdateTime=None, processStatuses=None, processDetail=None, applicationInterfaceId=None, applicationDeploymentId=None, computeResourceId=None, processInputs=None, processOutputs=None, processResourceSchedule=None, tasks=None, taskDag=None, processErrors=None, gatewayExecutionId=None, enableEmailNotification=None, emailAddresses=None, storageResourceId=None, userDn=None, generateCert=thrift_spec[21][4], experimentDataDir=None, userName=None,):
self.processId = processId
self.experimentId = experimentId
self.creationTime = creationTime
self.lastUpdateTime = lastUpdateTime
- self.processStatus = processStatus
+ self.processStatuses = processStatuses
self.processDetail = processDetail
self.applicationInterfaceId = applicationInterfaceId
self.applicationDeploymentId = applicationDeploymentId
@@ -101,7 +101,7 @@ class ProcessModel:
self.processResourceSchedule = processResourceSchedule
self.tasks = tasks
self.taskDag = taskDag
- self.processError = processError
+ self.processErrors = processErrors
self.gatewayExecutionId = gatewayExecutionId
self.enableEmailNotification = enableEmailNotification
self.emailAddresses = emailAddresses
@@ -142,12 +142,12 @@ class ProcessModel:
iprot.skip(ftype)
elif fid == 5:
if ftype == TType.LIST:
- self.processStatus = []
+ self.processStatuses = []
(_etype3, _size0) = iprot.readListBegin()
for _i4 in xrange(_size0):
_elem5 = apache.airavata.model.status.ttypes.ProcessStatus()
_elem5.read(iprot)
- self.processStatus.append(_elem5)
+ self.processStatuses.append(_elem5)
iprot.readListEnd()
else:
iprot.skip(ftype)
@@ -217,12 +217,12 @@ class ProcessModel:
iprot.skip(ftype)
elif fid == 15:
if ftype == TType.LIST:
- self.processError = []
+ self.processErrors = []
(_etype27, _size24) = iprot.readListBegin()
for _i28 in xrange(_size24):
_elem29 = apache.airavata.model.commons.ttypes.ErrorModel()
_elem29.read(iprot)
- self.processError.append(_elem29)
+ self.processErrors.append(_elem29)
iprot.readListEnd()
else:
iprot.skip(ftype)
@@ -297,10 +297,10 @@ class ProcessModel:
oprot.writeFieldBegin('lastUpdateTime', TType.I64, 4)
oprot.writeI64(self.lastUpdateTime)
oprot.writeFieldEnd()
- if self.processStatus is not None:
- oprot.writeFieldBegin('processStatus', TType.LIST, 5)
- oprot.writeListBegin(TType.STRUCT, len(self.processStatus))
- for iter36 in self.processStatus:
+ if self.processStatuses is not None:
+ oprot.writeFieldBegin('processStatuses', TType.LIST, 5)
+ oprot.writeListBegin(TType.STRUCT, len(self.processStatuses))
+ for iter36 in self.processStatuses:
iter36.write(oprot)
oprot.writeListEnd()
oprot.writeFieldEnd()
@@ -349,10 +349,10 @@ class ProcessModel:
oprot.writeFieldBegin('taskDag', TType.STRING, 14)
oprot.writeString(self.taskDag)
oprot.writeFieldEnd()
- if self.processError is not None:
- oprot.writeFieldBegin('processError', TType.LIST, 15)
- oprot.writeListBegin(TType.STRUCT, len(self.processError))
- for iter40 in self.processError:
+ if self.processErrors is not None:
+ oprot.writeFieldBegin('processErrors', TType.LIST, 15)
+ oprot.writeListBegin(TType.STRUCT, len(self.processErrors))
+ for iter40 in self.processErrors:
iter40.write(oprot)
oprot.writeListEnd()
oprot.writeFieldEnd()
@@ -408,7 +408,7 @@ class ProcessModel:
value = (value * 31) ^ hash(self.experimentId)
value = (value * 31) ^ hash(self.creationTime)
value = (value * 31) ^ hash(self.lastUpdateTime)
- value = (value * 31) ^ hash(self.processStatus)
+ value = (value * 31) ^ hash(self.processStatuses)
value = (value * 31) ^ hash(self.processDetail)
value = (value * 31) ^ hash(self.applicationInterfaceId)
value = (value * 31) ^ hash(self.applicationDeploymentId)
@@ -418,7 +418,7 @@ class ProcessModel:
value = (value * 31) ^ hash(self.processResourceSchedule)
value = (value * 31) ^ hash(self.tasks)
value = (value * 31) ^ hash(self.taskDag)
- value = (value * 31) ^ hash(self.processError)
+ value = (value * 31) ^ hash(self.processErrors)
value = (value * 31) ^ hash(self.gatewayExecutionId)
value = (value * 31) ^ hash(self.enableEmailNotification)
value = (value * 31) ^ hash(self.emailAddresses)
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/task/ttypes.py
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/task/ttypes.py b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/task/ttypes.py
index 9699f7b..213598b 100644
--- a/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/task/ttypes.py
+++ b/airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/apache/airavata/model/task/ttypes.py
@@ -94,10 +94,10 @@ class TaskModel:
- parentProcessId
- creationTime
- lastUpdateTime
- - taskStatus
+ - taskStatuses
- taskDetail
- subTaskModel
- - taskError
+ - taskErrors
- jobs
"""
@@ -108,23 +108,23 @@ class TaskModel:
(3, TType.STRING, 'parentProcessId', None, None, ), # 3
(4, TType.I64, 'creationTime', None, None, ), # 4
(5, TType.I64, 'lastUpdateTime', None, None, ), # 5
- (6, TType.LIST, 'taskStatus', (TType.STRUCT,(apache.airavata.model.status.ttypes.TaskStatus, apache.airavata.model.status.ttypes.TaskStatus.thrift_spec)), None, ), # 6
+ (6, TType.LIST, 'taskStatuses', (TType.STRUCT,(apache.airavata.model.status.ttypes.TaskStatus, apache.airavata.model.status.ttypes.TaskStatus.thrift_spec)), None, ), # 6
(7, TType.STRING, 'taskDetail', None, None, ), # 7
(8, TType.STRING, 'subTaskModel', None, None, ), # 8
- (9, TType.LIST, 'taskError', (TType.STRUCT,(apache.airavata.model.commons.ttypes.ErrorModel, apache.airavata.model.commons.ttypes.ErrorModel.thrift_spec)), None, ), # 9
+ (9, TType.LIST, 'taskErrors', (TType.STRUCT,(apache.airavata.model.commons.ttypes.ErrorModel, apache.airavata.model.commons.ttypes.ErrorModel.thrift_spec)), None, ), # 9
(10, TType.LIST, 'jobs', (TType.STRUCT,(apache.airavata.model.job.ttypes.JobModel, apache.airavata.model.job.ttypes.JobModel.thrift_spec)), None, ), # 10
)
- def __init__(self, taskId=thrift_spec[1][4], taskType=None, parentProcessId=None, creationTime=None, lastUpdateTime=None, taskStatus=None, taskDetail=None, subTaskModel=None, taskError=None, jobs=None,):
+ def __init__(self, taskId=thrift_spec[1][4], taskType=None, parentProcessId=None, creationTime=None, lastUpdateTime=None, taskStatuses=None, taskDetail=None, subTaskModel=None, taskErrors=None, jobs=None,):
self.taskId = taskId
self.taskType = taskType
self.parentProcessId = parentProcessId
self.creationTime = creationTime
self.lastUpdateTime = lastUpdateTime
- self.taskStatus = taskStatus
+ self.taskStatuses = taskStatuses
self.taskDetail = taskDetail
self.subTaskModel = subTaskModel
- self.taskError = taskError
+ self.taskErrors = taskErrors
self.jobs = jobs
def read(self, iprot):
@@ -163,12 +163,12 @@ class TaskModel:
iprot.skip(ftype)
elif fid == 6:
if ftype == TType.LIST:
- self.taskStatus = []
+ self.taskStatuses = []
(_etype3, _size0) = iprot.readListBegin()
for _i4 in xrange(_size0):
_elem5 = apache.airavata.model.status.ttypes.TaskStatus()
_elem5.read(iprot)
- self.taskStatus.append(_elem5)
+ self.taskStatuses.append(_elem5)
iprot.readListEnd()
else:
iprot.skip(ftype)
@@ -184,12 +184,12 @@ class TaskModel:
iprot.skip(ftype)
elif fid == 9:
if ftype == TType.LIST:
- self.taskError = []
+ self.taskErrors = []
(_etype9, _size6) = iprot.readListBegin()
for _i10 in xrange(_size6):
_elem11 = apache.airavata.model.commons.ttypes.ErrorModel()
_elem11.read(iprot)
- self.taskError.append(_elem11)
+ self.taskErrors.append(_elem11)
iprot.readListEnd()
else:
iprot.skip(ftype)
@@ -234,10 +234,10 @@ class TaskModel:
oprot.writeFieldBegin('lastUpdateTime', TType.I64, 5)
oprot.writeI64(self.lastUpdateTime)
oprot.writeFieldEnd()
- if self.taskStatus is not None:
- oprot.writeFieldBegin('taskStatus', TType.LIST, 6)
- oprot.writeListBegin(TType.STRUCT, len(self.taskStatus))
- for iter18 in self.taskStatus:
+ if self.taskStatuses is not None:
+ oprot.writeFieldBegin('taskStatuses', TType.LIST, 6)
+ oprot.writeListBegin(TType.STRUCT, len(self.taskStatuses))
+ for iter18 in self.taskStatuses:
iter18.write(oprot)
oprot.writeListEnd()
oprot.writeFieldEnd()
@@ -249,10 +249,10 @@ class TaskModel:
oprot.writeFieldBegin('subTaskModel', TType.STRING, 8)
oprot.writeString(self.subTaskModel)
oprot.writeFieldEnd()
- if self.taskError is not None:
- oprot.writeFieldBegin('taskError', TType.LIST, 9)
- oprot.writeListBegin(TType.STRUCT, len(self.taskError))
- for iter19 in self.taskError:
+ if self.taskErrors is not None:
+ oprot.writeFieldBegin('taskErrors', TType.LIST, 9)
+ oprot.writeListBegin(TType.STRUCT, len(self.taskErrors))
+ for iter19 in self.taskErrors:
iter19.write(oprot)
oprot.writeListEnd()
oprot.writeFieldEnd()
@@ -277,8 +277,8 @@ class TaskModel:
raise TProtocol.TProtocolException(message='Required field creationTime is unset!')
if self.lastUpdateTime is None:
raise TProtocol.TProtocolException(message='Required field lastUpdateTime is unset!')
- if self.taskStatus is None:
- raise TProtocol.TProtocolException(message='Required field taskStatus is unset!')
+ if self.taskStatuses is None:
+ raise TProtocol.TProtocolException(message='Required field taskStatuses is unset!')
return
@@ -289,10 +289,10 @@ class TaskModel:
value = (value * 31) ^ hash(self.parentProcessId)
value = (value * 31) ^ hash(self.creationTime)
value = (value * 31) ^ hash(self.lastUpdateTime)
- value = (value * 31) ^ hash(self.taskStatus)
+ value = (value * 31) ^ hash(self.taskStatuses)
value = (value * 31) ^ hash(self.taskDetail)
value = (value * 31) ^ hash(self.subTaskModel)
- value = (value * 31) ^ hash(self.taskError)
+ value = (value * 31) ^ hash(self.taskErrors)
value = (value * 31) ^ hash(self.jobs)
return value
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
index a3b0f9b..0284ed4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
@@ -28,14 +28,13 @@ import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePrefe
import org.apache.airavata.registry.core.app.catalog.resources.*;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogThriftConversion;
import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.CompositeIdentifier;
import org.apache.airavata.registry.cpi.UsrResourceProfile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
public class UsrResourceProfileImpl implements UsrResourceProfile {
private final static Logger logger = LoggerFactory.getLogger(UsrResourceProfileImpl.class);
@@ -44,6 +43,9 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public String addUserResourceProfile(org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile userResourceProfile) throws AppCatalogException {
try {
UserResourceProfileResource profileResource = new UserResourceProfileResource();
+ if (!userResourceProfile.getUserId().equals("")){
+ profileResource.setUserId(userResourceProfile.getUserId());
+ }
if (!userResourceProfile.getGatewayID().equals("")){
profileResource.setGatewayID(userResourceProfile.getGatewayID());
}
@@ -56,6 +58,7 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
if (userResourceProfile.getIdentityServerPwdCredToken() != null){
profileResource.setIdentityServerPwdCredToken(userResourceProfile.getIdentityServerPwdCredToken());
}
+ profileResource.setUserId(userResourceProfile.getUserId());
profileResource.setGatewayID(userResourceProfile.getGatewayID());
profileResource.save();
List<UserComputeResourcePreference> userComputeResourcePreferences = userResourceProfile.getUserComputeResourcePreferences();
@@ -91,6 +94,7 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
resource.setStorageResourceId(storagePreference.getStorageResourceId());
resource.setGatewayId(profileResource.getGatewayID());
+ resource.setUserId(profileResource.getUserId());
resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
resource.setLoginUserName(storagePreference.getLoginUserName());
resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
@@ -109,7 +113,8 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public void updateUserResourceProfile(String userId, String gatewayId, org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile updatedProfile) throws AppCatalogException {
try {
UserResourceProfileResource profileResource = new UserResourceProfileResource();
- UserResourceProfileResource existingUP = (UserResourceProfileResource)profileResource.get(userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId,gatewayId);
+ UserResourceProfileResource existingUP = (UserResourceProfileResource)profileResource.get(ids);
existingUP.setCredentialStoreToken(updatedProfile.getCredentialStoreToken());
existingUP.setIdentityServerTenant(updatedProfile.getIdentityServerTenant());
existingUP.setIdentityServerPwdCredToken(updatedProfile.getIdentityServerPwdCredToken());
@@ -166,14 +171,15 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public UserResourceProfile getUserResourceProfile(String userId, String gatewayId) throws AppCatalogException {
try {
UserResourceProfileResource resource = new UserResourceProfileResource();
- UserResourceProfileResource uResource = (UserResourceProfileResource)resource.get(userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId,gatewayId);
+ UserResourceProfileResource uResource = (UserResourceProfileResource)resource.get(ids);
UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
- List<AppCatalogResource> usercomputePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, userId);
+ List<AppCatalogResource> usercomputePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
List<UserComputeResourcePreference> userComputeResourcePreferences = AppCatalogThriftConversion.getUserComputeResourcePreferences(usercomputePrefList);
- List<UserStoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayId);
+ List<UserStoragePreference> dataStoragePreferences = getAllUserStoragePreferences(userId,gatewayId);
return AppCatalogThriftConversion.getUserResourceProfile(uResource, userComputeResourcePreferences, dataStoragePreferences);
}catch (Exception e) {
- logger.error("Error while retrieving gateway profile...", e);
+ logger.error("Error while retrieving user resource profile...", e);
throw new AppCatalogException(e);
}
}
@@ -182,7 +188,8 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public boolean removeUserResourceProfile(String userId, String gatewayId) throws AppCatalogException {
try {
UserResourceProfileResource resource = new UserResourceProfileResource();
- resource.remove(userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId,gatewayId);
+ resource.remove(ids);
return true;
}catch (Exception e) {
logger.error("Error while deleting user resource profile...", e);
@@ -194,9 +201,7 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public boolean removeUserComputeResourcePreferenceFromGateway(String userId, String gatewayId, String preferenceId) throws AppCatalogException {
try {
UserComputeHostPreferenceResource resource = new UserComputeHostPreferenceResource();
- Map<String, String> ids = new HashMap<String, String>();
- ids.put(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, userId);
- ids.put(AppCatAbstractResource.UserComputeResourcePreferenceConstants.RESOURCE_ID, preferenceId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId,gatewayId);
resource.remove(ids);
return true;
}catch (Exception e) {
@@ -209,9 +214,7 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public boolean removeUserDataStoragePreferenceFromGateway(String userId, String gatewayId, String preferenceId) throws AppCatalogException {
try {
UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
- Map<String, String> ids = new HashMap<String, String>();
- ids.put(AppCatAbstractResource.UserStoragePreferenceConstants.USER_ID, userId);
- ids.put(AppCatAbstractResource.UserStoragePreferenceConstants.STORAGE_ID, preferenceId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId,gatewayId);
resource.remove(ids);
return true;
}catch (Exception e) {
@@ -224,7 +227,8 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public boolean isUserResourceProfileExists(String userId, String gatewayId) throws AppCatalogException {
try {
UserResourceProfileResource resource = new UserResourceProfileResource();
- return resource.isExists(userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
+ return resource.isExists(ids);
}catch (Exception e) {
logger.error("Error while retrieving user resource profile...", e);
throw new AppCatalogException(e);
@@ -240,7 +244,8 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public UserComputeResourcePreference getUserComputeResourcePreference(String userId, String gatewayId, String hostId) throws AppCatalogException {
try {
UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
- List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
+ List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
for (AppCatalogResource resource : computePrefList){
UserComputeHostPreferenceResource cmP = (UserComputeHostPreferenceResource) resource;
if (cmP.getResourceId() != null && !cmP.getResourceId().equals("")){
@@ -260,7 +265,8 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
public UserStoragePreference getUserStoragePreference(String userId, String gatewayId, String storageId) throws AppCatalogException {
try {
UserStoragePreferenceResource prefResource = new UserStoragePreferenceResource();
- List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
+ List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
for (AppCatalogResource resource : computePrefList){
UserStoragePreferenceResource dsP = (UserStoragePreferenceResource) resource;
if (dsP.getStorageResourceId() != null && !dsP.getStorageResourceId().equals("")){
@@ -280,11 +286,12 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
* @param userId
* @return
*/
-
- public List<UserComputeResourcePreference> getAllUserComputeResourcePreferences(String userId) throws AppCatalogException {
+ @Override
+ public List<UserComputeResourcePreference> getAllUserComputeResourcePreferences(String userId, String gatewayID) throws AppCatalogException {
try {
- ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
- List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, userId);
+ UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
+ CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayID);
+ List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
return AppCatalogThriftConversion.getUserComputeResourcePreferences(computePrefList);
}catch (Exception e) {
logger.error("Error while retrieving compute resource preference...", e);
@@ -292,11 +299,12 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
}
}
-
- public List<UserStoragePreference> getAllStoragePreferences(String userId) throws AppCatalogException {
+ @Override
+ public List<UserStoragePreference> getAllUserStoragePreferences(String userId, String gatewayID) throws AppCatalogException {
try {
UserStoragePreferenceResource prefResource = new UserStoragePreferenceResource();
- List<AppCatalogResource> dataStoragePrefList = prefResource.get(AppCatAbstractResource.UserStoragePreferenceConstants.USER_ID, userId);
+ CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayID);
+ List<AppCatalogResource> dataStoragePrefList = prefResource.get(AppCatAbstractResource.UserStoragePreferenceConstants.USER_ID, ids);
return AppCatalogThriftConversion.getUserDataStoragePreferences(dataStoragePrefList);
}catch (Exception e) {
logger.error("Error while retrieving data storage preference...", e);
@@ -324,10 +332,11 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
@Override
public String getUserNamefromID(String userId, String gatewayID) throws AppCatalogException {
-// This method implementation is critical
+// Implementation not need, username and ID are some.
return null;
}
+
@Override
public List<UserResourceProfile> getAllUserResourceProfiles() throws AppCatalogException {
try {
@@ -337,15 +346,15 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
if (resourceList != null && !resourceList.isEmpty()){
for (AppCatalogResource resource : resourceList){
UserResourceProfileResource userProfileResource = (UserResourceProfileResource)resource;
- List<UserComputeResourcePreference> computeResourcePreferences = getAllUserComputeResourcePreferences(userProfileResource.getUserId());
- List<UserStoragePreference> dataStoragePreferences = getAllStoragePreferences(userProfileResource.getUserId());
+ List<UserComputeResourcePreference> computeResourcePreferences = getAllUserComputeResourcePreferences(userProfileResource.getUserId(),userProfileResource.getGatewayID());
+ List<UserStoragePreference> dataStoragePreferences = getAllUserStoragePreferences(userProfileResource.getUserId(), userProfileResource.getGatewayID());
UserResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getUserResourceProfile(userProfileResource, computeResourcePreferences, dataStoragePreferences);
gatewayResourceProfileList.add(gatewayResourceProfile);
}
}
return gatewayResourceProfileList;
}catch (Exception e) {
- logger.error("Error while retrieving gateway ids...", e);
+ logger.error("Error while retrieving user resource profiles...", e);
throw new AppCatalogException(e);
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreference.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreference.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreference.java
index cda901c..05f6e7c 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreference.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreference.java
@@ -27,17 +27,16 @@ import java.sql.Timestamp;
@Entity
@Table(name = "USER_COMPUTE_RESOURCE_PREFERENCE")
-@IdClass(ComputeResourcePreferencePK.class)
+@IdClass(UserComputeResourcePreferencePK.class)
public class UserComputeResourcePreference {
@Id
- @Column(name = "GATEWAY_ID")
- private String gatewayId;
- @Id
@Column(name = "USER_ID")
private String userId;
@Id
@Column(name = "RESOURCE_ID")
private String resourceId;
+ @Column(name = "GATEWAY_ID")
+ private String gatewayID;
@Column(name = "PREFERED_BATCH_QUEUE")
private String batchQueue;
@Column(name = "SCRATCH_LOCATION")
@@ -64,7 +63,7 @@ public class UserComputeResourcePreference {
@ManyToOne(cascade= CascadeType.MERGE)
- @JoinColumn(name = "GATEWAY_ID")
+ @JoinColumn(name = "USER_ID")
private UserResourceProfile userResouceProfile;
/*User Id should be linked to user profile table once it is finalized and created*/
@@ -77,12 +76,12 @@ public class UserComputeResourcePreference {
this.userId = userId;
}
- public String getGatewayId() {
- return gatewayId;
+ public String getGatewayID() {
+ return gatewayID;
}
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
+ public void setGatewayID(String gatewayID) {
+ this.gatewayID = gatewayID;
}
public String getResourceId() {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreferencePK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreferencePK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreferencePK.java
index d454852..0192f79 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreferencePK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserComputeResourcePreferencePK.java
@@ -24,13 +24,11 @@ package org.apache.airavata.registry.core.app.catalog.model;
import java.io.Serializable;
public class UserComputeResourcePreferencePK implements Serializable {
- private String gatewayId;
private String resourceId;
private String userId;
- public UserComputeResourcePreferencePK(String userId, String gatewayId, String resourceId) {
+ public UserComputeResourcePreferencePK(String userId, String resourceId) {
this.userId = userId;
- this.gatewayId = gatewayId;
this.resourceId = resourceId;
}
@@ -55,14 +53,6 @@ public class UserComputeResourcePreferencePK implements Serializable {
this.userId = userId;
}
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
public String getResourceId() {
return resourceId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserResourceProfile.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserResourceProfile.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserResourceProfile.java
index 6d570de..9156168 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserResourceProfile.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserResourceProfile.java
@@ -31,11 +31,12 @@ import java.sql.Timestamp;
@Entity
@Table(name = "USER_RESOURCE_PROFILE")
public class UserResourceProfile implements Serializable {
+
@Id
@Column(name = "USER_ID")
private String userId;
- @Id
+
@Column(name = "GATEWAY_ID")
private String gatewayID;
@@ -79,6 +80,10 @@ public class UserResourceProfile implements Serializable {
return gatewayID;
}
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
public void setGatewayID(String gatewayID) {
this.gatewayID = gatewayID;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
index 49915b5..3efbd7b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
@@ -26,14 +26,13 @@ import javax.persistence.*;
@Entity
@Table(name = "USER_STORAGE_PREFERENCE")
-@IdClass(StoragePreferencePK.class)
+@IdClass(UserStoragePreferencePK.class)
public class UserStoragePreference {
@Id
@Column(name = "USER_ID")
private String userId;
- @Id
@Column(name = "GATEWAY_ID")
- private String gatewayId;
+ private String gatewayID;
@Id
@Column(name = "STORAGE_RESOURCE_ID")
private String storageResourceId;
@@ -45,7 +44,7 @@ public class UserStoragePreference {
private String computeResourceCSToken;
@ManyToOne(cascade= CascadeType.MERGE)
- @JoinColumn(name = "GATEWAY_ID")
+ @JoinColumn(name = "USER_ID")
private UserResourceProfile userResourceProfile;
public String getUserId() {
@@ -56,12 +55,12 @@ public class UserStoragePreference {
this.userId = userId;
}
- public String getGatewayId() {
- return gatewayId;
+ public String getGatewayID() {
+ return gatewayID;
}
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
+ public void setGatewayID(String gatewayID) {
+ this.gatewayID = gatewayID;
}
public UserResourceProfile getUserResourceProfile() {
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
index 35a6f42..7943b5a 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
@@ -26,7 +26,6 @@ import java.io.Serializable;
public class UserStoragePreferencePK implements Serializable {
private String userId;
- private String gatewayId;
private String storageResourceId;
public UserStoragePreferencePK(String userId, String storageResourceId) {
@@ -55,14 +54,6 @@ public class UserStoragePreferencePK implements Serializable {
this.userId = userId;
}
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
public String getStorageResourceId() {
return storageResourceId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
index 0846a47..c968175 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
@@ -54,7 +54,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public static final String APPLICATION_OUTPUT = "ApplicationIntOutput";
public static final String WORKFLOW_OUTPUT = "WorkflowOutput";
public static final String GATEWAY_PROFILE = "GatewayProfile";
- public static final String USER_RESOURCE_PROFILE = "userResourceProfile";
+ public static final String USER_RESOURCE_PROFILE = "UserResourceProfile";
public static final String COMPUTE_RESOURCE_PREFERENCE = "ComputeResourcePreference";
public static final String USER_COMPUTE_RESOURCE_PREFERENCE = "UserComputeResourcePreference";
public static final String STORAGE_PREFERENCE = "StoragePreference";
@@ -89,7 +89,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public final class GatewayClientCredentialConstants {
public static final String CLIENT_KEY = "clientKey";
public static final String CLIENT_SECRET = "clientSecret";
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
}
@@ -201,7 +201,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public final class ApplicationModuleConstants {
public static final String MODULE_ID = "moduleID";
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
public static final String MODULE_NAME = "moduleName";
public static final String MODULE_VERSION = "moduleVersion";
public static final String MODULE_DESC = "moduleDesc";
@@ -211,7 +211,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public static final String APP_MODULE_ID = "appModuleID";
public static final String DEPLOYMENT_ID = "deploymentID";
public static final String COMPUTE_HOST_ID = "hostID";
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
public static final String EXECUTABLE_PATH = "executablePath";
public static final String APPLICATION_DESC = "applicationDesc";
public static final String ENV_MODULE_LOAD_CMD = "envModuleLoaString";
@@ -239,7 +239,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public final class ApplicationInterfaceConstants {
public static final String INTERFACE_ID = "interfaceID";
public static final String APPLICATION_NAME = "appName";
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
}
public final class AppModuleMappingConstants {
@@ -295,7 +295,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
}
public final class ComputeResourcePreferenceConstants {
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
public static final String RESOURCE_ID = "resourceId";
public static final String OVERRIDE_BY_AIRAVATA = "overrideByAiravata";
public static final String PREFERED_JOB_SUB_PROTOCOL = "preferedJobSubmissionProtocol";
@@ -306,7 +306,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
}
public final class UserComputeResourcePreferenceConstants {
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
public static final String USER_ID = "userId";
public static final String RESOURCE_ID = "resourceId";
public static final String PREFERED_BATCH_QUEUE = "batchQueue";
@@ -356,12 +356,12 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
}
public final class StoragePreferenceConstants {
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
public static final String STORAGE_ID = "storageResourceId";
}
public final class UserStoragePreferenceConstants {
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
public static final String USER_ID = "userId";
public static final String STORAGE_ID = "storageResourceId";
}
@@ -438,6 +438,6 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public static final String CREATED_USER = "createdUser";
public static final String GRAPH = "graph";
public static final String WF_TEMPLATE_ID = "wfTemplateId";
- public static final String GATEWAY_ID = "gatewayId";
+ public static final String GATEWAY_ID = "gatewayID";
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
index 180625b..4bbd952 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
@@ -23,13 +23,14 @@ package org.apache.airavata.registry.core.app.catalog.resources;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile;
import org.apache.airavata.registry.core.app.catalog.model.UserComputeResourcePreference;
import org.apache.airavata.registry.core.app.catalog.model.UserComputeResourcePreferencePK;
+import org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.CompositeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,13 +38,11 @@ import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.sql.Timestamp;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
private final static Logger logger = LoggerFactory.getLogger(UserComputeHostPreferenceResource.class);
- private String gatewayId;
+ private String gatewayID;
private String resourceId;
private String userId;
private String batchQueue;
@@ -76,11 +75,11 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
}
public String getGatewayId() {
- return gatewayId;
+ return gatewayID;
}
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
+ public void setGatewayId(String gatewayID) {
+ this.gatewayID = gatewayID;
}
public String getResourceId() {
@@ -174,12 +173,12 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
@Override
public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
@@ -187,8 +186,8 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_COMPUTE_RESOURCE_PREFERENCE);
- generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(UserComputeResourcePreferenceConstants.RESOURCE_ID));
- generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.get(UserComputeResourcePreferenceConstants.USER_ID));
+ generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.getSecondLevelIdentifier().toString());
Query q = generator.deleteQuery(em);
q.executeUpdate();
@@ -214,12 +213,12 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
@@ -227,8 +226,8 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_COMPUTE_RESOURCE_PREFERENCE);
- generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(UserComputeResourcePreferenceConstants.RESOURCE_ID));
- generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.get(UserComputeResourcePreferenceConstants.USER_ID));
+ generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.getSecondLevelIdentifier().toString());
Query q = generator.selectQuery(em);
UserComputeResourcePreference preference = (UserComputeResourcePreference) q.getSingleResult();
UserComputeHostPreferenceResource preferenceResource =
@@ -281,7 +280,15 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
}
}
} else if (fieldName.equals(UserComputeResourcePreferenceConstants.USER_ID)) {
- generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, value);
+ CompositeIdentifier ids;
+ if (value instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) value;
+ } else {
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
+ }
+ generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserComputeResourcePreferenceConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
@@ -347,7 +354,7 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
- UserComputeResourcePreference existingPreference = em.find(UserComputeResourcePreference.class, new UserComputeResourcePreferencePK(userId, gatewayId, resourceId));
+ UserComputeResourcePreference existingPreference = em.find(UserComputeResourcePreference.class, new UserComputeResourcePreferencePK(userId, resourceId));
if (em.isOpen()) {
if (em.getTransaction().isActive()){
em.getTransaction().rollback();
@@ -361,8 +368,8 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class, userId);
if (existingPreference != null) {
existingPreference.setResourceId(resourceId);
- existingPreference.setGatewayId(userId);
- existingPreference.setGatewayId(gatewayId);
+ existingPreference.setUserId(userId);
+ existingPreference.setGatewayID(gatewayID);
existingPreference.setComputeHostResource(computeResource);
existingPreference.setUserResouceProfile(userResourceProfile);
existingPreference.setScratchLocation(scratchLocation);
@@ -378,8 +385,8 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
} else {
UserComputeResourcePreference resourcePreference = new UserComputeResourcePreference();
resourcePreference.setResourceId(resourceId);
- resourcePreference.setGatewayId(gatewayId);
- resourcePreference.setGatewayId(userId);
+ resourcePreference.setGatewayID(gatewayID);
+ resourcePreference.setUserId(userId);
resourcePreference.setComputeHostResource(computeResource);
resourcePreference.setScratchLocation(scratchLocation);
resourcePreference.setProjectNumber(projectNumber);
@@ -414,21 +421,20 @@ public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
@Override
public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
UserComputeResourcePreference existingPreference = em.find(UserComputeResourcePreference.class,
- new UserComputeResourcePreferencePK(ids.get(UserComputeResourcePreferenceConstants.USER_ID),
- ids.get(UserComputeResourcePreferenceConstants.GATEWAY_ID),
- ids.get(UserComputeResourcePreferenceConstants.RESOURCE_ID)));
+ new UserComputeResourcePreferencePK(ids.getTopLevelIdentifier().toString(),
+ ids.getSecondLevelIdentifier().toString()));
if (em.isOpen()) {
if (em.getTransaction().isActive()){
em.getTransaction().rollback();
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
index 208c835..ed27935 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
@@ -26,6 +26,7 @@ import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.CompositeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -106,12 +107,19 @@ public class UserResourceProfileResource extends AppCatAbstractResource {
public void remove(Object identifier) throws AppCatalogException {
EntityManager em = null;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
+ } else {
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
+ }
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
- generator.setParameter(UserResourceProfileConstants.GATEWAY_ID, identifier);
- generator.setParameter(UserResourceProfileConstants.USER_ID, identifier);
+ generator.setParameter(UserResourceProfileConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
+ generator.setParameter(UserResourceProfileConstants.USER_ID, ids.getTopLevelIdentifier().toString());
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
@@ -136,11 +144,20 @@ public class UserResourceProfileResource extends AppCatAbstractResource {
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
+ } else {
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
+ }
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
- generator.setParameter(UserResourceProfileConstants.USER_ID, identifier);
+ logger.info(userId,"retrieved userId at UserREsourceProfileREsource : " + ids.getTopLevelIdentifier());
+ generator.setParameter(UserResourceProfileConstants.USER_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserResourceProfileConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
Query q = generator.selectQuery(em);
UserResourceProfile userResourceProfile = (UserResourceProfile) q.getSingleResult();
UserResourceProfileResource userResourceProfileResource =
@@ -167,15 +184,15 @@ public class UserResourceProfileResource extends AppCatAbstractResource {
}
}
- public List<AppCatalogResource> get(String userId, Object value) throws AppCatalogException {
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> userResourceProfileResources = new ArrayList<AppCatalogResource>();
EntityManager em = null;
- HashMap<String, String> ids;
- if (value instanceof Map) {
- ids = (HashMap) value;
+ CompositeIdentifier ids;
+ if (value instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) value;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
try {
em = AppCatalogJPAUtils.getEntityManager();
@@ -183,8 +200,9 @@ public class UserResourceProfileResource extends AppCatAbstractResource {
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
List results;
- if (userId.equals(UserResourceProfileConstants.USER_ID)) {
- generator.setParameter(UserResourceProfileConstants.USER_ID, ids.get(UserResourceProfileConstants.USER_ID));
+ if (fieldName.equals(UserResourceProfileConstants.USER_ID)) {
+ generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserStoragePreferenceConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
@@ -358,7 +376,7 @@ public class UserResourceProfileResource extends AppCatAbstractResource {
} else {
UserResourceProfile userResourceProfile = new UserResourceProfile();
userResourceProfile.setGatewayID(gatewayID);
- userResourceProfile.setGatewayID(userId);
+ userResourceProfile.setUserId(userId);
userResourceProfile.setCreationTime(AiravataUtils.getCurrentTimestamp());
if (credentialStoreToken != null){
userResourceProfile.setCredentialStoreToken(credentialStoreToken);
@@ -393,23 +411,30 @@ public class UserResourceProfileResource extends AppCatAbstractResource {
public boolean isExists(Object identifier) throws AppCatalogException {
EntityManager em = null;
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
try {
em = AppCatalogJPAUtils.getEntityManager();
- UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class, ids.get(UserResourceProfileConstants.USER_ID));
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
+ List results;
+ generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserStoragePreferenceConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
+ q = generator.selectQuery(em);
+ results = q.getResultList();
if (em.isOpen()) {
if (em.getTransaction().isActive()){
em.getTransaction().rollback();
}
em.close();
}
- return userResourceProfile != null;
+ return results != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
index 37dadc6..b43dfbd 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
@@ -29,19 +29,18 @@ import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.CompositeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
public class UserStoragePreferenceResource extends AppCatAbstractResource {
private final static Logger logger = LoggerFactory.getLogger(UserStoragePreferenceResource.class);
- private String gatewayId;
+ private String gatewayID;
private String userId;
private String storageResourceId;
private String loginUserName;
@@ -68,11 +67,11 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
}
public String getGatewayId() {
- return gatewayId;
+ return gatewayID;
}
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
+ public void setGatewayId(String gatewayID) {
+ this.gatewayID = gatewayID;
}
public UserResourceProfileResource getUserResourceProfileResource() {
@@ -109,12 +108,12 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
@Override
public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
@@ -122,8 +121,8 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_STORAGE_PREFERENCE);
- generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, ids.get(UserStoragePreferenceConstants.STORAGE_ID));
- generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.get(UserStoragePreferenceConstants.USER_ID));
+ generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.getSecondLevelIdentifier().toString());
Query q = generator.deleteQuery(em);
q.executeUpdate();
@@ -149,12 +148,12 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
@@ -162,8 +161,8 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_STORAGE_PREFERENCE);
- generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.get(UserStoragePreferenceConstants.USER_ID));
- generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, ids.get(UserStoragePreferenceConstants.STORAGE_ID));
+ generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, ids.getSecondLevelIdentifier().toString());
Query q = generator.selectQuery(em);
UserStoragePreference preference = (UserStoragePreference) q.getSingleResult();
UserStoragePreferenceResource preferenceResource =
@@ -216,7 +215,15 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
}
}
} else if (fieldName.equals(UserStoragePreferenceConstants.USER_ID)) {
- generator.setParameter(UserStoragePreferenceConstants.USER_ID, value);
+ CompositeIdentifier ids;
+ if (value instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) value;
+ } else {
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
+ }
+ generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.getTopLevelIdentifier().toString());
+ generator.setParameter(UserStoragePreferenceConstants.GATEWAY_ID, ids.getSecondLevelIdentifier().toString());
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
@@ -295,8 +302,8 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class, userId);
if (existingPreference != null) {
existingPreference.setStorageResourceId(storageResourceId);
- existingPreference.setGatewayId(userId);
- existingPreference.setGatewayId(gatewayId);
+ existingPreference.setGatewayID(userId);
+ existingPreference.setGatewayID(gatewayID);
existingPreference.setUserResourceProfile(userResourceProfile);
existingPreference.setLoginUserName(loginUserName);
existingPreference.setComputeResourceCSToken(resourceCSToken);
@@ -305,8 +312,8 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
} else {
UserStoragePreference resourcePreference = new UserStoragePreference();
resourcePreference.setStorageResourceId(storageResourceId);
- resourcePreference.setGatewayId(gatewayId);
- resourcePreference.setGatewayId(userId);
+ resourcePreference.setGatewayID(gatewayID);
+ resourcePreference.setGatewayID(userId);
resourcePreference.setUserResourceProfile(userResourceProfile);
resourcePreference.setLoginUserName(loginUserName);
resourcePreference.setComputeResourceCSToken(resourceCSToken);
@@ -335,20 +342,20 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource {
@Override
public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
+ CompositeIdentifier ids;
+ if (identifier instanceof CompositeIdentifier) {
+ ids = (CompositeIdentifier) identifier;
} else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ logger.error("Identifier should be a instance of CompositeIdentifier class");
+ throw new AppCatalogException("Identifier should be a instance of CompositeIdentifier class");
}
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
UserStoragePreference existingPreference = em.find(UserStoragePreference.class,
- new UserStoragePreferencePK(ids.get(UserStoragePreferenceConstants.USER_ID),
- ids.get(UserStoragePreferenceConstants.STORAGE_ID)));
+ new UserStoragePreferencePK(ids.getTopLevelIdentifier().toString(),
+ ids.getSecondLevelIdentifier().toString()));
if (em.isOpen()) {
if (em.getTransaction().isActive()){
em.getTransaction().rollback();
http://git-wip-us.apache.org/repos/asf/airavata/blob/8469effc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
index a62259b..1f37786 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
@@ -272,6 +272,13 @@ public class AppCatalogJPAUtils {
logger.error("Object should be a GatewayProfile.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GatewayProfile.");
}
+ case USER_RESOURCE_PROFILE:
+ if (o instanceof UserResourceProfile) {
+ return createUserResourceProfile((UserResourceProfile) o);
+ } else {
+ logger.error("Object should be a UserResourceProfile.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a UserResourceProfile.");
+ }
case COMPUTE_RESOURCE_PREFERENCE:
if (o instanceof ComputeResourcePreference) {
return createComputeResourcePref((ComputeResourcePreference) o);
@@ -279,6 +286,13 @@ public class AppCatalogJPAUtils {
logger.error("Object should be a Compute Resource Preference.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Compute Resource Preference.");
}
+ case USER_COMPUTE_RESOURCE_PREFERENCE:
+ if (o instanceof UserComputeResourcePreference) {
+ return createUserComputeResourcePref((UserComputeResourcePreference) o);
+ } else {
+ logger.error("Object should be a User Compute Resource Preference.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a User Compute Resource Preference.");
+ }
case STORAGE_PREFERENCE:
if (o instanceof StoragePreference) {
return createStoragePref((StoragePreference) o);
@@ -286,6 +300,13 @@ public class AppCatalogJPAUtils {
logger.error("Object should be a data storage Preference.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a data storage Preference.");
}
+ case USER_STORAGE_PREFERENCE:
+ if (o instanceof UserStoragePreference) {
+ return createUserStoragePref((UserStoragePreference) o);
+ } else {
+ logger.error("Object should be a User data storage Preference.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a User data storage Preference.");
+ }
case STORAGE_RESOURCE:
if (o instanceof StorageResource) {
return createStorageResource((StorageResource) o);
@@ -857,6 +878,22 @@ public class AppCatalogJPAUtils {
return resource;
}
+ private static AppCatalogResource createUserResourceProfile(UserResourceProfile o) {
+ UserResourceProfileResource resource = new UserResourceProfileResource();
+ if (o != null) {
+ resource.setGatewayID(o.getGatewayID());
+ resource.setUserId(o.getUserID());
+ resource.setCreatedTime(o.getCreationTime());
+ resource.setCredentialStoreToken(o.getCredentialStoreToken());
+ resource.setIdentityServerTenant(o.getIdentityServerTenant());
+ resource.setIdentityServerPwdCredToken(o.getIdentityServerPwdCredToken());
+ if (o.getUpdateTime() != null) {
+ resource.setUpdatedTime(o.getUpdateTime());
+ }
+ }
+ return resource;
+ }
+
private static AppCatalogResource createComputeResourcePref(ComputeResourcePreference o) {
ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
if (o != null) {
@@ -881,6 +918,27 @@ public class AppCatalogJPAUtils {
return resource;
}
+ private static AppCatalogResource createUserComputeResourcePref(UserComputeResourcePreference o) {
+ UserComputeHostPreferenceResource resource = new UserComputeHostPreferenceResource();
+ if (o != null) {
+ resource.setGatewayId(o.getGatewayID());
+ resource.setUserId(o.getUserId());
+ resource.setResourceId(o.getResourceId());
+ resource.setBatchQueue(o.getBatchQueue());
+ resource.setScratchLocation(o.getScratchLocation());
+ resource.setProjectNumber(o.getProjectNumber());
+ resource.setLoginUserName(o.getLoginUserName());
+ resource.setResourceCSToken(o.getComputeResourceCSToken());
+ resource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeHostResource()));
+ resource.setUserResourceProfileResource((UserResourceProfileResource) createUserResourceProfile(o.getUserResouceProfile()));
+ resource.setQualityOfService(o.getQualityOfService());
+ resource.setReservation(o.getReservation());
+ resource.setReservationStartTime(o.getReservationStartTime());
+ resource.setReservationEndTime(o.getReservationEndTime());
+ }
+ return resource;
+ }
+
private static AppCatalogResource createStoragePref(StoragePreference o) {
StoragePreferenceResource resource = new StoragePreferenceResource();
if (o != null) {
@@ -894,6 +952,20 @@ public class AppCatalogJPAUtils {
return resource;
}
+ private static AppCatalogResource createUserStoragePref(UserStoragePreference o) {
+ UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
+ if (o != null) {
+ resource.setGatewayId(o.getGatewayID());
+ resource.setUserId(o.getUserId());
+ resource.setStorageResourceId(o.getStorageResourceId());
+ resource.setLoginUserName(o.getLoginUserName());
+ resource.setResourceCSToken(o.getComputeResourceCSToken());
+ resource.setFsRootLocation(o.getFsRootLocation());
+ resource.setUserResourceProfileResource((UserResourceProfileResource) createUserResourceProfile(o.getUserResourceProfile()));
+ }
+ return resource;
+ }
+
private static AppCatalogResource createStorageResource(StorageResource o) {
StorageResourceResource resource = new StorageResourceResource();
if (o != null) {