airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1485287 - in /airavata/trunk/modules/registry: airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/ airavata-jpa-registry/...
Date Wed, 22 May 2013 17:06:01 GMT
Author: chathuri
Date: Wed May 22 17:06:00 2013
New Revision: 1485287

URL: http://svn.apache.org/r1485287
Log:
adding GFac_Job_Data related changes

Added:
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/GFac_Job_Data.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GFacJobDataResource.java
Modified:
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeDataResource.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-derby.sql
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-mysql.sql
    airavata/trunk/modules/registry/airavata-jpa-registry/src/test/resources/data-derby.sql
    airavata/trunk/modules/registry/airavata-registry-test/src/test/resources/data-derby.sql

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java
Wed May 22 17:06:00 2013
@@ -37,6 +37,7 @@ public enum ResourceType {
     WORKFLOW_DATA,
     NODE_DATA,
     GRAM_DATA,
-    EXECUTION_ERROR
+    EXECUTION_ERROR,
+    GFAC_JOB_DATA
 
 }

Added: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/GFac_Job_Data.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/GFac_Job_Data.java?rev=1485287&view=auto
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/GFac_Job_Data.java
(added)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/GFac_Job_Data.java
Wed May 22 17:06:00 2013
@@ -0,0 +1,164 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+package org.apache.airavata.persistance.registry.jpa.model;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+public class GFac_Job_Data {
+    private String experiment_ID;
+    private String workflow_instanceID;
+    private String  node_id;
+    private String application_descriptor_ID;
+    private String host_descriptor_ID;
+    private String service_descriptor_ID;
+    @Lob
+    private String job_data;
+    @Id
+    private String local_Job_ID;
+    private Timestamp  submitted_time;
+    private Timestamp  completed_time;
+    private int status;
+    @Lob
+    private String metadata;
+
+    @ManyToOne()
+    @JoinColumn(name = "experiment_ID")
+    private Experiment_Data experiment_data;
+
+    @ManyToOne()
+    @JoinColumn(name = "workflow_instanceID")
+    private Workflow_Data workflow_Data;
+
+    public String getExperiment_ID() {
+        return experiment_ID;
+    }
+
+    public String getWorkflow_instanceID() {
+        return workflow_instanceID;
+    }
+
+    public String getNode_id() {
+        return node_id;
+    }
+
+    public String getApplication_descriptor_ID() {
+        return application_descriptor_ID;
+    }
+
+    public String getHost_descriptor_ID() {
+        return host_descriptor_ID;
+    }
+
+    public String getService_descriptor_ID() {
+        return service_descriptor_ID;
+    }
+
+    public String getJob_data() {
+        return job_data;
+    }
+
+    public String getLocal_Job_ID() {
+        return local_Job_ID;
+    }
+
+    public Timestamp getSubmitted_time() {
+        return submitted_time;
+    }
+
+    public Timestamp getCompleted_time() {
+        return completed_time;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+
+    public Experiment_Data getExperiment_data() {
+        return experiment_data;
+    }
+
+    public Workflow_Data getWorkflow_Data() {
+        return workflow_Data;
+    }
+
+    public void setExperiment_ID(String experiment_ID) {
+        this.experiment_ID = experiment_ID;
+    }
+
+    public void setWorkflow_instanceID(String workflow_instanceID) {
+        this.workflow_instanceID = workflow_instanceID;
+    }
+
+    public void setNode_id(String node_id) {
+        this.node_id = node_id;
+    }
+
+    public void setApplication_descriptor_ID(String application_descriptor_ID) {
+        this.application_descriptor_ID = application_descriptor_ID;
+    }
+
+    public void setHost_descriptor_ID(String host_descriptor_ID) {
+        this.host_descriptor_ID = host_descriptor_ID;
+    }
+
+    public void setService_descriptor_ID(String service_descriptor_ID) {
+        this.service_descriptor_ID = service_descriptor_ID;
+    }
+
+    public void setJob_data(String job_data) {
+        this.job_data = job_data;
+    }
+
+    public void setLocal_Job_ID(String local_Job_ID) {
+        this.local_Job_ID = local_Job_ID;
+    }
+
+    public void setSubmitted_time(Timestamp submitted_time) {
+        this.submitted_time = submitted_time;
+    }
+
+    public void setCompleted_time(Timestamp completed_time) {
+        this.completed_time = completed_time;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public void setMetadata(String metadata) {
+        this.metadata = metadata;
+    }
+
+    public void setExperiment_data(Experiment_Data experiment_data) {
+        this.experiment_data = experiment_data;
+    }
+
+    public void setWorkflow_Data(Workflow_Data workflow_Data) {
+        this.workflow_Data = workflow_Data;
+    }
+}

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
Wed May 22 17:06:00 2013
@@ -43,6 +43,7 @@ public abstract class AbstractResource i
     public static final String WORKFLOW_DATA = "Workflow_Data";
     public static final String EXPERIMENT_METADATA = "Experiment_Metadata";
     public static final String EXECUTION_ERROR = "Execution_Error";
+    public static final String GFAC_JOB_DATA = "GFac_Job_Data";
 
     //Gateway Table
     public final class GatewayConstants {
@@ -189,6 +190,21 @@ public abstract class AbstractResource i
         public static final String ERROR_CODE = "error_code";
     }
 
+    public final class GFacJobDataConstants {
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String APP_DESC_ID = "application_descriptor_ID";
+        public static final String HOST_DESC_ID = "host_descriptor_ID";
+        public static final String SERVICE_DESC_ID = "service_descriptor_ID";
+        public static final String JOB_DATA = "job_data";
+        public static final String LOCAL_JOB_ID = "local_Job_ID";
+        public static final String SUBMITTED_TIME = "submitted_time";
+        public static final String COMPLETED_TIME = "completed_time";
+        public static final String STATUS = "status";
+        public static final String METADATA = "metadata";
+    }
+
     protected AbstractResource() {
     }
 

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java
Wed May 22 17:06:00 2013
@@ -24,10 +24,7 @@ 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.Execution_Error;
-import org.apache.airavata.persistance.registry.jpa.model.Experiment_Data;
-import org.apache.airavata.persistance.registry.jpa.model.Experiment_Metadata;
-import org.apache.airavata.persistance.registry.jpa.model.Workflow_Data;
+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;
@@ -82,6 +79,10 @@ public class ExperimentDataResource exte
                 ExperimentMetadataResource experimentMetadataResource = new ExperimentMetadataResource();
                 experimentMetadataResource.setExpID(experimentID);
                 return experimentMetadataResource;
+            case GFAC_JOB_DATA:
+                GFacJobDataResource gFacJobDataResource = new GFacJobDataResource();
+                gFacJobDataResource.setExperimentDataResource(this);
+                return gFacJobDataResource;
             default:
                 logger.error("Unsupported resource type for experiment data resource... ",
new UnsupportedOperationException());
                 throw new IllegalArgumentException("Unsupported resource type for experiment
data resource.");
@@ -108,6 +109,12 @@ public class ExperimentDataResource exte
                 q = generator.deleteQuery(em);
                 q.executeUpdate();
                 break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
             default:
                 break;
         }
@@ -140,6 +147,15 @@ public class ExperimentDataResource exte
                 em.getTransaction().commit();
                 em.close();
                 return experimentMetadataResource;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.selectQuery(em);
+                GFac_Job_Data gFacJobData = (GFac_Job_Data)q.getSingleResult();
+                GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA,
gFacJobData);
+                em.getTransaction().commit();
+                em.close();
+                return gFacJobDataResource;
             default:
                 em.getTransaction().commit();
                 em.close();
@@ -197,6 +213,19 @@ public class ExperimentDataResource exte
                     }
                 }
                 break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.EXPERIMENT_ID, experimentID);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GFac_Job_Data gFacJobData = (GFac_Job_Data)result;
+                        GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA,
gFacJobData);
+                        resourceList.add(gFacJobDataResource);
+                    }
+                }
+                break;
             default:
                 em.getTransaction().commit();
                 em.close();

Added: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GFacJobDataResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GFacJobDataResource.java?rev=1485287&view=auto
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GFacJobDataResource.java
(added)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GFacJobDataResource.java
Wed May 22 17:06:00 2013
@@ -0,0 +1,221 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistance.registry.jpa.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.Experiment_Data;
+import org.apache.airavata.persistance.registry.jpa.model.GFac_Job_Data;
+import org.apache.airavata.persistance.registry.jpa.model.Workflow_Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sun.security.timestamp.TimestampToken;
+
+import javax.persistence.EntityManager;
+import java.sql.Timestamp;
+import java.util.List;
+
+public class GFacJobDataResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(GFacJobDataResource.class);
+    private ExperimentDataResource experimentDataResource;
+    private WorkflowDataResource workflowDataResource;
+    private String nodeID;
+    private String applicationDescID;
+    private String hostDescID;
+    private String serviceDescID;
+    private String jobData;
+    private String localJobID;
+    private Timestamp submittedTime;
+    private Timestamp completedTime;
+    private int status;
+    private String metadata;
+
+    public ExperimentDataResource getExperimentDataResource() {
+        return experimentDataResource;
+    }
+
+    public WorkflowDataResource getWorkflowDataResource() {
+        return workflowDataResource;
+    }
+
+    public String getNodeID() {
+        return nodeID;
+    }
+
+    public String getApplicationDescID() {
+        return applicationDescID;
+    }
+
+    public String getHostDescID() {
+        return hostDescID;
+    }
+
+    public String getServiceDescID() {
+        return serviceDescID;
+    }
+
+    public String getJobData() {
+        return jobData;
+    }
+
+    public String getLocalJobID() {
+        return localJobID;
+    }
+
+    public Timestamp getSubmittedTime() {
+        return submittedTime;
+    }
+
+    public Timestamp getCompletedTime() {
+        return completedTime;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+
+    public void setExperimentDataResource(ExperimentDataResource experimentDataResource)
{
+        this.experimentDataResource = experimentDataResource;
+    }
+
+    public void setWorkflowDataResource(WorkflowDataResource workflowDataResource) {
+        this.workflowDataResource = workflowDataResource;
+    }
+
+    public void setNodeID(String nodeID) {
+        this.nodeID = nodeID;
+    }
+
+    public void setApplicationDescID(String applicationDescID) {
+        this.applicationDescID = applicationDescID;
+    }
+
+    public void setHostDescID(String hostDescID) {
+        this.hostDescID = hostDescID;
+    }
+
+    public void setServiceDescID(String serviceDescID) {
+        this.serviceDescID = serviceDescID;
+    }
+
+    public void setJobData(String jobData) {
+        this.jobData = jobData;
+    }
+
+    public void setLocalJobID(String localJobID) {
+        this.localJobID = localJobID;
+    }
+
+    public void setSubmittedTime(Timestamp submittedTime) {
+        this.submittedTime = submittedTime;
+    }
+
+    public void setCompletedTime(Timestamp completedTime) {
+        this.completedTime = completedTime;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public void setMetadata(String metadata) {
+        this.metadata = metadata;
+    }
+
+    @Override
+    public Resource create(ResourceType type) {
+        logger.error("Unsupported resource type for GFac Job data resource" ,new UnsupportedOperationException()
);
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void remove(ResourceType type, Object name) {
+        logger.error("Unsupported resource type for GFac Job data resource" ,new UnsupportedOperationException()
);
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Resource get(ResourceType type, Object name) {
+        logger.error("Unsupported resource type for GFac Job data resource" ,new UnsupportedOperationException()
);
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public List<Resource> get(ResourceType type) {
+        logger.error("Unsupported resource type for GFac Job data resource" ,new UnsupportedOperationException()
);
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void save() {
+        EntityManager em = ResourceUtils.getEntityManager();
+        GFac_Job_Data existingGfacJobData = em.find(GFac_Job_Data.class, localJobID);
+        em.close();
+
+        em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        GFac_Job_Data gFacJobData = new GFac_Job_Data();
+        Experiment_Data experiment_data = em.find(Experiment_Data.class, experimentDataResource.getExperimentID());
+        gFacJobData.setExperiment_data(experiment_data);
+        gFacJobData.setExperiment_ID(experimentDataResource.getExperimentID());
+        Workflow_Data workflow_data = em.find(Workflow_Data.class, workflowDataResource.getWorkflowInstanceID());
+        gFacJobData.setWorkflow_Data(workflow_data);
+        gFacJobData.setWorkflow_instanceID(workflowDataResource.getWorkflowInstanceID());
+        gFacJobData.setNode_id(nodeID);
+        gFacJobData.setApplication_descriptor_ID(applicationDescID);
+        gFacJobData.setLocal_Job_ID(localJobID);
+        gFacJobData.setService_descriptor_ID(serviceDescID);
+        gFacJobData.setHost_descriptor_ID(hostDescID);
+        gFacJobData.setJob_data(jobData);
+        gFacJobData.setSubmitted_time(submittedTime);
+        gFacJobData.setCompleted_time(completedTime);
+        gFacJobData.setStatus(status);
+        gFacJobData.setMetadata(metadata);
+        if(existingGfacJobData != null){
+            Experiment_Data experiment_data1 = em.find(Experiment_Data.class, experimentDataResource.getExperimentID());
+            existingGfacJobData.setExperiment_data(experiment_data1);
+            existingGfacJobData.setExperiment_ID(experimentDataResource.getExperimentID());
+            Workflow_Data workflow_data1 = em.find(Workflow_Data.class, workflowDataResource.getWorkflowInstanceID());
+            existingGfacJobData.setWorkflow_Data(workflow_data1);
+            existingGfacJobData.setWorkflow_instanceID(workflowDataResource.getWorkflowInstanceID());
+            existingGfacJobData.setNode_id(nodeID);
+            existingGfacJobData.setApplication_descriptor_ID(applicationDescID);
+            existingGfacJobData.setLocal_Job_ID(localJobID);
+            existingGfacJobData.setService_descriptor_ID(serviceDescID);
+            existingGfacJobData.setHost_descriptor_ID(hostDescID);
+            existingGfacJobData.setJob_data(jobData);
+            existingGfacJobData.setSubmitted_time(submittedTime);
+            existingGfacJobData.setCompleted_time(completedTime);
+            existingGfacJobData.setStatus(status);
+            existingGfacJobData.setMetadata(metadata);
+            gFacJobData = em.merge(existingGfacJobData);
+        }  else {
+            em.persist(gFacJobData);
+        }
+        em.getTransaction().commit();
+        em.close();
+    }
+}

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeDataResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeDataResource.java?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeDataResource.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeDataResource.java
Wed May 22 17:06:00 2013
@@ -25,10 +25,7 @@ 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.Execution_Error;
-import org.apache.airavata.persistance.registry.jpa.model.Node_Data;
-import org.apache.airavata.persistance.registry.jpa.model.Node_DataPK;
-import org.apache.airavata.persistance.registry.jpa.model.Workflow_Data;
+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;
@@ -116,18 +113,59 @@ public class NodeDataResource extends Ab
     }
 
     public Resource create(ResourceType type) {
-        logger.error("Unsupported resource type for node data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
+        switch (type){
+            case GFAC_JOB_DATA:
+                GFacJobDataResource gFacJobDataResource = new GFacJobDataResource();
+                gFacJobDataResource.setWorkflowDataResource(workflowDataResource);
+                gFacJobDataResource.setNodeID(nodeID);
+                return gFacJobDataResource;
+            default:
+                logger.error("Unsupported resource type for node data resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for node data
resource.");
+        }
     }
 
     public void remove(ResourceType type, Object name) {
-        logger.error("Unsupported resource type for node data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        switch (type){
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            default:
+                logger.error("Unsupported resource type for node data resource.", new IllegalArgumentException());
+                break;
+        }
+        em.getTransaction().commit();
+        em.close();
     }
 
     public Resource get(ResourceType type, Object name) {
-        logger.error("Unsupported resource type for node data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator generator;
+        Query q;
+        switch (type) {
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.selectQuery(em);
+                GFac_Job_Data gFac_job_data = (GFac_Job_Data)q.getSingleResult();
+                GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA,
gFac_job_data);
+                em.getTransaction().commit();
+                em.close();
+                return gFacJobDataResource;
+            default:
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported resource type for node data resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for node data
resource.");
+        }
     }
 
     public List<Resource> get(ResourceType type) {
@@ -151,6 +189,19 @@ public class NodeDataResource extends Ab
                     }
                 }
                 break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.NODE_ID, nodeID);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GFac_Job_Data gFac_job_data = (GFac_Job_Data)result;
+                        GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA,
gFac_job_data);
+                        resourceList.add(gFacJobDataResource);
+                    }
+                }
+                break;
             default:
                 em.getTransaction().commit();
                 em.close();

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
Wed May 22 17:06:00 2013
@@ -317,6 +317,13 @@ public class Utils {
                     logger.error("Object should be a Node Error type.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Object should be a Node Error.");
                 }
+            case GFAC_JOB_DATA:
+                if (o instanceof GFac_Job_Data){
+                    return createGfacJobData((GFac_Job_Data) o);
+                }else {
+                    logger.error("Object should be a GFac Job Data type.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a GFac Job Data.");
+                }
             default:
         }
         return null;
@@ -602,6 +609,25 @@ public class Utils {
         return executionErrorResource;
     }
 
+    private static Resource createGfacJobData (GFac_Job_Data o){
+        GFacJobDataResource gFacJobDataResource = new GFacJobDataResource();
+        ExperimentDataResource experimentDataResource = (ExperimentDataResource)createExperimentData(o.getExperiment_data());
+        WorkflowDataResource workflowDataResource = (WorkflowDataResource)createWorkflowData(o.getWorkflow_Data());
+        gFacJobDataResource.setExperimentDataResource(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.setCompletedTime(o.getCompleted_time());
+        gFacJobDataResource.setStatus(o.getStatus());
+        gFacJobDataResource.setMetadata(o.getMetadata());
+        return gFacJobDataResource;
+    }
+
 //    public static byte[] getByteArray(String content){
 //        byte[] contentBytes = content.getBytes();
 //        return contentBytes;

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
Wed May 22 17:06:00 2013
@@ -109,6 +109,10 @@ public class WorkflowDataResource extend
                ExecutionErrorResource executionErrorResource = new ExecutionErrorResource();
                executionErrorResource.setWorkflowDataResource(this);
                return executionErrorResource;
+           case GFAC_JOB_DATA:
+               GFacJobDataResource gFacJobDataResource = new GFacJobDataResource();
+               gFacJobDataResource.setWorkflowDataResource(this);
+               return gFacJobDataResource;
            default:
                logger.error("Unsupported resource type for workflow data resource.", new
IllegalArgumentException());
                throw new IllegalArgumentException("Unsupported resource type for workflow
data resource.");
@@ -141,6 +145,12 @@ public class WorkflowDataResource extend
                 q = generator.deleteQuery(em);
                 q.executeUpdate();
                 break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
             default:
                 logger.error("Unsupported resource type for workflow data resource.", new
IllegalArgumentException());
                 break;
@@ -184,13 +194,20 @@ public class WorkflowDataResource extend
                 em.getTransaction().commit();
                 em.close();
                 return executionErrorResource;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.selectQuery(em);
+                GFac_Job_Data gFac_job_data = (GFac_Job_Data)q.getSingleResult();
+                GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA,
gFac_job_data);
+                em.getTransaction().commit();
+                em.close();
+                return gFacJobDataResource;
             default:
                 em.getTransaction().commit();
                 em.close();
                 logger.error("Unsupported resource type for workflow data resource.", new
IllegalArgumentException());
                 throw new IllegalArgumentException("Unsupported resource type for workflow
data resource.");
-
-
         }
     }
 
@@ -242,6 +259,19 @@ public class WorkflowDataResource extend
                     }
                 }
                 break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.WORKFLOW_INSTANCE_ID, workflowInstanceID);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GFac_Job_Data gFac_job_data = (GFac_Job_Data)result;
+                        GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA,
gFac_job_data);
+                        resourceList.add(gFacJobDataResource);
+                    }
+                }
+                break;
             default:
                 em.getTransaction().commit();
                 em.close();

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-derby.sql
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-derby.sql?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-derby.sql
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-derby.sql
Wed May 22 17:06:00 2013
@@ -21,7 +21,7 @@
 create table Gateway
 (
         gateway_name varchar(255),
-	    owner varchar(255),
+	      owner varchar(255),
         PRIMARY KEY (gateway_name)
 );
 
@@ -131,7 +131,7 @@ create table Application_Descriptor
 create table Experiment
 (
           project_name varchar(255),
-	      gateway_name varchar(255),
+	        gateway_name varchar(255),
           user_name varchar(255),
           experiment_ID varchar(255),
           submitted_date TIMESTAMP DEFAULT '0000-00-00 00:00:00',
@@ -143,17 +143,17 @@ create table Experiment
 
 create table Experiment_Data
 (
-	experiment_ID varchar(255),
-	name varchar(255),
-	username varchar(255),
-	PRIMARY KEY (experiment_ID)
+        experiment_ID varchar(255),
+        name varchar(255),
+        username varchar(255),
+        PRIMARY KEY (experiment_ID)
 );
 
 create table Experiment_Metadata
 (
-	experiment_ID varchar(255),
-	metadata BLOB,
-	PRIMARY KEY (experiment_ID)
+        experiment_ID varchar(255),
+        metadata BLOB,
+        PRIMARY KEY (experiment_ID)
 );
 
 
@@ -184,6 +184,7 @@ create table Node_Data
        FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID) ON
DELETE CASCADE
 );
 
+-- need to remove this in future
 create table Gram_Data
 (
        workflow_instanceID varchar(255),
@@ -195,6 +196,25 @@ create table Gram_Data
        FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID) ON
DELETE CASCADE
 );
 
+create table GFac_Job_Data
+(
+       experiment_ID varchar(255),
+       workflow_instanceID varchar(255),
+       node_id varchar(255),
+       application_descriptor_ID varchar(255),
+       host_descriptor_ID varchar(255),
+       service_descriptor_ID varchar(255),
+       job_data CLOB,
+       local_Job_ID varchar(255),
+       submitted_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       completed_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       status INT,
+       metadata CLOB,
+       PRIMARY KEY(local_Job_ID),
+       FOREIGN KEY (experiment_ID) REFERENCES Experiment_Data(experiment_ID),
+       FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID)
+);
+
 
 CREATE TABLE community_user
 (

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-mysql.sql
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-mysql.sql?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-mysql.sql
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data-mysql.sql
Wed May 22 17:06:00 2013
@@ -21,7 +21,7 @@
 create table Gateway
 (
         gateway_name varchar(255),
-	    owner varchar(255),
+	      owner varchar(255),
         PRIMARY KEY (gateway_name)
 );
 
@@ -129,7 +129,7 @@ create table Application_Descriptor
 create table Experiment
 (
           project_name varchar(255),
-	      gateway_name varchar(255),
+	        gateway_name varchar(255),
           user_name varchar(255),
           experiment_ID varchar(255),
           submitted_date TIMESTAMP DEFAULT '0000-00-00 00:00:00',
@@ -141,17 +141,17 @@ create table Experiment
 
 create table Experiment_Data
 (
-	experiment_ID varchar(255),
-	name varchar(255),
-	username varchar(255),
-	PRIMARY KEY (experiment_ID)
+          experiment_ID varchar(255),
+          name varchar(255),
+          username varchar(255),
+          PRIMARY KEY (experiment_ID)
 );
 
 create table Experiment_Metadata
 (
-	experiment_ID varchar(255),
-	metadata BLOB,
-	PRIMARY KEY (experiment_ID)
+          experiment_ID varchar(255),
+          metadata BLOB,
+          PRIMARY KEY (experiment_ID)
 );
 
 
@@ -193,6 +193,25 @@ create table Gram_Data
        FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID) ON
DELETE CASCADE
 );
 
+create table GFac_Job_Data
+(
+       experiment_ID varchar(255),
+       workflow_instanceID varchar(255),
+       node_id varchar(255),
+       application_descriptor_ID varchar(255),
+       host_descriptor_ID varchar(255),
+       service_descriptor_ID varchar(255),
+       job_data LONGTEXT,
+       local_Job_ID varchar(255),
+       submitted_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       completed_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       status INT,
+       metadata LONGTEXT,
+       PRIMARY KEY(local_Job_ID),
+       FOREIGN KEY (experiment_ID) REFERENCES Experiment_Data(experiment_ID),
+       FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID)
+);
+
 
 CREATE TABLE community_user
 (

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/test/resources/data-derby.sql
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/test/resources/data-derby.sql?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/test/resources/data-derby.sql
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/test/resources/data-derby.sql
Wed May 22 17:06:00 2013
@@ -21,7 +21,7 @@
 create table Gateway
 (
         gateway_name varchar(255),
-	    owner varchar(255),
+	      owner varchar(255),
         PRIMARY KEY (gateway_name)
 );
 
@@ -143,17 +143,17 @@ create table Experiment
 
 create table Experiment_Data
 (
-	experiment_ID varchar(255),
-	name varchar(255),
-	username varchar(255),
-	PRIMARY KEY (experiment_ID)
+        experiment_ID varchar(255),
+        name varchar(255),
+        username varchar(255),
+        PRIMARY KEY (experiment_ID)
 );
 
 create table Experiment_Metadata
 (
-	experiment_ID varchar(255),
-	metadata BLOB,
-	PRIMARY KEY (experiment_ID)
+        experiment_ID varchar(255),
+        metadata BLOB,
+        PRIMARY KEY (experiment_ID)
 );
 
 
@@ -195,6 +195,25 @@ create table Gram_Data
        FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID) ON
DELETE CASCADE
 );
 
+create table GFac_Job_Data
+(
+       experiment_ID varchar(255),
+       workflow_instanceID varchar(255),
+       node_id varchar(255),
+       application_descriptor_ID varchar(255),
+       host_descriptor_ID varchar(255),
+       service_descriptor_ID varchar(255),
+       job_data CLOB,
+       local_Job_ID varchar(255),
+       submitted_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       completed_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       status INT,
+       metadata CLOB,
+       PRIMARY KEY(local_Job_ID),
+       FOREIGN KEY (experiment_ID) REFERENCES Experiment_Data(experiment_ID),
+       FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID)
+);
+
 CREATE TABLE COMMUNITY_USER
 (
         GATEWAY_NAME VARCHAR(256) NOT NULL,

Modified: airavata/trunk/modules/registry/airavata-registry-test/src/test/resources/data-derby.sql
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-registry-test/src/test/resources/data-derby.sql?rev=1485287&r1=1485286&r2=1485287&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-registry-test/src/test/resources/data-derby.sql
(original)
+++ airavata/trunk/modules/registry/airavata-registry-test/src/test/resources/data-derby.sql
Wed May 22 17:06:00 2013
@@ -21,7 +21,7 @@
 create table Gateway
 (
         gateway_name varchar(255),
-	    owner varchar(255),
+	      owner varchar(255),
         PRIMARY KEY (gateway_name)
 );
 
@@ -143,17 +143,17 @@ create table Experiment
 
 create table Experiment_Data
 (
-	experiment_ID varchar(255),
-	name varchar(255),
-	username varchar(255),
-	PRIMARY KEY (experiment_ID)
+          experiment_ID varchar(255),
+          name varchar(255),
+          username varchar(255),
+          PRIMARY KEY (experiment_ID)
 );
 
 create table Experiment_Metadata
 (
-	experiment_ID varchar(255),
-	metadata BLOB,
-	PRIMARY KEY (experiment_ID)
+          experiment_ID varchar(255),
+          metadata BLOB,
+          PRIMARY KEY (experiment_ID)
 );
 
 
@@ -195,6 +195,25 @@ create table Gram_Data
        FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID) ON
DELETE CASCADE
 );
 
+create table GFac_Job_Data
+(
+       experiment_ID varchar(255),
+       workflow_instanceID varchar(255),
+       node_id varchar(255),
+       application_descriptor_ID varchar(255),
+       host_descriptor_ID varchar(255),
+       service_descriptor_ID varchar(255),
+       job_data CLOB,
+       local_Job_ID varchar(255),
+       submitted_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       completed_time TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+       status INT,
+       metadata CLOB,
+       PRIMARY KEY(local_Job_ID),
+       FOREIGN KEY (experiment_ID) REFERENCES Experiment_Data(experiment_ID),
+       FOREIGN KEY (workflow_instanceID) REFERENCES Workflow_Data(workflow_instanceID)
+);
+
 CREATE TABLE COMMUNITY_USER
 (
         GATEWAY_NAME VARCHAR(256) NOT NULL,



Mime
View raw message