airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: fixing some issues with registry jpa models - AIRAVATA-1025
Date Tue, 25 Feb 2014 22:08:10 GMT
Repository: airavata
Updated Branches:
  refs/heads/master ec6357671 -> e20214088


fixing some issues with registry jpa models - AIRAVATA-1025


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

Branch: refs/heads/master
Commit: e202140889b842f5cf3291dc7285f90f79ae1110
Parents: ec63576
Author: chathuri <chathuri@apache.org>
Authored: Tue Feb 25 17:08:05 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Tue Feb 25 17:08:05 2014 -0500

----------------------------------------------------------------------
 .../jpa/resources/ErrorDetailResource.java      | 36 +++++----------
 .../registry/jpa/resources/StatusResource.java  | 48 +++++++-------------
 .../registry/jpa/resources/Utils.java           | 30 ++++++++----
 3 files changed, 48 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/e2021408/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
index 06e37f4..9e97c17 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
@@ -173,19 +173,20 @@ public class ErrorDetailResource extends AbstractResource {
     @Override
     public void save() {
         EntityManager em = ResourceUtils.getEntityManager();
-        ErrorDetail existingErrorDetail = em.find(ErrorDetail.class, errorId);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
         em.getTransaction().begin();
         ErrorDetail errorDetail = new ErrorDetail();
         errorDetail.setErrorID(errorId);
         Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
         errorDetail.setExperiment(experiment);
-        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-        errorDetail.setTask(taskDetail);
-        WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, nodeDetail.getNodeInstanceId());
-        errorDetail.setNodeDetails(workflowNodeDetail);
+        if (taskDetailResource != null){
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            errorDetail.setTask(taskDetail);
+        }
+
+        if (nodeDetail != null){
+            WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, nodeDetail.getNodeInstanceId());
+            errorDetail.setNodeDetails(workflowNodeDetail);
+        }
         errorDetail.setCreationTime(creationTime);
         errorDetail.setActualErrorMsg(actualErrorMsg.toCharArray());
         errorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
@@ -194,23 +195,8 @@ public class ErrorDetailResource extends AbstractResource {
         errorDetail.setCorrectiveAction(correctiveAction);
         errorDetail.setActionableGroup(actionableGroup);
         errorDetail.setJobId(jobId);
-        if (existingErrorDetail != null){
-            existingErrorDetail.setErrorID(errorId);
-            existingErrorDetail.setExperiment(experiment);
-            existingErrorDetail.setTask(taskDetail);
-            existingErrorDetail.setNodeDetails(workflowNodeDetail);
-            existingErrorDetail.setCreationTime(creationTime);
-            existingErrorDetail.setActualErrorMsg(actualErrorMsg.toCharArray());
-            existingErrorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
-            existingErrorDetail.setTransientPersistent(transientPersistent);
-            existingErrorDetail.setErrorCategory(errorCategory);
-            existingErrorDetail.setCorrectiveAction(correctiveAction);
-            existingErrorDetail.setActionableGroup(actionableGroup);
-            existingErrorDetail.setJobId(jobId);
-            errorDetail = em.merge(existingErrorDetail);
-        }else {
-            em.merge(errorDetail);
-        }
+        em.persist(errorDetail);
+        errorId = errorDetail.getErrorID();
         em.getTransaction().commit();
         em.close();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/e2021408/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
index 327e5e0..db2e8d3 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
@@ -143,47 +143,33 @@ public class StatusResource extends AbstractResource {
     @Override
     public void save() {
         EntityManager em = ResourceUtils.getEntityManager();
-        Status existingStatus = em.find(Status.class, statusId);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
         em.getTransaction().begin();
         Status status = new Status();
         Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-        WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetail.getNodeInstanceId());
-        DataTransferDetail transferDetail = em.find(DataTransferDetail.class, dataTransferDetail.getTransferId());
+        if (taskDetailResource != null){
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            status.setTask(taskDetail);
+            status.setTaskId(taskDetailResource.getTaskId());
+        }
+        if (workflowNodeDetail != null){
+            WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetail.getNodeInstanceId());
+            status.setNode(nodeDetail);
+            status.setNodeId(workflowNodeDetail.getNodeInstanceId());
+        }
+        if (dataTransferDetail != null){
+            DataTransferDetail transferDetail = em.find(DataTransferDetail.class, dataTransferDetail.getTransferId());
+            status.setTransferDetail(transferDetail);
+            status.setTransferId(dataTransferDetail.getTransferId());
+        }
         status.setStatusId(statusId);
         status.setExperiment(experiment);
-        status.setTask(taskDetail);
-        status.setNode(nodeDetail);
-        status.setTransferDetail(transferDetail);
         status.setJobId(jobId);
         status.setExpId(experimentResource.getExpID());
-        status.setTaskId(taskDetailResource.getTaskId());
-        status.setNodeId(workflowNodeDetail.getNodeInstanceId());
-        status.setTransferId(dataTransferDetail.getTransferId());
         status.setState(state);
         status.setStatusUpdateTime(statusUpdateTime);
         status.setStatusType(statusType);
-        if (existingStatus != null){
-            existingStatus.setStatusId(statusId);
-            existingStatus.setExperiment(experiment);
-            existingStatus.setTask(taskDetail);
-            existingStatus.setNode(nodeDetail);
-            existingStatus.setTransferDetail(transferDetail);
-            existingStatus.setJobId(jobId);
-            existingStatus.setExpId(experimentResource.getExpID());
-            existingStatus.setTaskId(taskDetailResource.getTaskId());
-            existingStatus.setNodeId(workflowNodeDetail.getNodeInstanceId());
-            existingStatus.setTransferId(dataTransferDetail.getTransferId());
-            existingStatus.setState(state);
-            existingStatus.setStatusUpdateTime(statusUpdateTime);
-            existingStatus.setStatusType(statusType);
-            status = em.merge(existingStatus);
-        }else {
-            em.merge(status);
-        }
+        em.persist(status);
+        statusId = status.getStatusId();
         em.getTransaction().commit();
         em.close();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/e2021408/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 7e0cfeb..2d5c346 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
@@ -631,10 +631,14 @@ public class Utils {
         ErrorDetailResource errorDetailResource = new ErrorDetailResource();
         ExperimentResource experimentResource = (ExperimentResource)createExperiment(o.getExperiment());
         errorDetailResource.setExperimentResource(experimentResource);
-        TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
-        errorDetailResource.setTaskDetailResource(taskDetailResource);
-        WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNodeDetails());
-        errorDetailResource.setNodeDetail(nodeDetailResource);
+        if (o.getTask() != null){
+            TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
+            errorDetailResource.setTaskDetailResource(taskDetailResource);
+        }
+        if (o.getNodeDetails() != null){
+            WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNodeDetails());
+            errorDetailResource.setNodeDetail(nodeDetailResource);
+        }
         errorDetailResource.setErrorId(o.getErrorID());
         errorDetailResource.setJobId(o.getJobId());
         errorDetailResource.setCreationTime(o.getCreationTime());
@@ -716,12 +720,18 @@ public class Utils {
         StatusResource statusResource = new StatusResource();
         ExperimentResource experimentResource = (ExperimentResource)createExperiment(o.getExperiment());
         statusResource.setExperimentResource(experimentResource);
-        TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
-        statusResource.setTaskDetailResource(taskDetailResource);
-        WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNode());
-        statusResource.setWorkflowNodeDetail(nodeDetailResource);
-        DataTransferDetailResource transferDetailResource = (DataTransferDetailResource)createDataTransferResource(o.getTransferDetail());
-        statusResource.setDataTransferDetail(transferDetailResource);
+        if (o.getTask() != null){
+            TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
+            statusResource.setTaskDetailResource(taskDetailResource);
+        }
+        if (o.getNode() != null){
+            WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNode());
+            statusResource.setWorkflowNodeDetail(nodeDetailResource);
+        }
+        if (o.getTransferDetail() != null){
+            DataTransferDetailResource transferDetailResource = (DataTransferDetailResource)createDataTransferResource(o.getTransferDetail());
+            statusResource.setDataTransferDetail(transferDetailResource);
+        }
         statusResource.setStatusId(o.getStatusId());
         statusResource.setJobId(o.getJobId());
         statusResource.setState(o.getState());


Mime
View raw message