airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: adding data model resources - AIRAVATA-1017
Date Wed, 19 Feb 2014 03:13:21 GMT
Repository: airavata
Updated Branches:
  refs/heads/master b66eba943 -> 867cfee4c


adding data model resources - AIRAVATA-1017


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

Branch: refs/heads/master
Commit: 867cfee4c0fc7a09c5e58989eeaff4bd39ecc916
Parents: b66eba9
Author: chathuri <chathuri@apache.org>
Authored: Tue Feb 18 22:13:11 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Tue Feb 18 22:13:11 2014 -0500

----------------------------------------------------------------------
 .../jpa/resources/ErrorDetailResource.java      |  63 +++-
 .../jpa/resources/ExperimentResource.java       | 260 +++++++++++---
 .../jpa/resources/TaskDetailResource.java       | 356 ++++++++++++++++++-
 .../registry/jpa/resources/Utils.java           | 273 +++++++-------
 .../resources/WorkflowNodeDetailResource.java   | 244 ++++++++++++-
 5 files changed, 1008 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/867cfee4/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 a43175d..63d9d0f 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
@@ -23,11 +23,20 @@ package org.apache.airavata.persistance.registry.jpa.resources;
 
 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.ErrorDetail;
+import org.apache.airavata.persistance.registry.jpa.model.Experiment;
+import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
 import java.sql.Timestamp;
 import java.util.List;
 
 public class ErrorDetailResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(ErrorDetailResource.class);
     private int errorId;
     private ExperimentResource experimentResource;
     private TaskDetailResource taskDetailResource;
@@ -130,26 +139,68 @@ public class ErrorDetailResource extends AbstractResource {
 
     @Override
     public Resource create(ResourceType type) {
-        return null;
+        logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
     }
 
     @Override
     public void remove(ResourceType type, Object name) {
-
+        logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
     }
 
     @Override
     public Resource get(ResourceType type, Object name) {
-        return null;
+        logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
     }
 
     @Override
     public List<Resource> get(ResourceType type) {
-        return null;
+        logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
     }
 
     @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);
+        errorDetail.setCreationTime(creationTime);
+        errorDetail.setActualErrorMsg(actualErrorMsg);
+        errorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
+        errorDetail.setTransientPersistent(transientPersistent);
+        errorDetail.setErrorCategory(errorCategory);
+        errorDetail.setCorrectiveAction(correctiveAction);
+        errorDetail.setActionableGroup(actionableGroup);
+        if (existingErrorDetail != null){
+            existingErrorDetail.setErrorID(errorId);
+            existingErrorDetail.setExperiment(experiment);
+            existingErrorDetail.setTask(taskDetail);
+            existingErrorDetail.setNodeDetails(workflowNodeDetail);
+            existingErrorDetail.setCreationTime(creationTime);
+            existingErrorDetail.setActualErrorMsg(actualErrorMsg);
+            existingErrorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
+            existingErrorDetail.setTransientPersistent(transientPersistent);
+            existingErrorDetail.setErrorCategory(errorCategory);
+            existingErrorDetail.setCorrectiveAction(correctiveAction);
+            existingErrorDetail.setActionableGroup(actionableGroup);
+            errorDetail = em.merge(existingErrorDetail);
+        }else {
+            em.merge(errorDetail);
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/867cfee4/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
index 468ed53..bdd5c50 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
@@ -278,6 +278,87 @@ public class ExperimentResource extends AbstractResource {
                 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 WORKFLOW_NODE_DETAIL:
+                generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+                generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_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);
+                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 CONFIG_DATA:
+                generator = new QueryGenerator(CONFIG_DATA);
+                generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
+                q = generator.selectQuery(em);
+                ExperimentConfigData configData = (ExperimentConfigData)q.getSingleResult();
+                ConfigDataResource configDataResource = (ConfigDataResource)Utils.getResource(ResourceType.CONFIG_DATA, configData);
+                em.getTransaction().commit();
+                em.close();
+                return configDataResource;
+            case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
+                q = generator.selectQuery(em);
+                Computational_Resource_Scheduling scheduling = (Computational_Resource_Scheduling)q.getSingleResult();
+                ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource)Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, scheduling);
+                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);
+                q = generator.selectQuery(em);
+                AdvancedInputDataHandling inputDataHandling = (AdvancedInputDataHandling)q.getSingleResult();
+                AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, inputDataHandling);
+                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);
+                q = generator.selectQuery(em);
+                AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling)q.getSingleResult();
+                AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+                em.getTransaction().commit();
+                em.close();
+                return outputDataHandlingResource;
+            case QOS_PARAM:
+                generator = new QueryGenerator(QOS_PARAMS);
+                generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
+                q = generator.selectQuery(em);
+                QosParam qosParam = (QosParam)q.getSingleResult();
+                QosParamResource qosParamResource = (QosParamResource)Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+                em.getTransaction().commit();
+                em.close();
+                return qosParamResource;
             default:
                 em.getTransaction().commit();
                 em.close();
@@ -288,69 +369,144 @@ public class ExperimentResource extends AbstractResource {
     }
 
     /**
-     * key should be the experiment ID
-     * @param keys experiment ID
-     * @return ExperimentResource
-     */
-    public List<Resource> populate(Object[] keys) {
-        List<Resource> list = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator queryGenerator = new QueryGenerator(EXPERIMENT);
-        queryGenerator.setParameter(ExperimentConstants.EXPERIMENT_ID, keys[0]);
-        Query q = queryGenerator.selectQuery(em);
-        Experiment experiment = (Experiment)q.getSingleResult();
-        ExperimentResource experimentResource =
-                (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
-        em.getTransaction().commit();
-        em.close();
-        list.add(experimentResource);
-        return list;
-
-    }
-
-    /**
      *
      * @param type  child resource types
      * @return UnsupportedOperationException
      */
     public List<Resource> get(ResourceType type) {
-        logger.error("Unsupported resource type for experiment resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        List results;
+        switch (type){
+            case EXPERIMENT_INPUT:
+                generator = new QueryGenerator(EXPERIMENT_INPUT);
+                generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, expID);
+                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);
+                    }
+                }
+                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 WORKFLOW_NODE_DETAIL:
+                generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+                generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_ID, expID);
+                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);
+                    }
+                }
+                break;
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, expID);
+                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;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.EXPERIMENT_ID, expID);
+                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;
+            default:
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported resource type for experiment resource.", new UnsupportedOperationException());
+                throw new UnsupportedOperationException();
+        }
+        em.getTransaction().commit();
+        em.close();
+        return resourceList;
     }
 
     /**
      * save experiment
      */
     public void save() {
-//        EntityManager em = ResourceUtils.getEntityManager();
-//        Experiment existingExp = em.find(Experiment.class, expID);
-//        em.close();
-//
-//        em = ResourceUtils.getEntityManager();
-//        em.getTransaction().begin();
-//        Experiment experiment = new Experiment();
-//        Project projectmodel = em.find(Project.class, project.getName());
-//        experiment.setProject(projectmodel);
-//        Users user = em.find(Users.class, getWorker().getUser());
-//        Gateway gateway = em.find(Gateway.class, getGateway().getGatewayName());
-//        experiment.setProject(projectmodel);
-//        experiment.setExperiment_ID(getExpID());
-//        experiment.setUser(user);
-//        experiment.setGateway(gateway);
-//        experiment.setSubmitted_date(submittedDate);
-//        if(existingExp != null){
-//            existingExp.setGateway(gateway);
-//            existingExp.setProject(projectmodel);
-//            existingExp.setUser(user);
-//            existingExp.setSubmitted_date(submittedDate);
-//            experiment = em.merge(existingExp);
-//        } else{
-//           em.merge(experiment);
-//        }
-//
-//        em.getTransaction().commit();
-//        em.close();
+        EntityManager em = ResourceUtils.getEntityManager();
+        Experiment existingExp = em.find(Experiment.class, expID);
+        em.close();
+
+        em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Experiment experiment = new Experiment();
+        Project projectmodel = em.find(Project.class, project.getName());
+        experiment.setProject(projectmodel);
+        Users user = em.find(Users.class, getWorker().getUser());
+        Gateway gateway = em.find(Gateway.class, getGateway().getGatewayName());
+        experiment.setProject(projectmodel);
+        experiment.setExpId(expID);
+        experiment.setUser(user);
+        experiment.setGateway(gateway);
+        experiment.setCreationTime(creationTime);
+        experiment.setExpName(expName);
+        experiment.setExpDesc(description);
+        experiment.setApplicationId(applicationId);
+        experiment.setAppVersion(applicationVersion);
+        experiment.setWorkflowExecutionId(workflowExecutionId);
+        experiment.setWorkflowTemplateVersion(workflowTemplateVersion);
+        experiment.setWorkflowExecutionId(workflowExecutionId);
+        if(existingExp != null){
+            existingExp.setGateway(gateway);
+            existingExp.setProject(projectmodel);
+            existingExp.setUser(user);
+            existingExp.setCreationTime(creationTime);
+            existingExp.setExpName(expName);
+            existingExp.setExpDesc(description);
+            existingExp.setApplicationId(applicationId);
+            existingExp.setAppVersion(applicationVersion);
+            existingExp.setWorkflowExecutionId(workflowExecutionId);
+            existingExp.setWorkflowTemplateVersion(workflowTemplateVersion);
+            existingExp.setWorkflowExecutionId(workflowExecutionId);
+            experiment = em.merge(existingExp);
+        } else{
+           em.merge(experiment);
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata/blob/867cfee4/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
index 8b8595d..e1f0a21 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
@@ -23,11 +23,20 @@ package org.apache.airavata.persistance.registry.jpa.resources;
 
 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.*;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+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 TaskDetailResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(TaskDetailResource.class);
     private String taskId;
     private WorkflowNodeDetailResource workflowNodeDetailResource;
     private Timestamp creationTime;
@@ -76,26 +85,365 @@ public class TaskDetailResource extends AbstractResource {
 
     @Override
     public Resource create(ResourceType type) {
-        return null;
+       switch (type){
+           case ERROR_DETAIL:
+               ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+               errorDetailResource.setTaskDetailResource(this);
+               return errorDetailResource;
+           case APPLICATION_INPUT:
+               ApplicationInputResource applicationInputResource = new ApplicationInputResource();
+               applicationInputResource.setTaskDetailResource(this);
+               return applicationInputResource;
+           case APPLICATION_OUTPUT:
+               ApplicationOutputResource applicationOutputResource = new ApplicationOutputResource();
+               applicationOutputResource.setTaskDetailResource(this);
+               return applicationOutputResource;
+           case JOB_DETAIL:
+               JobDetailResource jobDetailResource = new JobDetailResource();
+               jobDetailResource.setTaskDetailResource(this);
+               return jobDetailResource;
+           case DATA_TRANSFER_DETAIL:
+               DataTransferDetailResource dataTransferDetailResource = new DataTransferDetailResource();
+               dataTransferDetailResource.setTaskDetailResource(this);
+               return dataTransferDetailResource;
+           case STATUS:
+               StatusResource statusResource = new StatusResource();
+               statusResource.setTaskDetailResource(this);
+               return statusResource;
+           case COMPUTATIONAL_RESOURCE_SCHEDULING:
+               ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
+               schedulingResource.setTaskDetailResource(this);
+               return schedulingResource;
+           case ADVANCE_INPUT_DATA_HANDLING:
+               AdvanceInputDataHandlingResource inputDataHandlingResource = new AdvanceInputDataHandlingResource();
+               inputDataHandlingResource.setTaskDetailResource(this);
+               return inputDataHandlingResource;
+           case ADVANCE_OUTPUT_DATA_HANDLING:
+               AdvancedOutputDataHandlingResource outputDataHandlingResource = new AdvancedOutputDataHandlingResource();
+               outputDataHandlingResource.setTaskDetailResource(this);
+               return outputDataHandlingResource;
+           case QOS_PARAM:
+               QosParamResource qosParamResource = new QosParamResource();
+               qosParamResource.setTaskDetailResource(this);
+               return qosParamResource;
+           default:
+               logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
+               throw new IllegalArgumentException("Unsupported resource type for task detail resource.");
+       }
     }
 
     @Override
     public void remove(ResourceType type, Object name) {
-
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        switch (type){
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case APPLICATION_INPUT:
+                generator = new QueryGenerator(APPLICATION_INPUT);
+                generator.setParameter(ApplicationInputConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case APPLICATION_OUTPUT:
+                generator = new QueryGenerator(APPLICATION_OUTPUT);
+                generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case JOB_DETAIL:
+                generator = new QueryGenerator(JOB_DETAIL);
+                generator.setParameter(JobDetailConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case DATA_TRANSFER_DETAIL:
+                generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+                generator.setParameter(DataTransferDetailConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case ADVANCE_INPUT_DATA_HANDLING:
+                generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+                generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case ADVANCE_OUTPUT_DATA_HANDLING:
+                generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+                generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case QOS_PARAM:
+                generator = new QueryGenerator(QOS_PARAMS);
+                generator.setParameter(QosParamsConstants.TASK_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            default:
+                logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
+                break;
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 
     @Override
     public Resource get(ResourceType type, Object name) {
-        return null;
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator generator;
+        Query q;
+        switch (type) {
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.TASK_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 APPLICATION_INPUT:
+                generator = new QueryGenerator(APPLICATION_INPUT);
+                generator.setParameter(ApplicationInputConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                ApplicationInput applicationInput = (ApplicationInput)q.getSingleResult();
+                ApplicationInputResource inputResource = (ApplicationInputResource)Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
+                em.getTransaction().commit();
+                em.close();
+                return inputResource;
+            case APPLICATION_OUTPUT:
+                generator = new QueryGenerator(APPLICATION_OUTPUT);
+                generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                ApplicationOutput applicationOutput = (ApplicationOutput)q.getSingleResult();
+                ApplicationOutputResource outputResource = (ApplicationOutputResource)Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
+                em.getTransaction().commit();
+                em.close();
+                return outputResource;
+            case JOB_DETAIL:
+                generator = new QueryGenerator(JOB_DETAIL);
+                generator.setParameter(JobDetailConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                JobDetail jobDetail = (JobDetail)q.getSingleResult();
+                JobDetailResource jobDetailResource = (JobDetailResource)Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
+                em.getTransaction().commit();
+                em.close();
+                return jobDetailResource;
+            case DATA_TRANSFER_DETAIL:
+                generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+                generator.setParameter(DataTransferDetailConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                DataTransferDetail transferDetail = (DataTransferDetail)q.getSingleResult();
+                DataTransferDetailResource transferDetailResource = (DataTransferDetailResource)Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
+                em.getTransaction().commit();
+                em.close();
+                return transferDetailResource;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.TASK_ID, name);
+                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 COMPUTATIONAL_RESOURCE_SCHEDULING:
+                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling)q.getSingleResult();
+                ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource)Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
+                em.getTransaction().commit();
+                em.close();
+                return schedulingResource;
+            case ADVANCE_INPUT_DATA_HANDLING:
+                generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+                generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling)q.getSingleResult();
+                AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
+                em.getTransaction().commit();
+                em.close();
+                return inputDataHandlingResource;
+            case ADVANCE_OUTPUT_DATA_HANDLING:
+                generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+                generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling)q.getSingleResult();
+                AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+                em.getTransaction().commit();
+                em.close();
+                return outputDataHandlingResource;
+            case QOS_PARAM:
+                generator = new QueryGenerator(QOS_PARAMS);
+                generator.setParameter(QosParamsConstants.TASK_ID, name);
+                q = generator.selectQuery(em);
+                QosParam qosParam = (QosParam)q.getSingleResult();
+                QosParamResource qosParamResource = (QosParamResource)Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+                em.getTransaction().commit();
+                em.close();
+                return qosParamResource;
+            default:
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+        }
     }
 
     @Override
     public List<Resource> get(ResourceType type) {
-        return null;
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        List results;
+        switch (type){
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
+                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;
+            case APPLICATION_INPUT:
+                generator = new QueryGenerator(APPLICATION_INPUT);
+                generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationInput applicationInput = (ApplicationInput) result;
+                        ApplicationInputResource inputResource =
+                                (ApplicationInputResource)Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
+                        resourceList.add(inputResource);
+                    }
+                }
+                break;
+            case APPLICATION_OUTPUT:
+                generator = new QueryGenerator(APPLICATION_OUTPUT);
+                generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ApplicationOutput applicationOutput = (ApplicationOutput) result;
+                        ApplicationOutputResource outputResource =
+                                (ApplicationOutputResource)Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
+                        resourceList.add(outputResource);
+                    }
+                }
+                break;
+            case JOB_DETAIL:
+                generator = new QueryGenerator(JOB_DETAIL);
+                generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        JobDetail jobDetail = (JobDetail) result;
+                        JobDetailResource jobDetailResource =
+                                (JobDetailResource)Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
+                        resourceList.add(jobDetailResource);
+                    }
+                }
+                break;
+            case DATA_TRANSFER_DETAIL:
+                generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+                generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataTransferDetail transferDetail = (DataTransferDetail) result;
+                        DataTransferDetailResource transferDetailResource =
+                                (DataTransferDetailResource)Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
+                        resourceList.add(transferDetailResource);
+                    }
+                }
+                break;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.TASK_ID, taskId);
+                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;
+            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();
+        return resourceList;
     }
 
     @Override
     public void save() {
+        EntityManager em = ResourceUtils.getEntityManager();
+        TaskDetail existingTaskDetail = em.find(TaskDetail.class, taskId);
+        em.close();
 
+        em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        TaskDetail taskDetail = new TaskDetail();
+        taskDetail.setTaskId(taskId);
+        WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetailResource.getNodeInstanceId());
+        taskDetail.setNodeDetail(workflowNodeDetail);
+        taskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
+        taskDetail.setCreationTime(creationTime);
+        taskDetail.setAppId(applicationId);
+        taskDetail.setAppVersion(applicationVersion);
+        if (existingTaskDetail != null){
+            existingTaskDetail.setTaskId(taskId);
+            existingTaskDetail.setNodeDetail(workflowNodeDetail);
+            existingTaskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
+            existingTaskDetail.setCreationTime(creationTime);
+            existingTaskDetail.setAppId(applicationId);
+            existingTaskDetail.setAppVersion(applicationVersion);
+            taskDetail = em.merge(existingTaskDetail);
+        }else {
+            em.merge(taskDetail);
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/867cfee4/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 9311571..e4c8265 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
@@ -268,6 +268,13 @@ public class Utils {
                     logger.error("Object should be a Gateway Worker.", new IllegalArgumentException());
                     throw  new IllegalArgumentException("Object should be a Gateway Worker.");
                 }
+            case EXPERIMENT:
+                if (o instanceof  Experiment){
+                    return createExperiment((Experiment)o);
+                }else {
+                    logger.error("Object should be a Experiment.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a Experiment.");
+                }
             case EXPERIMENT_INPUT:
                 if (o instanceof  Experiment_Input){
                     return createExperimentInput((Experiment_Input)o);
@@ -282,10 +289,115 @@ public class Utils {
                     logger.error("Object should be a Experiment output data.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Object should be a Experiment output data.");
                 }
+            case WORKFLOW_NODE_DETAIL:
+                 if (o instanceof  WorkflowNodeDetail){
+                     return createWorkflowNodeDetail((WorkflowNodeDetail)o);
+                 }else {
+                     logger.error("Object should be a Workflow node data.", new IllegalArgumentException());
+                     throw new IllegalArgumentException("Object should be a Workflow node data.");
+                 }
+            case TASK_DETAIL:
+                if (o instanceof  TaskDetail){
+                    return createTaskDetail((TaskDetail)o);
+                }else {
+                    logger.error("Object should be a task detail data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a task detail data.");
+                }
+            case ERROR_DETAIL:
+                if (o instanceof  ErrorDetail){
+                    return createErrorDetail((ErrorDetail)o);
+                }else {
+                    logger.error("Object should be a error detail data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a error detail data.");
+                }
+            case APPLICATION_INPUT:
+                if (o instanceof  ApplicationInput){
+                    return createApplicationInput((ApplicationInput)o);
+                }else {
+                    logger.error("Object should be a application input data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a application input data.");
+                }
+            case APPLICATION_OUTPUT:
+                if (o instanceof  ApplicationOutput){
+                    return createApplicationOutput((ApplicationOutput)o);
+                }else {
+                    logger.error("Object should be a application output data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a application output data.");
+                }
+            case NODE_INPUT:
+                if (o instanceof  NodeInput){
+                    return createNodeInput((NodeInput)o);
+                }else {
+                    logger.error("Object should be a node input data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a node input data.");
+                }
+            case NODE_OUTPUT:
+                if (o instanceof  NodeOutput){
+                    return createNodeOutput((NodeOutput)o);
+                }else {
+                    logger.error("Object should be a node output data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a node output data.");
+                }
+            case JOB_DETAIL:
+                if (o instanceof  JobDetail){
+                    return createJobDetail((JobDetail)o);
+                }else {
+                    logger.error("Object should be a job detail data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a job detail data.");
+                }
+            case DATA_TRANSFER_DETAIL:
+                if (o instanceof  DataTransferDetail){
+                    return createDataTransferResource((DataTransferDetail)o);
+                }else {
+                    logger.error("Object should be a data transfer detail data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a data transfer detail data.");
+                }
+            case STATUS:
+                if (o instanceof  Status){
+                    return createStatusResource((Status)o);
+                }else {
+                    logger.error("Object should be a status data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a status data.");
+                }
+            case CONFIG_DATA:
+                if (o instanceof  ExperimentConfigData){
+                    return createExConfigDataResource((ExperimentConfigData)o);
+                }else {
+                    logger.error("Object should be a experiment config data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be experiment config data.");
+                }
+            case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                if (o instanceof  Computational_Resource_Scheduling){
+                    return createComputationalScheduling((Computational_Resource_Scheduling)o);
+                }else {
+                    logger.error("Object should be a scheduling resource data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be scheduling resource data.");
+                }
+            case ADVANCE_INPUT_DATA_HANDLING:
+                if (o instanceof  AdvancedInputDataHandling){
+                    return createAdvancedInputDataResource((AdvancedInputDataHandling)o);
+                }else {
+                    logger.error("Object should be a advanced input data handling data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be advanced input data handling data.");
+                }
+            case ADVANCE_OUTPUT_DATA_HANDLING:
+                if (o instanceof  AdvancedOutputDataHandling){
+                    return createAdvancedOutputDataResource((AdvancedOutputDataHandling)o);
+                }else {
+                    logger.error("Object should be a advanced output data handling data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be advanced output data handling data.");
+                }
+            case QOS_PARAM:
+                if (o instanceof  QosParam){
+                    return createQosParamResource((QosParam)o);
+                }else {
+                    logger.error("Object should be a QOSparam data.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be QOSparam data.");
+                }
             default:
+                logger.error("Illegal data type..", new IllegalArgumentException());
+                throw new IllegalArgumentException("Illegal data type..");
         }
-        return null;
-
     }
 
     /**
@@ -645,126 +757,43 @@ public class Utils {
         return schedulingResource;
     }
 
-        /**
-         *
-         * @param o  Workflow_Data model object
-     * @return  WorkflowDataResource object
-     */
-//    private static Resource createWorkflowData(Workflow_Data o){
-//        WorkflowDataResource workflowDataResource = new WorkflowDataResource();
-//        workflowDataResource.setExperimentID(o.getExperiment_data().getExperiment_id());
-//        workflowDataResource.setWorkflowInstanceID(o.getWorkflow_instanceID());
-//        workflowDataResource.setTemplateName(o.getTemplate_name());
-//        workflowDataResource.setStatus(o.getStatus());
-//        workflowDataResource.setStartTime(o.getStart_time());
-//        workflowDataResource.setLastUpdatedTime(o.getLast_update_time());
-//        return workflowDataResource;
-//    }
+    private static Resource createAdvancedInputDataResource (AdvancedInputDataHandling o){
+        AdvanceInputDataHandlingResource dataHandlingResource = new AdvanceInputDataHandlingResource();
+        ExperimentResource experimentResource = (ExperimentResource)createExperiment(o.getExperiment());
+        dataHandlingResource.setExperimentResource(experimentResource);
+        TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
+        dataHandlingResource.setTaskDetailResource(taskDetailResource);
+        dataHandlingResource.setDataHandlingId(o.getDataHandlingId());
+        dataHandlingResource.setWorkingDirParent(o.getParentWorkingDir());
+        dataHandlingResource.setWorkingDir(o.getWorkingDir());
+        dataHandlingResource.setStageInputFiles(o.isStageInputsToWorkingDir());
+        dataHandlingResource.setCleanAfterJob(o.isCleanAfterJob());
+        return dataHandlingResource;
+    }
 
-    /**
-     *
-     * @param o  Node_Data model object
-     * @return Node Data resource
-     */
-//    private static Resource createNodeData (Node_Data o){
-//        NodeDataResource nodeDataResource = new NodeDataResource();
-//        WorkflowDataResource workflowDataResource = (WorkflowDataResource)createWorkflowData(o.getWorkflow_Data());
-//        nodeDataResource.setWorkflowDataResource(workflowDataResource);
-//        nodeDataResource.setNodeID(o.getNode_id());
-//        nodeDataResource.setNodeType(o.getNode_type());
-//        if (o.getInputs()!=null) {
-//			nodeDataResource.setInputs(new String(o.getInputs()));
-//		}
-//		if (o.getOutputs()!=null) {
-//			nodeDataResource.setOutputs(new String(o.getOutputs()));
-//		}
-//		nodeDataResource.setStatus(o.getStatus());
-//        nodeDataResource.setStartTime(o.getStart_time());
-//        nodeDataResource.setLastUpdateTime(o.getLast_update_time());
-//        nodeDataResource.setExecutionIndex(o.getExecution_index());
-//        return nodeDataResource;
-//    }
+    private static Resource createAdvancedOutputDataResource (AdvancedOutputDataHandling o){
+        AdvancedOutputDataHandlingResource dataHandlingResource = new AdvancedOutputDataHandlingResource();
+        ExperimentResource experimentResource = (ExperimentResource)createExperiment(o.getExperiment());
+        dataHandlingResource.setExperimentResource(experimentResource);
+        TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
+        dataHandlingResource.setTaskDetailResource(taskDetailResource);
+        dataHandlingResource.setOutputDataHandlingId(o.getOutputDataHandlingId());
+        dataHandlingResource.setOutputDataDir(o.getOutputDataDir());
+        dataHandlingResource.setDataRegUrl(o.getDataRegUrl());
+        dataHandlingResource.setPersistOutputData(o.isPersistOutputData());
+        return dataHandlingResource;
+    }
 
-    /**
-     *
-     * @param o GramData model object
-     * @return GramData Resource object
-     */
-//    private static Resource createGramData (Gram_Data o){
-//        GramDataResource gramDataResource = new GramDataResource();
-//        WorkflowDataResource workflowDataResource = (WorkflowDataResource)createWorkflowData(o.getWorkflow_Data());
-//        gramDataResource.setWorkflowDataResource(workflowDataResource);
-//        gramDataResource.setNodeID(o.getNode_id());
-//        gramDataResource.setRsl(new String(o.getRsl()));
-//        gramDataResource.setInvokedHost(o.getInvoked_host());
-//        gramDataResource.setLocalJobID(o.getLocal_Job_ID());
-//        return gramDataResource;
-//    }
-
-//    private static Resource createExecutionError(Execution_Error o){
-//        ExecutionErrorResource executionErrorResource = new ExecutionErrorResource();
-//        ExperimentMetadataResource experimentDataResource = (ExperimentMetadataResource)createExperimentMetadata(o.getExperiment_MetaData());
-//        executionErrorResource.setMetadataResource(experimentDataResource);
-//        WorkflowDataResource workflowDataResource = (WorkflowDataResource)createWorkflowData(o.getWorkflow_Data());
-//        executionErrorResource.setWorkflowDataResource(workflowDataResource);
-//        executionErrorResource.setNodeID(o.getNode_id());
-//        executionErrorResource.setErrorID(o.getError_id());
-//        executionErrorResource.setGfacJobID(o.getGfacJobID());
-//        executionErrorResource.setSourceType(o.getSource_type());
-//        executionErrorResource.setErrorTime(o.getError_date());
-//        executionErrorResource.setErrorMsg(o.getError_msg());
-//        executionErrorResource.setErrorDes(o.getError_des());
-//        executionErrorResource.setErrorCode(o.getError_code());
-//        executionErrorResource.setErrorReporter(o.getError_reporter());
-//        executionErrorResource.setErrorLocation(o.getError_location());
-//        executionErrorResource.setActionTaken(o.getAction_taken());
-//        executionErrorResource.setErrorReference(o.getError_reference());
-//        return executionErrorResource;
-//    }
-
-//    private static Resource createGfacJobData (GFac_Job_Data o){
-//        GFacJobDataResource gFacJobDataResource = new GFacJobDataResource();
-//        ExperimentMetadataResource experimentDataResource = (ExperimentMetadataResource)createExperimentMetadata(o.getExperiment_metadata());
-//        WorkflowDataResource workflowDataResource = (WorkflowDataResource)createWorkflowData(o.getWorkflow_Data());
-//        gFacJobDataResource.setMetadataResource(experimentDataResource);
-//        gFacJobDataResource.setWorkflowDataResource(workflowDataResource);
-//        gFacJobDataResource.setNodeID(o.getNode_id());
-//        gFacJobDataResource.setApplicationDescID(o.getApplication_descriptor_ID());
-//        gFacJobDataResource.setServiceDescID(o.getService_descriptor_ID());
-//        gFacJobDataResource.setHostDescID(o.getHost_descriptor_ID());
-//        gFacJobDataResource.setJobData(o.getJob_data());
-//        gFacJobDataResource.setLocalJobID(o.getLocal_Job_ID());
-//        gFacJobDataResource.setSubmittedTime(o.getSubmitted_time());
-//        gFacJobDataResource.setStatusUpdateTime(o.getStatus_update_time());
-//        gFacJobDataResource.setStatus(o.getStatus());
-//        gFacJobDataResource.setMetadata(o.getMetadata());
-//        return gFacJobDataResource;
-//    }
-
-//    private static Resource createGfacJobStatus(GFac_Job_Status o) {
-//        GFacJobStatusResource gFacJobStatusResource = new GFacJobStatusResource();
-//        gFacJobStatusResource.setLocalJobID(o.getLocal_Job_ID());
-//        gFacJobStatusResource.setStatus(o.getStatus());
-//        gFacJobStatusResource.setStatusUpdateTime(o.getStatus_update_time());
-//        GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)createGfacJobData(o.getgFac_job_data());
-//        gFacJobStatusResource.setgFacJobDataResource(gFacJobDataResource);
-//        return gFacJobStatusResource;
-//    }
-
-//    private static Resource createOrchestratorData(Orchestrator data){
-//    	OrchestratorDataResource dataResource = new OrchestratorDataResource();
-//    	dataResource.setExperimentID(data.getExperiment_ID());
-//    	dataResource.setUserName(data.getUserName());
-//    	dataResource.setApplicationName(data.getApplicationName());
-//    	dataResource.setStatus(data.getStatus());
-//    	dataResource.setGfacEPR(data.getGfacEPR());
-//    	dataResource.setJobRequest(data.getJobRequest());
-//    	dataResource.setSubmittedTime(data.getSubmittedTime());
-//    	dataResource.setStatusUpdateTime(data.getStatusUpdateTime());
-//    	return dataResource;
-//    }
-//    public static byte[] getByteArray(String content){
-//        byte[] contentBytes = content.getBytes();
-//        return contentBytes;
-//    }
+    private static Resource createQosParamResource (QosParam o){
+        QosParamResource qosParamResource = new QosParamResource();
+        ExperimentResource experimentResource = (ExperimentResource)createExperiment(o.getExperiment());
+        qosParamResource.setExperimentResource(experimentResource);
+        TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTask());
+        qosParamResource.setTaskDetailResource(taskDetailResource);
+        qosParamResource.setQosId(o.getQosId());
+        qosParamResource.setExecuteBefore(o.getExecuteBefore());
+        qosParamResource.setStartExecutionAt(o.getStartExecutionAt());
+        qosParamResource.setNoOfRetries(o.getNoOfRetries());
+        return qosParamResource;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/867cfee4/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
index d78bc19..cc3e2c2 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
@@ -23,11 +23,20 @@ package org.apache.airavata.persistance.registry.jpa.resources;
 
 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.*;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+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 WorkflowNodeDetailResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(WorkflowNodeDetailResource.class);
     private ExperimentResource experimentResource;
     private String nodeInstanceId;
     private Timestamp creationTime;
@@ -67,26 +76,253 @@ public class WorkflowNodeDetailResource extends AbstractResource {
 
     @Override
     public Resource create(ResourceType type) {
-        return null;
+        switch (type){
+            case TASK_DETAIL:
+                TaskDetailResource taskDetailResource = new TaskDetailResource();
+                taskDetailResource.setWorkflowNodeDetailResource(this);
+                return taskDetailResource;
+            case ERROR_DETAIL:
+                ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+                errorDetailResource.setNodeDetail(this);
+                return errorDetailResource;
+            case NODE_INPUT:
+                NodeInputResource nodeInputResource = new NodeInputResource();
+                nodeInputResource.setNodeDetailResource(this);
+                return nodeInputResource;
+            case NODE_OUTPUT:
+                NodeOutputResource nodeOutputResource = new NodeOutputResource();
+                nodeOutputResource.setNodeDetailResource(this);
+                return nodeOutputResource;
+            case STATUS:
+                StatusResource statusResource = new StatusResource();
+                statusResource.setWorkflowNodeDetail(this);
+                return statusResource;
+            default:
+                logger.error("Unsupported resource type for workflow node detail resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for workflow node detail resource.");
+        }
     }
 
     @Override
     public void remove(ResourceType type, Object name) {
-
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        switch (type){
+            case TASK_DETAIL:
+                generator = new QueryGenerator(TASK_DETAIL);
+                generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case NODE_INPUT:
+                generator = new QueryGenerator(NODE_INPUT);
+                generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case NODE_OUTPUT:
+                generator = new QueryGenerator(NODE_OUTPUT);
+                generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            default:
+                logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+                break;
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 
     @Override
     public Resource get(ResourceType type, Object name) {
-        return null;
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator generator;
+        Query q;
+        switch (type) {
+            case TASK_DETAIL:
+                generator = new QueryGenerator(TASK_DETAIL);
+                generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, name);
+                q = generator.selectQuery(em);
+                TaskDetail taskDetail = (TaskDetail)q.getSingleResult();
+                TaskDetailResource taskDetailResource = (TaskDetailResource)Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
+                em.getTransaction().commit();
+                em.close();
+                return taskDetailResource;
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_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 NODE_INPUT:
+                generator = new QueryGenerator(NODE_INPUT);
+                generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
+                q = generator.selectQuery(em);
+                NodeInput nodeInput = (NodeInput)q.getSingleResult();
+                NodeInputResource nodeInputResource = (NodeInputResource)Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
+                em.getTransaction().commit();
+                em.close();
+                return nodeInputResource;
+            case NODE_OUTPUT:
+                generator = new QueryGenerator(NODE_OUTPUT);
+                generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
+                q = generator.selectQuery(em);
+                NodeOutput nodeOutput = (NodeOutput)q.getSingleResult();
+                NodeOutputResource nodeOutputResource = (NodeOutputResource)Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
+                em.getTransaction().commit();
+                em.close();
+                return nodeOutputResource;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
+                q = generator.selectQuery(em);
+                Status status = (Status)q.getSingleResult();
+                StatusResource statusResource = (StatusResource)Utils.getResource(ResourceType.STATUS, status);
+                em.getTransaction().commit();
+                em.close();
+                return statusResource;
+            default:
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+        }
     }
 
     @Override
     public List<Resource> get(ResourceType type) {
-        return null;
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        List results;
+        switch (type){
+            case TASK_DETAIL:
+                generator = new QueryGenerator(TASK_DETAIL);
+                generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        TaskDetail taskDetail = (TaskDetail) result;
+                        TaskDetailResource taskDetailResource =
+                                (TaskDetailResource)Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
+                        resourceList.add(taskDetailResource);
+                    }
+                }
+                break;
+            case ERROR_DETAIL:
+                generator = new QueryGenerator(ERROR_DETAIL);
+                generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                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;
+            case NODE_INPUT:
+                generator = new QueryGenerator(NODE_INPUT);
+                generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        NodeInput nodeInput = (NodeInput) result;
+                        NodeInputResource nodeInputResource =
+                                (NodeInputResource)Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
+                        resourceList.add(nodeInputResource);
+                    }
+                }
+                break;
+            case NODE_OUTPUT:
+                generator = new QueryGenerator(NODE_OUTPUT);
+                generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        NodeOutput nodeOutput = (NodeOutput) result;
+                        NodeOutputResource nodeOutputResource =
+                                (NodeOutputResource)Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
+                        resourceList.add(nodeOutputResource);
+                    }
+                }
+                break;
+            case STATUS:
+                generator = new QueryGenerator(STATUS);
+                generator.setParameter(StatusConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                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;
+            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();
+        return resourceList;
     }
 
     @Override
     public void save() {
+        EntityManager em = ResourceUtils.getEntityManager();
+        WorkflowNodeDetail existingNode = em.find(WorkflowNodeDetail.class, nodeInstanceId);
+        em.close();
 
+        em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        WorkflowNodeDetail workflowNodeDetail = new WorkflowNodeDetail();
+        workflowNodeDetail.setNodeId(nodeInstanceId);
+        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+        workflowNodeDetail.setExperiment(experiment);
+        workflowNodeDetail.setExpId(experimentResource.getExpID());
+        workflowNodeDetail.setCreationTime(creationTime);
+        workflowNodeDetail.setNodeName(nodeName);
+        if (existingNode != null){
+            existingNode.setExperiment(experiment);
+            existingNode.setExpId(experimentResource.getExpID());
+            existingNode.setCreationTime(creationTime);
+            existingNode.setNodeName(nodeName);
+            workflowNodeDetail = em.merge(existingNode);
+        }else {
+            em.merge(workflowNodeDetail);
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 }


Mime
View raw message