airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject [2/2] git commit: merged resource changes and add resource methods for input/output objects. AIRAVATA-1017
Date Tue, 18 Feb 2014 19:21:12 GMT
merged resource changes and add resource methods for input/output objects. AIRAVATA-1017


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

Branch: refs/heads/master
Commit: e8ac03899a6140a1128f81973864b07cd0a4dd72
Parents: 4066c47 0e2e21c
Author: raminder <raminder@apache.org>
Authored: Tue Feb 18 14:20:50 2014 -0500
Committer: raminder <raminder@apache.org>
Committed: Tue Feb 18 14:20:50 2014 -0500

----------------------------------------------------------------------
 .../registry/jpa/model/ErrorDetail.java         | 178 ++++++++++
 .../registry/jpa/model/ErrorDetails.java        | 178 ----------
 .../registry/jpa/model/Experiment.java          |  12 +
 .../registry/jpa/model/TaskDetail.java          |  14 +-
 .../jpa/resources/ApplicationInputResource.java |  23 +-
 .../resources/ApplicationOutputResource.java    |  23 +-
 .../jpa/resources/ErrorDetailResource.java      |  54 +--
 .../jpa/resources/ExperimentResource.java       | 148 +++++++--
 .../jpa/resources/JobDetailResource.java        |  10 +-
 .../jpa/resources/NodeInputResource.java        |  36 +-
 .../jpa/resources/NodeOutputResource.java       |  62 +++-
 .../registry/jpa/resources/StatusResource.java  |  14 +-
 .../registry/jpa/resources/Utils.java           | 328 ++++++++++++-------
 .../src/main/resources/registry-mysql.sql       |  13 +-
 14 files changed, 674 insertions(+), 419 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/e8ac0389/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
----------------------------------------------------------------------
diff --cc modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
index ca3245a,d54f46a..51dd057
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
@@@ -21,23 -21,13 +21,22 @@@
  
  package org.apache.airavata.persistance.registry.jpa.resources;
  
 +import java.util.List;
 +
 +import javax.persistence.EntityManager;
 +
  import org.apache.airavata.persistance.registry.jpa.Resource;
  import org.apache.airavata.persistance.registry.jpa.ResourceType;
 -
 -import java.util.List;
 +import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 +import org.apache.airavata.persistance.registry.jpa.model.ApplicationInput;
 +import org.apache.airavata.persistance.registry.jpa.model.ApplicationInput_PK;
 +import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
  
  public class ApplicationInputResource extends AbstractResource {
 +	private static final Logger logger = LoggerFactory.getLogger(ApplicationInputResource.class);
- 
- 	private String taskId;
+     private TaskDetailResource taskDetailResource;
      private String inputKey;
      private String inputType;
      private String metadata;
@@@ -83,10 -65,17 +74,18 @@@
          this.value = value;
      }
  
+     public TaskDetailResource getTaskDetailResource() {
+         return taskDetailResource;
+     }
+ 
+     public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+         this.taskDetailResource = taskDetailResource;
+     }
+ 
      @Override
      public Resource create(ResourceType type) {
 -        return null;
 +        logger.error("Unsupported resource type for application input data resource.", new
UnsupportedOperationException());
 +        throw new UnsupportedOperationException();
      }
  
      @Override
@@@ -109,33 -95,6 +108,33 @@@
  
      @Override
      public void save() {
 -
 +        EntityManager em = ResourceUtils.getEntityManager();
-         ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey,
taskId));
++        ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey,
taskDetailResource.getTaskId()));
 +        em.close();
 +
 +        em = ResourceUtils.getEntityManager();
 +        em.getTransaction().begin();
 +        ApplicationInput applicationInput = new ApplicationInput();
-         TaskDetail taskDetail = em.find(TaskDetail.class, taskId);
++        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
 +        applicationInput.setTask(taskDetail);
 +        applicationInput.setTaskId(taskDetail.getTaskId());
 +        applicationInput.setInputKey(inputKey);
 +        applicationInput.setInputKeyType(inputType);
 +        applicationInput.setValue(value);
 +        applicationInput.setMetadata(metadata);
 +        
 +        if (existingInput != null){
 +            existingInput.setTask(taskDetail);
 +            existingInput.setTaskId(taskDetail.getTaskId());
 +            existingInput.setInputKey(inputKey);
 +            existingInput.setInputKeyType(inputType);
 +            existingInput.setValue(value);
 +            existingInput.setMetadata(metadata);
 +            applicationInput = em.merge(existingInput);
 +        }else {
 +            em.persist(applicationInput);
 +        }
 +        em.getTransaction().commit();
 +        em.close();
      }
  }

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8ac0389/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
----------------------------------------------------------------------
diff --cc modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
index 7fe7b3d,5edd3bf..6a0f43e
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
@@@ -21,23 -21,13 +21,22 @@@
  
  package org.apache.airavata.persistance.registry.jpa.resources;
  
 +import java.util.List;
 +
 +import javax.persistence.EntityManager;
 +
  import org.apache.airavata.persistance.registry.jpa.Resource;
  import org.apache.airavata.persistance.registry.jpa.ResourceType;
 -
 -import java.util.List;
 +import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 +import org.apache.airavata.persistance.registry.jpa.model.ApplicationOutput;
 +import org.apache.airavata.persistance.registry.jpa.model.ApplicationOutput_PK;
 +import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
  
  public class ApplicationOutputResource extends AbstractResource {
 +	private static final Logger logger = LoggerFactory.getLogger(ApplicationOutputResource.class);
- 
- 	private String taskId;
+     private TaskDetailResource taskDetailResource;
      private String outputKey;
      private String outputType;
      private String metadata;
@@@ -83,10 -65,17 +74,18 @@@
          this.value = value;
      }
  
+     public TaskDetailResource getTaskDetailResource() {
+         return taskDetailResource;
+     }
+ 
+     public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+         this.taskDetailResource = taskDetailResource;
+     }
+ 
      @Override
      public Resource create(ResourceType type) {
 -        return null;
 +        logger.error("Unsupported resource type for application output data resource.",
new UnsupportedOperationException());
 +        throw new UnsupportedOperationException();
      }
  
      @Override
@@@ -109,35 -95,6 +108,35 @@@
  
      @Override
      public void save() {
 +        EntityManager em = ResourceUtils.getEntityManager();
-         ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey,
taskId));
++        ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey,
taskDetailResource.getTaskId()));
 +        em.close();
 +
 +        em = ResourceUtils.getEntityManager();
 +        em.getTransaction().begin();
 +        ApplicationOutput applicationOutput = new ApplicationOutput();
-         TaskDetail taskDetail = em.find(TaskDetail.class, taskId);
++        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
 +        applicationOutput.setTask(taskDetail);
 +        applicationOutput.setTaskId(taskDetail.getTaskId());
 +        applicationOutput.setOutputKey(outputKey);
 +        applicationOutput.setOutputKeyType(outputType);
 +        applicationOutput.setValue(value);
 +        applicationOutput.setMetadata(metadata);
 +        
 +        if (existingOutput != null){
 +        	existingOutput.setTask(taskDetail);
 +        	existingOutput.setTaskId(taskDetail.getTaskId());
 +        	existingOutput.setOutputKey(outputKey);
 +        	existingOutput.setOutputKeyType(outputType);
 +        	existingOutput.setValue(value);
 +        	existingOutput.setMetadata(metadata);
 +        	applicationOutput = em.merge(existingOutput);
 +        }else {
 +            em.persist(applicationOutput);
 +        }
 +        em.getTransaction().commit();
 +        em.close();
 +
  
      }
  }

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8ac0389/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
----------------------------------------------------------------------
diff --cc modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
index e483d8f,2ada52f..2b12c95
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
@@@ -21,22 -21,13 +21,23 @@@
  
  package org.apache.airavata.persistance.registry.jpa.resources;
  
 +import java.util.List;
 +
 +import javax.persistence.EntityManager;
 +
  import org.apache.airavata.persistance.registry.jpa.Resource;
  import org.apache.airavata.persistance.registry.jpa.ResourceType;
 -
 -import java.util.List;
 +import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 +import org.apache.airavata.persistance.registry.jpa.model.NodeInput;
 +import org.apache.airavata.persistance.registry.jpa.model.NodeInput_PK;
++import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
  
  public class NodeInputResource extends AbstractResource {
 +	private static final Logger logger = LoggerFactory.getLogger(NodeInputResource.class);
 +
-     private String nodeInstanceId;
+     private WorkflowNodeDetailResource nodeDetailResource;
      private String inputKey;
      private String inputType;
      private String metadata;
@@@ -108,12 -95,6 +109,33 @@@
  
      @Override
      public void save() {
 -
 +        EntityManager em = ResourceUtils.getEntityManager();
-         NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeInstanceId));
++        NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeDetailResource.getNodeInstanceId()));
 +        em.close();
 +
 +        em = ResourceUtils.getEntityManager();
 +        em.getTransaction().begin();
-        
++        NodeInput nodeInput = new NodeInput();
++        WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
++        nodeInput.setNodeDetails(nodeDetail);
++        nodeInput.setNodeId(nodeDetail.getNodeId());
++        nodeInput.setInputKey(inputKey);
++        nodeInput.setInputKeyType(inputType);
++        nodeInput.setValue(value);
++        nodeInput.setMetadata(metadata);
++        
++        if (existingInput != null){
++            existingInput.setNodeDetails(nodeDetail);
++            existingInput.setNodeId(nodeDetail.getNodeId());
++            existingInput.setInputKey(inputKey);
++            existingInput.setInputKeyType(inputType);
++            existingInput.setValue(value);
++            existingInput.setMetadata(metadata);
++            nodeInput = em.merge(existingInput);
++        }else {
++            em.persist(nodeInput);
++        }
++        em.getTransaction().commit();
++        em.close();
      }
  }

http://git-wip-us.apache.org/repos/asf/airavata/blob/e8ac0389/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
----------------------------------------------------------------------
diff --cc modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
index 9d27c22,b105157..c4ab7c0
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
@@@ -23,11 -23,11 +23,23 @@@ package org.apache.airavata.persistance
  
  import org.apache.airavata.persistance.registry.jpa.Resource;
  import org.apache.airavata.persistance.registry.jpa.ResourceType;
++import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
++import org.apache.airavata.persistance.registry.jpa.model.NodeInput;
++import org.apache.airavata.persistance.registry.jpa.model.NodeInput_PK;
++import org.apache.airavata.persistance.registry.jpa.model.NodeOutput;
++import org.apache.airavata.persistance.registry.jpa.model.NodeOutput_PK;
++import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
  
  import java.util.List;
  
++import javax.persistence.EntityManager;
++
  public class NodeOutputResource extends AbstractResource {
-     private String nodeInstanceId;
++	private static final Logger logger = LoggerFactory.getLogger(NodeOutputResource.class);
++	
+     private WorkflowNodeDetailResource nodeDetailResource;
      private String outputKey;
      private String outputType;
      private String metadata;
@@@ -75,26 -75,26 +87,58 @@@
  
      @Override
      public Resource create(ResourceType type) {
--        return null;
++        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
++        throw new UnsupportedOperationException();
      }
  
      @Override
      public void remove(ResourceType type, Object name) {
--
++        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
++        throw new UnsupportedOperationException();
      }
  
      @Override
      public Resource get(ResourceType type, Object name) {
--        return null;
++        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
++        throw new UnsupportedOperationException();
      }
  
      @Override
      public List<Resource> get(ResourceType type) {
--        return null;
++        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
++        throw new UnsupportedOperationException();
      }
  
      @Override
      public void save() {
  
++        EntityManager em = ResourceUtils.getEntityManager();
++        NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey,
nodeDetailResource.getNodeInstanceId()));
++        em.close();
++
++        em = ResourceUtils.getEntityManager();
++        em.getTransaction().begin();
++        NodeOutput nodeOutput = new NodeOutput();
++        WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
++        nodeOutput.setNode(nodeDetail);
++        nodeOutput.setNodeId(nodeDetail.getNodeId());
++        nodeOutput.setOutputKey(outputKey);
++        nodeOutput.setOutputKeyType(outputType);
++        nodeOutput.setValue(value);
++        nodeOutput.setMetadata(metadata);
++        
++        if (existingOutput != null){
++            existingOutput.setNode(nodeDetail);
++            existingOutput.setNodeId(nodeDetail.getNodeId());
++            existingOutput.setOutputKey(outputKey);
++            existingOutput.setOutputKeyType(outputType);
++            existingOutput.setValue(value);
++            existingOutput.setMetadata(metadata);
++            nodeOutput = em.merge(existingOutput);
++        }else {
++            em.persist(nodeOutput);
++        }
++        em.getTransaction().commit();
++        em.close();
      }
  }


Mime
View raw message