You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/18 22:51:18 UTC
[11/17] airavata git commit: Changing the registry model and resource
packages to comply with the new data models
http://git-wip-us.apache.org/repos/asf/airavata/blob/f366c384/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
index 7755f4f..9aa35f2 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
@@ -1,131 +1,111 @@
/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-package org.apache.airavata.registry.core.experiment.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
+package org.apache.airavata.registry.core.experiment.catalog.resources;
import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.model.Process;
import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.utils.StatusType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
public class ExperimentResource extends AbstractExpCatResource {
private static final Logger logger = LoggerFactory.getLogger(ExperimentResource.class);
-// private WorkerResource worker;
- private String executionUser;
- private String expID;
- private Timestamp creationTime;
- private String gatewayId;
+ private String experimentId;
private String projectId;
- private String expName;
- private String description;
+ private String experimentType;
+ private String userName;
private String applicationId;
- private String applicationVersion;
- private String workflowTemplateId;
- private String workflowTemplateVersion;
- private String workflowExecutionId;
- private boolean enableEmailNotifications;
+ private String experimentName;
+ private Timestamp creationTime;
+ private String description;
+ private String executionId;
private String gatewayExecutionId;
- private List<ExperimentInputResource> experimentInputResources;
- private List<ExperimentOutputResource> experimentOutputputResources;
- private ComputationSchedulingResource computationSchedulingResource;
- private ConfigDataResource userConfigDataResource;
- private List<WorkflowNodeDetailResource> workflowNodeDetailResourceList;
- private List<StatusResource> stateChangeList;
- private List<ErrorDetailResource> errorDetailList;
- private StatusResource experimentStatus;
- private List<NotificationEmailResource> emailResourceList;
-
- /**
- *
- * @return experiment ID
- */
- public String getExpID() {
- return expID;
- }
+ private Boolean enableEmailNotification;
+ private String emailAddresses;
- public Timestamp getCreationTime() {
- return creationTime;
+ public String getExperimentId() {
+ return experimentId;
}
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
}
- public String getExpName() {
- return expName;
+ public String getProjectId() {
+ return projectId;
}
- public void setExpName(String expName) {
- this.expName = expName;
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
}
- public String getApplicationId() {
- return applicationId;
+ public String getExperimentType() {
+ return experimentType;
}
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
+ public void setExperimentType(String experimentType) {
+ this.experimentType = experimentType;
}
- public String getApplicationVersion() {
- return applicationVersion;
+ public String getUserName() {
+ return userName;
}
- public void setApplicationVersion(String applicationVersion) {
- this.applicationVersion = applicationVersion;
+ public void setUserName(String userName) {
+ this.userName = userName;
}
- public String getWorkflowTemplateId() {
- return workflowTemplateId;
+ public String getApplicationId() {
+ return applicationId;
}
- public void setWorkflowTemplateId(String workflowTemplateId) {
- this.workflowTemplateId = workflowTemplateId;
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
}
- public String getWorkflowTemplateVersion() {
- return workflowTemplateVersion;
+ public String getExperimentName() {
+ return experimentName;
}
- public void setWorkflowTemplateVersion(String workflowTemplateVersion) {
- this.workflowTemplateVersion = workflowTemplateVersion;
+ public void setExperimentName(String experimentName) {
+ this.experimentName = experimentName;
}
- public String getWorkflowExecutionId() {
- return workflowExecutionId;
+ public Timestamp getCreationTime() {
+ return creationTime;
}
- public void setWorkflowExecutionId(String workflowExecutionId) {
- this.workflowExecutionId = workflowExecutionId;
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
}
public String getDescription() {
@@ -136,12 +116,12 @@ public class ExperimentResource extends AbstractExpCatResource {
this.description = description;
}
- public boolean isEnableEmailNotifications() {
- return enableEmailNotifications;
+ public String getExecutionId() {
+ return executionId;
}
- public void setEnableEmailNotifications(boolean enableEmailNotifications) {
- this.enableEmailNotifications = enableEmailNotifications;
+ public void setExecutionId(String executionId) {
+ this.executionId = executionId;
}
public String getGatewayExecutionId() {
@@ -152,156 +132,56 @@ public class ExperimentResource extends AbstractExpCatResource {
this.gatewayExecutionId = gatewayExecutionId;
}
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public String getProjectId() {
- return projectId;
- }
-
- public void setProjectId(String projectId) {
- this.projectId = projectId;
- }
-
- public List<ExperimentInputResource> getExperimentInputResources() {
- return experimentInputResources;
- }
-
- public void setExperimentInputResources(List<ExperimentInputResource> experimentInputResources) {
- this.experimentInputResources = experimentInputResources;
- }
-
- public List<ExperimentOutputResource> getExperimentOutputputResources() {
- return experimentOutputputResources;
- }
-
- public void setExperimentOutputputResources(List<ExperimentOutputResource> experimentOutputputResources) {
- this.experimentOutputputResources = experimentOutputputResources;
- }
-
- public ComputationSchedulingResource getComputationSchedulingResource() {
- return computationSchedulingResource;
- }
-
- public void setComputationSchedulingResource(ComputationSchedulingResource computationSchedulingResource) {
- this.computationSchedulingResource = computationSchedulingResource;
- }
-
- public ConfigDataResource getUserConfigDataResource() {
- return userConfigDataResource;
- }
-
- public void setUserConfigDataResource(ConfigDataResource userConfigDataResource) {
- this.userConfigDataResource = userConfigDataResource;
- }
-
- public List<WorkflowNodeDetailResource> getWorkflowNodeDetailResourceList() {
- return workflowNodeDetailResourceList;
- }
-
- public void setWorkflowNodeDetailResourceList(List<WorkflowNodeDetailResource> workflowNodeDetailResourceList) {
- this.workflowNodeDetailResourceList = workflowNodeDetailResourceList;
- }
-
- public List<StatusResource> getStateChangeList() {
- return stateChangeList;
- }
-
- public void setStateChangeList(List<StatusResource> stateChangeList) {
- this.stateChangeList = stateChangeList;
- }
-
- public List<ErrorDetailResource> getErrorDetailList() {
- return errorDetailList;
- }
-
- public void setErrorDetailList(List<ErrorDetailResource> errorDetailList) {
- this.errorDetailList = errorDetailList;
- }
-
- public void setExperimentStatus(StatusResource experimentStatus) {
- this.experimentStatus = experimentStatus;
- }
-
- public List<NotificationEmailResource> getEmailResourceList() {
- return emailResourceList;
- }
-
- public void setEmailResourceList(List<NotificationEmailResource> emailResourceList) {
- this.emailResourceList = emailResourceList;
- }
-
-
- /**
- * Since experiments are at the leaf level, this method is not
- * valid for an experiment
- * @param type child resource types
- * @return UnsupportedOperationException
- */
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- switch (type){
- case EXPERIMENT_INPUT:
- ExperimentInputResource inputResource = new ExperimentInputResource();
- inputResource.setExperimentId(expID);
- return inputResource;
- case EXPERIMENT_OUTPUT:
- ExperimentOutputResource experimentOutputResource = new ExperimentOutputResource();
- experimentOutputResource.setExperimentId(expID);
- return experimentOutputResource;
- case NOTIFICATION_EMAIL:
- NotificationEmailResource emailResource = new NotificationEmailResource();
- emailResource.setExperimentId(expID);
- return emailResource;
- case WORKFLOW_NODE_DETAIL:
- WorkflowNodeDetailResource nodeDetailResource = new WorkflowNodeDetailResource();
- nodeDetailResource.setExperimentId(expID);
- return nodeDetailResource;
- case ERROR_DETAIL:
- ErrorDetailResource errorDetailResource = new ErrorDetailResource();
- errorDetailResource.setExperimentId(expID);
- return errorDetailResource;
- case STATUS:
- StatusResource statusResource = new StatusResource();
- statusResource.setExperimentId(expID);
- return statusResource;
- case CONFIG_DATA:
- ConfigDataResource configDataResource = new ConfigDataResource();
- configDataResource.setExperimentId(expID);
- return configDataResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
- schedulingResource.setExperimentId(expID);
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- AdvanceInputDataHandlingResource dataHandlingResource = new AdvanceInputDataHandlingResource();
- dataHandlingResource.setExperimentId(expID);
- return dataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- AdvancedOutputDataHandlingResource outputDataHandlingResource = new AdvancedOutputDataHandlingResource();
- outputDataHandlingResource.setExperimentId(expID);
- return outputDataHandlingResource;
- case QOS_PARAM:
- QosParamResource qosParamResource = new QosParamResource();
- qosParamResource.setExperimentId(expID);
- return qosParamResource;
- default:
- logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for experiment resource.");
- }
- }
-
- /**
- *
- * @param type child resource types
- * @param name name of the child resource
- * @return UnsupportedOperationException
- */
- public void remove(ResourceType type, Object name) throws RegistryException {
+ public Boolean getEnableEmailNotification() {
+ return enableEmailNotification;
+ }
+
+ public void setEnableEmailNotification(Boolean enableEmailNotification) {
+ this.enableEmailNotification = enableEmailNotification;
+ }
+
+ public String getEmailAddresses() {
+ return emailAddresses;
+ }
+
+ public void setEmailAddresses(String emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException{
+ switch (type){
+ case EXPERIMENT_ERROR:
+ ExperimentErrorResource errorResource = new ExperimentErrorResource();
+ errorResource.setExperimentId(experimentId);
+ return errorResource;
+ case EXPERIMENT_STATUS:
+ ExperimentStatusResource statusResource = new ExperimentStatusResource();
+ statusResource.setExperimentId(experimentId);
+ return statusResource;
+ case EXPERIMENT_INPUT:
+ ExperimentInputResource experimentInputResource = new ExperimentInputResource();
+ experimentInputResource.setExperimentId(experimentId);
+ return experimentInputResource;
+ case EXPERIMENT_OUTPUT:
+ ExperimentOutputResource outputResource = new ExperimentOutputResource();
+ outputResource.setExperimentId(experimentId);
+ return outputResource;
+ case USER_CONFIGURATION_DATA:
+ UserConfigurationDataResource configurationDataResource = new UserConfigurationDataResource();
+ configurationDataResource.setExperimentId(experimentId);
+ return configurationDataResource;
+ case PROCESS:
+ ProcessResource processResource = new ProcessResource();
+ processResource.setExperimentId(experimentId);
+ return processResource;
+ default:
+ logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for experiment resource.");
+ }
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
EntityManager em = null;
try {
em = ExpCatResourceUtils.getEntityManager();
@@ -309,75 +189,45 @@ public class ExperimentResource extends AbstractExpCatResource {
Query q;
QueryGenerator generator;
switch (type) {
- case EXPERIMENT_INPUT:
- generator = new QueryGenerator(EXPERIMENT_INPUT);
- generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case EXPERIMENT_OUTPUT:
- generator = new QueryGenerator(EXPERIMENT_OUTPUT);
- generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
+ case EXPERIMENT_ERROR:
+ generator = new QueryGenerator(EXPERIMENT_ERROR);
+ generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, name);
+ case EXPERIMENT_STATUS:
+ generator = new QueryGenerator(EXPERIMENT_STATUS);
+ generator.setParameter(ExperimentStatusConstants.EXPERIMENT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
- case WORKFLOW_NODE_DETAIL:
- generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
- generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.EXPERIMENT.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case CONFIG_DATA:
- generator = new QueryGenerator(CONFIG_DATA);
- generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
+ case EXPERIMENT_INPUT:
+ generator = new QueryGenerator(EXPERIMENT_INPUT);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_INPUT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
+ case EXPERIMENT_OUTPUT:
+ generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+ generator.setParameter(ExperimentOutputConstants.EXPERIMENT_OUTPUT_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
+ case USER_CONFIGURATION_DATA:
+ generator = new QueryGenerator(USER_CONFIGURATION_DATA);
+ generator.setParameter(UserConfigurationDataConstants.EXPERIMENT_ID, experimentId);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
+ case PROCESS:
+ generator = new QueryGenerator(PROCESS);
+ generator.setParameter(ProcessConstants.EXPERIMENT_ID, experimentId);
+ generator.setParameter(ProcessConstants.PROCESS_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
default:
- logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+ logger.error("Unsupported resource type for process detail resource.", new IllegalArgumentException());
break;
}
em.getTransaction().commit();
@@ -395,13 +245,8 @@ public class ExperimentResource extends AbstractExpCatResource {
}
}
- /**
- *
- * @param type child resource types
- * @param name name of the child resource
- * @return UnsupportedOperationException
- */
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
EntityManager em = null;
try {
em = ExpCatResourceUtils.getEntityManager();
@@ -409,115 +254,69 @@ public class ExperimentResource extends AbstractExpCatResource {
QueryGenerator generator;
Query q;
switch (type) {
- case EXPERIMENT_INPUT:
- generator = new QueryGenerator(EXPERIMENT_INPUT);
- generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
+ case EXPERIMENT_STATUS:
+ generator = new QueryGenerator(EXPERIMENT_STATUS);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
q = generator.selectQuery(em);
- Experiment_Input experimentInput = (Experiment_Input) q.getSingleResult();
- ExperimentInputResource inputResource = (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
- em.getTransaction().commit();
- em.close();
- return inputResource;
- case EXPERIMENT_OUTPUT:
- generator = new QueryGenerator(EXPERIMENT_OUTPUT);
- generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Experiment_Output experimentOutput = (Experiment_Output) q.getSingleResult();
- ExperimentOutputResource outputResource = (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
- em.getTransaction().commit();
- em.close();
- return outputResource;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
- NotificationEmailResource notificationEmailResource = (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- em.getTransaction().commit();
- em.close();
- return notificationEmailResource;
- case WORKFLOW_NODE_DETAIL:
- generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
- generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
- q = generator.selectQuery(em);
- WorkflowNodeDetail workflowNodeDetail = (WorkflowNodeDetail) q.getSingleResult();
- WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, workflowNodeDetail);
- em.getTransaction().commit();
- em.close();
- return nodeDetailResource;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.EXPERIMENT.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ ExperimentStatus status = (ExperimentStatus) q.getSingleResult();
+ ExperimentStatusResource statusResource = (ExperimentStatusResource) Utils.getResource(ResourceType.EXPERIMENT_STATUS, status);
em.getTransaction().commit();
em.close();
return statusResource;
- case CONFIG_DATA:
- generator = new QueryGenerator(CONFIG_DATA);
- generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
+ case EXPERIMENT_ERROR:
+ generator = new QueryGenerator(EXPERIMENT_ERROR);
+ generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, name);
q = generator.selectQuery(em);
- ExperimentConfigData configData = (ExperimentConfigData) q.getSingleResult();
- ConfigDataResource configDataResource = (ConfigDataResource) Utils.getResource(ResourceType.CONFIG_DATA, configData);
+ ExperimentError experimentError = (ExperimentError) q.getSingleResult();
+ ExperimentErrorResource processErrorResource = (ExperimentErrorResource) Utils.getResource(ResourceType.EXPERIMENT_ERROR, experimentError);
em.getTransaction().commit();
em.close();
- return configDataResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
- generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, null);
+ return processErrorResource;
+ case EXPERIMENT_INPUT:
+ generator = new QueryGenerator(EXPERIMENT_INPUT);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_INPUT_ID, name);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
- Computational_Resource_Scheduling scheduling = (Computational_Resource_Scheduling) q.getSingleResult();
- ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, scheduling);
+ ExperimentInput experimentInput = (ExperimentInput) q.getSingleResult();
+ ExperimentInputResource experimentInputResource = (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
em.getTransaction().commit();
em.close();
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
- generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, null);
+ return experimentInputResource;
+ case EXPERIMENT_OUTPUT:
+ generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+ generator.setParameter(ExperimentOutputConstants.EXPERIMENT_OUTPUT_ID, name);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
- AdvancedInputDataHandling inputDataHandling = (AdvancedInputDataHandling) q.getSingleResult();
- AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, inputDataHandling);
+ ExperimentOutput experimentOutput = (ExperimentOutput) q.getSingleResult();
+ ExperimentOutputResource outputResource = (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
em.getTransaction().commit();
em.close();
- return dataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
- generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, null);
+ return outputResource;
+ case USER_CONFIGURATION_DATA:
+ generator = new QueryGenerator(USER_CONFIGURATION_DATA);
+ generator.setParameter(UserConfigurationDataConstants.EXPERIMENT_ID, name);
q = generator.selectQuery(em);
- AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
- AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+ UserConfigurationData configurationData = (UserConfigurationData) q.getSingleResult();
+ UserConfigurationDataResource configurationDataResource = (UserConfigurationDataResource)
+ Utils.getResource(ResourceType.USER_CONFIGURATION_DATA, configurationData);
em.getTransaction().commit();
em.close();
- return outputDataHandlingResource;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
- generator.setParameter(QosParamsConstants.TASK_ID, null);
+ return configurationDataResource;
+ case PROCESS:
+ generator = new QueryGenerator(PROCESS);
+ generator.setParameter(ProcessConstants.PROCESS_ID, name);
+ generator.setParameter(ProcessConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
- QosParam qosParam = (QosParam) q.getSingleResult();
- QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+ Process process = (Process) q.getSingleResult();
+ ProcessResource processResource = (ProcessResource) Utils.getResource(ResourceType.PROCESS, process);
em.getTransaction().commit();
em.close();
- return qosParamResource;
+ return processResource;
default:
em.getTransaction().commit();
em.close();
logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+ throw new IllegalArgumentException("Unsupported resource type for experiment resource.");
}
} catch (Exception e) {
throw new RegistryException(e);
@@ -529,15 +328,9 @@ public class ExperimentResource extends AbstractExpCatResource {
em.close();
}
}
-
}
- /**
- *
- * @param type child resource types
- * @return UnsupportedOperationException
- */
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
EntityManager em = null;
try {
@@ -549,85 +342,57 @@ public class ExperimentResource extends AbstractExpCatResource {
switch (type) {
case EXPERIMENT_INPUT:
generator = new QueryGenerator(EXPERIMENT_INPUT);
- generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, expID);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
- Experiment_Input exInput = (Experiment_Input) result;
- ExperimentInputResource inputResource =
- (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, exInput);
- resourceList.add(inputResource);
+ ExperimentInput experimentInput = (ExperimentInput) result;
+ ExperimentInputResource experimentInputResource =
+ (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
+ resourceList.add(experimentInputResource);
}
}
break;
case EXPERIMENT_OUTPUT:
generator = new QueryGenerator(EXPERIMENT_OUTPUT);
- generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment_Output output = (Experiment_Output) result;
- ExperimentOutputResource outputResource =
- (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, output);
- resourceList.add(outputResource);
- }
- }
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Notification_Email notificationEmail = (Notification_Email) result;
- NotificationEmailResource emailResource =
- (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- resourceList.add(emailResource);
- }
- }
- break;
- case WORKFLOW_NODE_DETAIL:
- generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
- generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_ID, expID);
+ generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
- WorkflowNodeDetail nodeDetail = (WorkflowNodeDetail) result;
- WorkflowNodeDetailResource nodeDetailResource =
- (WorkflowNodeDetailResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, nodeDetail);
- resourceList.add(nodeDetailResource);
+ ExperimentOutput experimentOutput = (ExperimentOutput) result;
+ ExperimentOutputResource experimentOutputResource
+ = (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
+ resourceList.add(experimentOutputResource);
}
}
break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, expID);
+ case PROCESS:
+ generator = new QueryGenerator(PROCESS);
+ generator.setParameter(ProcessConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailResource errorDetailResource =
- (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
+ Process process = (Process) result;
+ ProcessResource processResource =
+ (ProcessResource) Utils.getResource(ResourceType.PROCESS, process);
+ resourceList.add(processResource);
}
}
break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.EXPERIMENT_ID, expID);
+ case PROCESS_ERROR:
+ generator = new QueryGenerator(EXPERIMENT_ERROR);
+ generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
- Status status = (Status) result;
- StatusResource statusResource =
- (StatusResource) Utils.getResource(ResourceType.STATUS, status);
- resourceList.add(statusResource);
+ ProcessError processError = (ProcessError) result;
+ ProcessErrorResource processErrorResource =
+ (ProcessErrorResource) Utils.getResource(ResourceType.PROCESS_ERROR, processError);
+ resourceList.add(processErrorResource);
}
}
break;
@@ -653,54 +418,31 @@ public class ExperimentResource extends AbstractExpCatResource {
return resourceList;
}
- /**
- * save experiment
- */
public void save() throws RegistryException{
EntityManager em = null;
try {
em = ExpCatResourceUtils.getEntityManager();
- Experiment existingExp = em.find(Experiment.class, expID);
+ Experiment experiment = em.find(Experiment.class, experimentId);
em.close();
-
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
- Experiment experiment = new Experiment();
- experiment.setProjectID(projectId);
- experiment.setExpId(expID);
- experiment.setExecutionUser(executionUser);
- experiment.setExecutionUser(executionUser);
- experiment.setGatewayId(gatewayId);
- experiment.setCreationTime(creationTime);
- experiment.setExpName(expName);
- experiment.setExpDesc(description);
+ if (experiment == null) {
+ experiment = new Experiment();
+ }
+ experiment.setExperimentId(experimentId);
+ experiment.setProjectId(projectId);
+ experiment.setExperimentType(experimentType);
+ experiment.setUserName(userName);
experiment.setApplicationId(applicationId);
- experiment.setAppVersion(applicationVersion);
- experiment.setWorkflowExecutionId(workflowExecutionId);
- experiment.setWorkflowTemplateVersion(workflowTemplateVersion);
- experiment.setWorkflowExecutionId(workflowExecutionId);
- experiment.setAllowNotification(enableEmailNotifications);
+ experiment.setExperimentName(experimentName);
+ experiment.setCreationTime(creationTime);
+ experiment.setDescription(description);
+ experiment.setExecutionId(executionId);
experiment.setGatewayExecutionId(gatewayExecutionId);
- if (existingExp != null) {
- existingExp.setGatewayId(gatewayId);
- existingExp.setExecutionUser(executionUser);
- existingExp.setProjectID(projectId);
- existingExp.setCreationTime(creationTime);
- existingExp.setExpName(expName);
- existingExp.setExpDesc(description);
- existingExp.setApplicationId(applicationId);
- existingExp.setAppVersion(applicationVersion);
- existingExp.setWorkflowExecutionId(workflowExecutionId);
- existingExp.setWorkflowTemplateVersion(workflowTemplateVersion);
- existingExp.setWorkflowExecutionId(workflowExecutionId);
- existingExp.setAllowNotification(enableEmailNotifications);
- existingExp.setGatewayExecutionId(gatewayExecutionId);
- experiment = em.merge(existingExp);
- } else {
- em.persist(experiment);
- }
+ experiment.setEnableEmailNotification(enableEmailNotification);
+ experiment.setEmailAddresses(emailAddresses);
+ em.persist(experiment);
em.getTransaction().commit();
- em.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RegistryException(e);
@@ -714,118 +456,53 @@ public class ExperimentResource extends AbstractExpCatResource {
}
}
- /**
- *
- * @param expID experiment ID
- */
- public void setExpID(String expID) {
- this.expID = expID;
- }
-
- public String getExecutionUser() {
- return executionUser;
- }
-
- public void setExecutionUser(String executionUser) {
- this.executionUser = executionUser;
- }
-
- public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{
- List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>();
- List<ExperimentCatResource> resources = get(ResourceType.NOTIFICATION_EMAIL);
- for (ExperimentCatResource resource : resources) {
- emailResources.add((NotificationEmailResource) resource);
- }
- return emailResources;
- }
-
- public List<ExperimentInputResource> getExperimentInputs () throws RegistryException{
- List<ExperimentInputResource> expInputs = new ArrayList<ExperimentInputResource>();
+ public List<ExperimentInputResource> getExperimentInputs() throws RegistryException{
+ List<ExperimentInputResource> experimentInputResources = new ArrayList();
List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_INPUT);
for (ExperimentCatResource resource : resources) {
- expInputs.add((ExperimentInputResource) resource);
+ ExperimentInputResource inputResource = (ExperimentInputResource) resource;
+ experimentInputResources.add(inputResource);
}
- return expInputs;
+ return experimentInputResources;
}
- public List<ExperimentOutputResource> getExperimentOutputs () throws RegistryException{
- List<ExperimentOutputResource> expOutputs = new ArrayList<ExperimentOutputResource>();
+ public List<ExperimentOutputResource> getExperimentOutputs() throws RegistryException{
+ List<ExperimentOutputResource> outputResources = new ArrayList();
List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_OUTPUT);
for (ExperimentCatResource resource : resources) {
- expOutputs.add((ExperimentOutputResource) resource);
+ ExperimentOutputResource outputResource = (ExperimentOutputResource) resource;
+ outputResources.add(outputResource);
}
- return expOutputs;
+ return outputResources;
}
- public StatusResource getExperimentStatus() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusResource expStatus = (StatusResource) resource;
- if(expStatus.getStatusType().equals(StatusType.EXPERIMENT.toString())){
- if (expStatus.getState() == null || expStatus.getState().equals("") ){
- expStatus.setState("UNKNOWN");
- }
- return expStatus;
- }
- }
- return null;
+ public ExperimentStatusResource getExperimentStatus() throws RegistryException{
+ ExperimentCatResource resource = get(ResourceType.EXPERIMENT_STATUS, executionId);
+ return (ExperimentStatusResource)resource;
}
- public List<StatusResource> getWorkflowNodeStatuses() throws RegistryException{
- List<StatusResource> statuses = new ArrayList<StatusResource>();
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ public List<ExperimentErrorResource> getExperimentErrors() throws RegistryException{
+ List<ExperimentErrorResource> experimentErrorResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_ERROR);
for (ExperimentCatResource resource : resources) {
- StatusResource workflowNodeStatus = (StatusResource) resource;
- if(workflowNodeStatus.getStatusType().equals(StatusType.WORKFLOW_NODE.toString())){
- if (workflowNodeStatus.getState() == null || workflowNodeStatus.getState().equals("")){
- workflowNodeStatus.setState("UNKNOWN");
- }
- statuses.add(workflowNodeStatus);
- }
+ ExperimentErrorResource errorResource = (ExperimentErrorResource) resource;
+ experimentErrorResources.add(errorResource);
}
- return statuses;
+ return experimentErrorResources;
}
- public List<WorkflowNodeDetailResource> getWorkflowNodeDetails () throws RegistryException{
- List<WorkflowNodeDetailResource> workflowNodeDetailResourceList = new ArrayList<WorkflowNodeDetailResource>();
- List<ExperimentCatResource> resources = get(ResourceType.WORKFLOW_NODE_DETAIL);
- for (ExperimentCatResource resource : resources) {
- WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) resource;
- workflowNodeDetailResourceList.add(nodeDetailResource);
- }
- return workflowNodeDetailResourceList;
+ public UserConfigurationDataResource getUserConfigurationDataResource() throws RegistryException{
+ ExperimentCatResource resource = get(ResourceType.USER_CONFIGURATION_DATA, experimentId);
+ return (UserConfigurationDataResource)resource;
}
- public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
- List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
- List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
+ public List<ProcessResource> getProcessList() throws RegistryException{
+ List<ProcessResource> processResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.PROCESS);
for (ExperimentCatResource resource : resources) {
- ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
- errorDetailResources.add(errorDetailResource);
+ ProcessResource processResource = (ProcessResource) resource;
+ processResources.add(processResource);
}
- return errorDetailResources;
- }
-
- public ComputationSchedulingResource getComputationScheduling (String expId) throws RegistryException{
- return (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, expId);
- }
-
- public AdvanceInputDataHandlingResource getInputDataHandling (String expId) throws RegistryException{
- return (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, expId);
- }
-
- public AdvancedOutputDataHandlingResource getOutputDataHandling (String expId) throws RegistryException{
- return (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, expId);
- }
-
- public QosParamResource getQOSparams (String expId) throws RegistryException{
- return (QosParamResource)get(ResourceType.QOS_PARAM, expId);
- }
-
- public ConfigDataResource getUserConfigData(String expID) throws RegistryException{
- return (ConfigDataResource)get(ResourceType.CONFIG_DATA, expID);
- }
- public WorkflowNodeDetailResource getWorkflowNode (String nodeId) throws RegistryException{
- return (WorkflowNodeDetailResource)get(ResourceType.WORKFLOW_NODE_DETAIL, nodeId);
+ return processResources;
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f366c384/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
new file mode 100644
index 0000000..53ef1da
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
@@ -0,0 +1,130 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentStatus;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.sql.Timestamp;
+import java.util.List;
+
+public class ExperimentStatusResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ExperimentStatusResource.class);
+ private String experimentId;
+ private String state;
+ private Timestamp timeOfStateChange;
+ private String reason;
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public Timestamp getTimeOfStateChange() {
+ return timeOfStateChange;
+ }
+
+ public void setTimeOfStateChange(Timestamp timeOfStateChange) {
+ this.timeOfStateChange = timeOfStateChange;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for process status data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for process status data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for process status data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for process status data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ExperimentStatus experimentStatus;
+ if(experimentId == null || state == null){
+ throw new RegistryException("Does not have the experiment id or state");
+ }
+ experimentStatus = em.find(ExperimentStatus.class, experimentId);
+ if(experimentStatus == null){
+ experimentStatus = new ExperimentStatus();
+ }
+ experimentStatus.setExperimentId(experimentId);
+ experimentStatus.setState(state);
+ experimentStatus.setReason(reason);
+ em.persist(experimentStatus);
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f366c384/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
index 0b0d1af..1e0aa14 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
@@ -33,15 +33,16 @@ import java.util.List;
public class ExperimentSummaryResource extends AbstractExpCatResource {
private final static Logger logger = LoggerFactory.getLogger(ExperimentSummaryResource.class);
- private String executionUser;
- private String expID;
- private String projectID;
+ private String experimentId;
+ private String projectId;
+ private String userName;
+ private String applicationId;
+ private String experimentName;
private Timestamp creationTime;
- private String expName;
private String description;
- private String applicationId;
-
- private StatusResource status;
+ private String state;
+ private String resourceHostId;
+ private Timestamp timeOfStateChange;
@Override
public ExperimentCatResource create(ResourceType type) throws RegistryException {
@@ -68,44 +69,52 @@ public class ExperimentSummaryResource extends AbstractExpCatResource {
throw new MethodNotFoundException();
}
- public String getExecutionUser() {
- return executionUser;
+ public String getExperimentId() {
+ return experimentId;
}
- public void setExecutionUser(String executionUser) {
- this.executionUser = executionUser;
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
}
- public String getExpID() {
- return expID;
+ public String getProjectId() {
+ return projectId;
}
- public void setExpID(String expID) {
- this.expID = expID;
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
}
- public String getProjectID() {
- return projectID;
+ public String getUserName() {
+ return userName;
}
- public void setProjectID(String projectID) {
- this.projectID = projectID;
+ public void setUserName(String userName) {
+ this.userName = userName;
}
- public Timestamp getCreationTime() {
- return creationTime;
+ public String getApplicationId() {
+ return applicationId;
}
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
}
- public String getExpName() {
- return expName;
+ public String getExperimentName() {
+ return experimentName;
}
- public void setExpName(String expName) {
- this.expName = expName;
+ public void setExperimentName(String experimentName) {
+ this.experimentName = experimentName;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
}
public String getDescription() {
@@ -116,19 +125,27 @@ public class ExperimentSummaryResource extends AbstractExpCatResource {
this.description = description;
}
- public String getApplicationId() {
- return applicationId;
+ public String getState() {
+ return state;
}
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getResourceHostId() {
+ return resourceHostId;
+ }
+
+ public void setResourceHostId(String resourceHostId) {
+ this.resourceHostId = resourceHostId;
}
- public StatusResource getStatus() {
- return status;
+ public Timestamp getTimeOfStateChange() {
+ return timeOfStateChange;
}
- public void setStatus(StatusResource status) {
- this.status = status;
+ public void setTimeOfStateChange(Timestamp timeOfStateChange) {
+ this.timeOfStateChange = timeOfStateChange;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/f366c384/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
index a7d8544..fae7552 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
@@ -20,12 +20,6 @@
*/
package org.apache.airavata.registry.core.experiment.catalog.resources;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
@@ -35,6 +29,11 @@ import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
public class GatewayResource extends AbstractExpCatResource {
private final static Logger logger = LoggerFactory.getLogger(GatewayResource.class);
@@ -122,7 +121,7 @@ public class GatewayResource extends AbstractExpCatResource {
return projectResource;
case EXPERIMENT:
ExperimentResource experimentResource =new ExperimentResource();
- experimentResource.setGatewayId(gatewayId);
+ experimentResource.setGatewayExecutionId(gatewayId);
return experimentResource;
case GATEWAY_WORKER:
WorkerResource workerResource = new WorkerResource();
@@ -197,7 +196,7 @@ public class GatewayResource extends AbstractExpCatResource {
generator.setParameter(GatewayWorkerConstants.USERNAME, name);
generator.setParameter(GatewayWorkerConstants.GATEWAY_ID, gatewayId);
q = generator.selectQuery(em);
- Gateway_Worker worker = (Gateway_Worker) q.getSingleResult();
+ GatewayWorker worker = (GatewayWorker) q.getSingleResult();
WorkerResource workerResource =
(WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, worker);
em.getTransaction().commit();
@@ -207,7 +206,7 @@ public class GatewayResource extends AbstractExpCatResource {
generator = new QueryGenerator(USERS);
generator.setParameter(UserConstants.USERNAME, name);
q = generator.selectQuery(em);
- Users user = (Users) q.getSingleResult();
+ User user = (User) q.getSingleResult();
UserResource userResource =
(UserResource) Utils.getResource(ResourceType.USER, user);
em.getTransaction().commit();
@@ -279,7 +278,7 @@ public class GatewayResource extends AbstractExpCatResource {
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
- Gateway_Worker gatewayWorker = (Gateway_Worker) result;
+ GatewayWorker gatewayWorker = (GatewayWorker) result;
WorkerResource workerResource =
(WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
resourceList.add(workerResource);
@@ -304,7 +303,7 @@ public class GatewayResource extends AbstractExpCatResource {
generator = new QueryGenerator(USERS);
q = generator.selectQuery(em);
for (Object o : q.getResultList()) {
- Users user = (Users) o;
+ User user = (User) o;
UserResource userResource =
(UserResource) Utils.getResource(ResourceType.USER, user);
resourceList.add(userResource);
@@ -345,15 +344,15 @@ public class GatewayResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
Gateway gateway = new Gateway();
- gateway.setGateway_name(gatewayName);
- gateway.setGateway_id(gatewayId);
+ gateway.setGatewayName(gatewayName);
+ gateway.setGatewayId(gatewayId);
gateway.setDomain(domain);
gateway.setEmailAddress(emailAddress);
if (existingGateway != null) {
existingGateway.setDomain(domain);
- existingGateway.setGateway_name(gatewayName);
+ existingGateway.setGatewayName(gatewayName);
existingGateway.setEmailAddress(emailAddress);
- gateway = em.merge(existingGateway);
+ em.merge(existingGateway);
} else {
em.persist(gateway);
}
@@ -385,12 +384,15 @@ public class GatewayResource extends AbstractExpCatResource {
switch (type) {
case GATEWAY_WORKER:
em = ExpCatResourceUtils.getEntityManager();
- Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayId, name.toString()));
+ GatewayWorkerPK gatewayWorkerPK = new GatewayWorkerPK();
+ gatewayWorkerPK.setGatewayId(gatewayId);
+ gatewayWorkerPK.setUserName(name.toString());
+ GatewayWorker existingWorker = em.find(GatewayWorker.class, gatewayWorkerPK);
em.close();
return existingWorker != null;
case USER:
em = ExpCatResourceUtils.getEntityManager();
- Users existingUser = em.find(Users.class, name);
+ User existingUser = em.find(User.class, name);
em.close();
return existingUser != null;
case EXPERIMENT:
@@ -415,12 +417,6 @@ public class GatewayResource extends AbstractExpCatResource {
}
}
- public ExperimentResource createExperiment (String experimentID) throws RegistryException{
- ExperimentResource metadataResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
- metadataResource.setExpID(experimentID);
- return metadataResource;
- }
-
public ExperimentResource getExperiment (String expId) throws RegistryException{
return (ExperimentResource)get(ResourceType.EXPERIMENT, expId);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f366c384/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java
deleted file mode 100644
index 0dffd8e..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.utils.StatusType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-public class JobDetailResource extends AbstractExpCatResource {
- private static final Logger logger = LoggerFactory.getLogger(JobDetailResource.class);
- private String jobId;
- private String taskId;
- private String jobDescription;
- private Timestamp creationTime;
- private String computeResourceConsumed;
- private String jobName;
- private String workingDir;
- private StatusResource jobStatus;
- private List<ErrorDetailResource> errors;
-
- public void setJobStatus(StatusResource jobStatus) {
- this.jobStatus = jobStatus;
- }
-
- public List<ErrorDetailResource> getErrors() {
- return errors;
- }
-
- public void setErrors(List<ErrorDetailResource> errors) {
- this.errors = errors;
- }
-
- public String getJobName() {
- return jobName;
- }
-
- public void setJobName(String jobName) {
- this.jobName = jobName;
- }
-
- public String getWorkingDir() {
- return workingDir;
- }
-
- public void setWorkingDir(String workingDir) {
- this.workingDir = workingDir;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getJobDescription() {
- return jobDescription;
- }
-
- public void setJobDescription(String jobDescription) {
- this.jobDescription = jobDescription;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getComputeResourceConsumed() {
- return computeResourceConsumed;
- }
-
- public void setComputeResourceConsumed(String computeResourceConsumed) {
- this.computeResourceConsumed = computeResourceConsumed;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- switch (type){
- case STATUS:
- StatusResource statusResource = new StatusResource();
- statusResource.setJobId(jobId);
- return statusResource;
- case ERROR_DETAIL:
- ErrorDetailResource errorDetailResource = new ErrorDetailResource();
- errorDetailResource.setJobId(jobId);
- return errorDetailResource;
- default:
- logger.error("Unsupported resource type for job details data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.JOB_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(ErrorDetailConstants.JOB_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.JOB_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
- em.getTransaction().commit();
- em.close();
- return statusResource;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.JOB_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for job details resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.JOB_ID, jobId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Status status = (Status) result;
- StatusResource statusResource =
- (StatusResource) Utils.getResource(ResourceType.STATUS, status);
- resourceList.add(statusResource);
- }
- }
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.JOB_ID, jobId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailResource errorDetailResource =
- (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
- }
- }
- break;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskId));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- JobDetail jobDetail = new JobDetail();
- jobDetail.setJobId(jobId);
- jobDetail.setTaskId(taskId);
- jobDetail.setCreationTime(creationTime);
- jobDetail.setJobName(jobName);
- jobDetail.setWorkingDir(workingDir);
- if (jobDescription != null) {
- jobDetail.setJobDescription(jobDescription.toCharArray());
- }
- jobDetail.setComputeResourceConsumed(computeResourceConsumed);
- if (existingJobDetail != null) {
- existingJobDetail.setJobId(jobId);
- existingJobDetail.setTaskId(taskId);
- existingJobDetail.setCreationTime(creationTime);
- if (jobDescription != null) {
- existingJobDetail.setJobDescription(jobDescription.toCharArray());
- }
- existingJobDetail.setComputeResourceConsumed(computeResourceConsumed);
- existingJobDetail.setJobName(jobName);
- existingJobDetail.setWorkingDir(workingDir);
- jobDetail = em.merge(existingJobDetail);
- } else {
- em.persist(jobDetail);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public StatusResource getJobStatus() {
- return jobStatus;
- }
-
- public StatusResource getJobStatus1() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusResource jobStatus = (StatusResource) resource;
- if(jobStatus.getStatusType().equals(StatusType.JOB.toString())){
- if (jobStatus.getState() == null || jobStatus.getState().equals("") ){
- jobStatus.setState("UNKNOWN");
- }
- return jobStatus;
- }
- }
- return null;
- }
-
- public StatusResource getApplicationStatus() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusResource appStatus = (StatusResource) resource;
- if(appStatus.getStatusType().equals(StatusType.APPLICATION.toString())){
- if (appStatus.getState() == null || appStatus.getState().equals("") ){
- appStatus.setState("UNKNOWN");
- }
- return appStatus;
- }
- }
- return null;
- }
-
- public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
- List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
- List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
- for(ExperimentCatResource resource : resources){
- errorDetailResources.add((ErrorDetailResource)resource);
- }
- return errorDetailResources;
- }
-
-
-}