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/05/31 23:23:16 UTC

[05/13] airavata git commit: Removing ExperimentSummary entity and using Experiment entity for ExperimentStatus

Removing ExperimentSummary entity and using Experiment entity for ExperimentStatus


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/5b1ee03c
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/5b1ee03c
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/5b1ee03c

Branch: refs/heads/master
Commit: 5b1ee03c620a004b13e473b1fb33dd73a01d18f7
Parents: 0d32c22
Author: Supun Nakandala <sc...@apache.org>
Authored: Sun May 31 14:36:09 2015 +0530
Committer: Supun Nakandala <sc...@apache.org>
Committed: Sun May 31 14:36:09 2015 +0530

----------------------------------------------------------------------
 modules/registry/airavata-jpa-registry/pom.xml  |   4 +-
 .../registry/jpa/model/Experiment.java          |  29 ++-
 .../registry/jpa/model/ExperimentSummary.java   | 198 -------------------
 .../registry/jpa/resources/Utils.java           |  63 +++---
 .../registry/jpa/resources/WorkerResource.java  |   6 +-
 .../src/main/resources/META-INF/persistence.xml |   1 -
 6 files changed, 68 insertions(+), 233 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/5b1ee03c/modules/registry/airavata-jpa-registry/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/pom.xml b/modules/registry/airavata-jpa-registry/pom.xml
index ed6d410..3e40154 100644
--- a/modules/registry/airavata-jpa-registry/pom.xml
+++ b/modules/registry/airavata-jpa-registry/pom.xml
@@ -69,11 +69,11 @@
             <artifactId>airavata-registry-cpi</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <!--dependency>
+        <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <version>${mysql.connector.version}</version>
-        </dependency-->
+        </dependency>
         <dependency>
             <groupId>org.apache.derby</groupId>
             <artifactId>derby</artifactId>

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b1ee03c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java
index 1c2d430..f1555f5 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java
@@ -26,6 +26,7 @@ import org.apache.openjpa.persistence.DataCache;
 import javax.persistence.*;
 import java.io.Serializable;
 import java.sql.Timestamp;
+import java.util.Collection;
 
 @Entity
 @Table(name = "EXPERIMENT")
@@ -61,18 +62,24 @@ public class Experiment implements Serializable {
     @Column(name = "GATEWAY_EXECUTION_ID")
     private String gatewayExecutionId;
 
-    @ManyToOne(cascade=CascadeType.MERGE)
+    @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
     @JoinColumn(name = "GATEWAY_ID")
     private Gateway gateway;
 
-    @ManyToOne(cascade=CascadeType.MERGE)
+    @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
     @JoinColumn(name = "PROJECT_ID")
     private Project project;
 
-    @ManyToOne(cascade=CascadeType.MERGE)
+    @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
     @JoinColumn(name = "EXECUTION_USER", referencedColumnName = "USER_NAME")
     private Users user;
 
+    @OneToMany(mappedBy = "experiment")
+    private Collection<ErrorDetail> errorDetails;
+
+    @OneToMany(mappedBy = "experiment")
+    private Collection<Status> statuses;
+
     public String getExpId() {
         return expId;
     }
@@ -208,4 +215,20 @@ public class Experiment implements Serializable {
     public void setGatewayExecutionId(String gatewayExecutionId) {
         this.gatewayExecutionId = gatewayExecutionId;
     }
+
+    public Collection<Status> getStatuses() {
+        return statuses;
+    }
+
+    public void setStatuses(Collection<Status> statuses) {
+        this.statuses = statuses;
+    }
+
+    public Collection<ErrorDetail> getErrorDetails() {
+        return errorDetails;
+    }
+
+    public void setErrorDetails(Collection<ErrorDetail> errorDetails) {
+        this.errorDetails = errorDetails;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b1ee03c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ExperimentSummary.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ExperimentSummary.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ExperimentSummary.java
deleted file mode 100644
index 52338c3..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ExperimentSummary.java
+++ /dev/null
@@ -1,198 +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.persistance.registry.jpa.model;
-
-import org.apache.openjpa.persistence.DataCache;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.util.Collection;
-
-@Entity
-@Table(name = "EXPERIMENT")
-@DataCache
-public class ExperimentSummary implements Serializable {
-    @Id
-    @Column(name = "EXPERIMENT_ID")
-    private String expId;
-    @Column(name = "GATEWAY_ID")
-    private String gatewayId;
-    @Column(name = "EXECUTION_USER")
-    private String executionUser;
-    @Column(name = "PROJECT_ID")
-    private String projectID;
-    @Column(name = "CREATION_TIME")
-    private Timestamp creationTime;
-    @Column(name = "EXPERIMENT_NAME")
-    private String expName;
-    @Column(name = "EXPERIMENT_DESCRIPTION")
-    private String expDesc;
-    @Column(name = "APPLICATION_ID")
-    private String applicationId;
-    @Column(name = "APPLICATION_VERSION")
-    private String appVersion;
-    @Column(name = "WORKFLOW_TEMPLATE_ID")
-    private String workflowTemplateId;
-    @Column(name = "WORKFLOW_TEMPLATE_VERSION")
-    private String workflowTemplateVersion;
-    @Column(name = "WORKFLOW_EXECUTION_ID")
-    private String workflowExecutionId;
-    @Column(name = "ALLOW_NOTIFICATION")
-    private boolean allowNotification;
-    @Column(name = "GATEWAY_EXECUTION_ID")
-    private String gatewayExecutionId;
-
-    @OneToMany(fetch = FetchType.EAGER, mappedBy = "experiment")
-    private Collection<ErrorDetail> errorDetails;
-
-    @OneToMany(fetch = FetchType.EAGER, mappedBy = "experiment")
-    private Collection<Status> statuses;
-
-    public String getExpId() {
-        return expId;
-    }
-
-    public void setExpId(String expId) {
-        this.expId = expId;
-    }
-
-    public String getGatewayId() {
-        return gatewayId;
-    }
-
-    public void setGatewayId(String gatewayId) {
-        this.gatewayId = gatewayId;
-    }
-
-    public String getExecutionUser() {
-        return executionUser;
-    }
-
-    public void setExecutionUser(String executionUser) {
-        this.executionUser = executionUser;
-    }
-
-    public String getProjectId() {
-        return projectID;
-    }
-
-    public void setProjectId(String projectId) {
-        this.projectID = projectId;
-    }
-
-    public Timestamp getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(Timestamp creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    public String getExpName() {
-        return expName;
-    }
-
-    public void setExpName(String expName) {
-        this.expName = expName;
-    }
-
-    public String getExpDesc() {
-        return expDesc;
-    }
-
-    public void setExpDesc(String expDesc) {
-        this.expDesc = expDesc;
-    }
-
-    public String getApplicationId() {
-        return applicationId;
-    }
-
-    public void setApplicationId(String applicationId) {
-        this.applicationId = applicationId;
-    }
-
-    public String getAppVersion() {
-        return appVersion;
-    }
-
-    public void setAppVersion(String appVersion) {
-        this.appVersion = appVersion;
-    }
-
-    public String getWorkflowTemplateId() {
-        return workflowTemplateId;
-    }
-
-    public void setWorkflowTemplateId(String workflowTemplateId) {
-        this.workflowTemplateId = workflowTemplateId;
-    }
-
-    public String getWorkflowTemplateVersion() {
-        return workflowTemplateVersion;
-    }
-
-    public void setWorkflowTemplateVersion(String workflowTemplateVersion) {
-        this.workflowTemplateVersion = workflowTemplateVersion;
-    }
-
-    public String getWorkflowExecutionId() {
-        return workflowExecutionId;
-    }
-
-    public void setWorkflowExecutionId(String workflowExecutionId) {
-        this.workflowExecutionId = workflowExecutionId;
-    }
-
-    public boolean isAllowNotification() {
-        return allowNotification;
-    }
-
-    public void setAllowNotification(boolean allowNotification) {
-        this.allowNotification = allowNotification;
-    }
-
-    public String getGatewayExecutionId() {
-        return gatewayExecutionId;
-    }
-
-    public void setGatewayExecutionId(String gatewayExecutionId) {
-        this.gatewayExecutionId = gatewayExecutionId;
-    }
-
-    public Collection<ErrorDetail> getErrorDetailsByExperimentId() {
-        return errorDetails;
-    }
-
-    public void setErrorDetailsByExperimentId(Collection<ErrorDetail> errorDetailsByExperimentId) {
-        this.errorDetails = errorDetailsByExperimentId;
-    }
-
-    public Collection<Status> getStatusesByExperimentId() {
-        return statuses;
-    }
-
-    public void setStatusesByExperimentId(Collection<Status> statusesByExperimentId) {
-        this.statuses = statusesByExperimentId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b1ee03c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
index ce4d1d0..5c68bd4 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
@@ -26,12 +26,14 @@ import org.apache.airavata.persistance.registry.jpa.JPAConstants;
 import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.model.*;
+import org.apache.airavata.registry.cpi.utils.StatusType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
 
@@ -218,8 +220,8 @@ public class Utils {
                     throw new IllegalArgumentException("Object should be a Experiment.");
                 }
             case EXPERIMENT_SUMMARY:
-                if (o instanceof  ExperimentSummary){
-                    return createExperimentSummary((ExperimentSummary)o);
+                if (o instanceof  Experiment){
+                    return createExperimentSummary((Experiment)o);
                 }else {
                     logger.error("Object should be a ExperimentSummary.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Object should be a ExperimentSummary.");
@@ -487,7 +489,7 @@ public class Utils {
      * @param o ExperimentSummary model object
      * @return  ExperimentSummary Resource object
      */
-    private static Resource createExperimentSummary(ExperimentSummary o) {
+    private static Resource createExperimentSummary(Experiment o) {
         ExperimentSummaryResource experimentSummaryResource = new ExperimentSummaryResource();
         if (o != null){
             experimentSummaryResource.setExecutionUser(o.getExecutionUser());
@@ -498,33 +500,42 @@ public class Utils {
             experimentSummaryResource.setDescription(o.getExpDesc());
             experimentSummaryResource.setApplicationId(o.getApplicationId());
 
-            List<ErrorDetailResource> errorDetailResourceList = new ArrayList();
-            for(ErrorDetail err: o.getErrorDetailsByExperimentId()){
-                ErrorDetailResource errorDetailResource = new ErrorDetailResource();
-                errorDetailResource.setErrorId(err.getErrorID());
-                errorDetailResource.setJobId(err.getJobId());
-                errorDetailResource.setCreationTime(o.getCreationTime());
-                if (err.getActualErrorMsg() != null){
-                    errorDetailResource.setActualErrorMsg(new String(err.getActualErrorMsg()));
+            if(o.getErrorDetails()!=null) {
+                List<ErrorDetailResource> errorDetailResourceList = new ArrayList();
+                for (ErrorDetail err : o.getErrorDetails()) {
+                    ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+                    errorDetailResource.setErrorId(err.getErrorID());
+                    errorDetailResource.setJobId(err.getJobId());
+                    errorDetailResource.setCreationTime(o.getCreationTime());
+                    if (err.getActualErrorMsg() != null) {
+                        errorDetailResource.setActualErrorMsg(new String(err.getActualErrorMsg()));
+                    }
+                    errorDetailResource.setUserFriendlyErrorMsg(err.getUserFriendlyErrorMsg());
+                    errorDetailResource.setTransientPersistent(err.isTransientPersistent());
+                    errorDetailResource.setErrorCategory(err.getErrorCategory());
+                    errorDetailResource.setCorrectiveAction(err.getCorrectiveAction());
+                    errorDetailResource.setActionableGroup(err.getActionableGroup());
+                    errorDetailResourceList.add(errorDetailResource);
                 }
-                errorDetailResource.setUserFriendlyErrorMsg(err.getUserFriendlyErrorMsg());
-                errorDetailResource.setTransientPersistent(err.isTransientPersistent());
-                errorDetailResource.setErrorCategory(err.getErrorCategory());
-                errorDetailResource.setCorrectiveAction(err.getCorrectiveAction());
-                errorDetailResource.setActionableGroup(err.getActionableGroup());
-                errorDetailResourceList.add(errorDetailResource);
+                experimentSummaryResource.setErrorDetails(errorDetailResourceList);
             }
-            experimentSummaryResource.setErrorDetails(errorDetailResourceList);
 
-            Collection<Status> statusList = o.getStatusesByExperimentId();
+            Collection<Status> statusList = o.getStatuses();
             if(statusList != null && statusList.size()>0){
-                StatusResource statusResource = new StatusResource();
-                statusResource.setStatusId(statusList.iterator().next().getStatusId());
-                statusResource.setJobId(statusList.iterator().next().getJobId());
-                statusResource.setState(statusList.iterator().next().getState());
-                statusResource.setStatusUpdateTime(statusList.iterator().next().getStatusUpdateTime());
-                statusResource.setStatusType(statusList.iterator().next().getStatusType());
-                experimentSummaryResource.setStatus(statusResource);
+                Iterator<Status> statusIterator = statusList.iterator();
+                while(statusIterator.hasNext()){
+                    Status status = statusIterator.next();
+                    if(status.getStatusType().equals(StatusType.EXPERIMENT.toString())){
+                        StatusResource statusResource = new StatusResource();
+                        statusResource.setStatusId(status.getStatusId());
+                        statusResource.setJobId(status.getJobId());
+                        statusResource.setState(status.getState());
+                        statusResource.setStatusUpdateTime(status.getStatusUpdateTime());
+                        statusResource.setStatusType(status.getStatusType());
+                        experimentSummaryResource.setStatus(statusResource);
+                        break;
+                    }
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b1ee03c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
index 96e83c9..ed7166f 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
@@ -621,7 +621,7 @@ public class WorkerResource extends AbstractResource {
         List<ExperimentSummaryResource> result = new ArrayList();
         EntityManager em = null;
         try {
-            String query = "SELECT e FROM ExperimentSummary e " +
+            String query = "SELECT e FROM Experiment e " +
                     "LEFT JOIN e.statuses s LEFT JOIN FETCH e.errorDetails LEFT JOIN FETCH e.statuses WHERE ";
             if(filters.get(StatusConstants.STATE) != null) {
                 String experimentState = ExperimentState.valueOf(filters.get(StatusConstants.STATE)).toString();
@@ -673,9 +673,9 @@ public class WorkerResource extends AbstractResource {
 
             List resultList = q.getResultList();
             for (Object o : resultList) {
-                ExperimentSummary experimentSummary = (ExperimentSummary) o;
+                Experiment experiment = (Experiment) o;
                 ExperimentSummaryResource experimentSummaryResource =
-                        (ExperimentSummaryResource) Utils.getResource(ResourceType.EXPERIMENT_SUMMARY, experimentSummary);
+                        (ExperimentSummaryResource) Utils.getResource(ResourceType.EXPERIMENT_SUMMARY, experiment);
                 result.add(experimentSummaryResource);
             }
             em.getTransaction().commit();

http://git-wip-us.apache.org/repos/asf/airavata/blob/5b1ee03c/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml b/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml
index a8b6f70..9055d3d 100644
--- a/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml
+++ b/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml
@@ -30,7 +30,6 @@
         <class>org.apache.airavata.persistance.registry.jpa.model.Project</class>
         <class>org.apache.airavata.persistance.registry.jpa.model.ProjectUser</class>
         <class>org.apache.airavata.persistance.registry.jpa.model.Experiment</class>
-        <class>org.apache.airavata.persistance.registry.jpa.model.ExperimentSummary</class>
         <class>org.apache.airavata.persistance.registry.jpa.model.Notification_Email</class>
         <class>org.apache.airavata.persistance.registry.jpa.model.Experiment_Input</class>
         <class>org.apache.airavata.persistance.registry.jpa.model.Experiment_Output</class>