airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: changing primary key of job model and job status
Date Fri, 30 Oct 2015 18:09:40 GMT
Repository: airavata
Updated Branches:
  refs/heads/orchestratorTaskBreakdown b57a5015d -> b442e0c35


changing primary key of job model and job status


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

Branch: refs/heads/orchestratorTaskBreakdown
Commit: b442e0c351a4e48f9c7c2733f0a88947a24c6272
Parents: b57a501
Author: Chathuri Wimalasena <chathuri@apache.org>
Authored: Fri Oct 30 14:09:29 2015 -0400
Committer: Chathuri Wimalasena <chathuri@apache.org>
Committed: Fri Oct 30 14:09:29 2015 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 31 +++++++----
 .../apache/airavata/gfac/core/GFacUtils.java    |  2 +-
 .../catalog/impl/ExperimentRegistry.java        | 49 ++++++++++++-----
 .../core/experiment/catalog/model/Job.java      |  2 +-
 .../core/experiment/catalog/model/JobPK.java    | 16 +++---
 .../experiment/catalog/model/JobStatus.java     | 12 ++++-
 .../experiment/catalog/model/JobStatusPK.java   | 14 ++---
 .../resources/AbstractExpCatResource.java       |  1 +
 .../catalog/resources/JobResource.java          |  2 +-
 .../catalog/resources/JobStatusResource.java    | 12 ++++-
 .../catalog/resources/TaskResource.java         | 55 +++++++++++++++++++-
 .../experiment/catalog/resources/Utils.java     |  1 +
 .../src/main/resources/expcatalog-derby.sql     |  9 ++--
 .../src/main/resources/expcatalog-mysql.sql     |  9 ++--
 .../src/test/resources/expcatalog-derby.sql     |  9 ++--
 .../airavata/registry/cpi/utils/Constants.java  |  1 +
 16 files changed, 171 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 15f930b..af0372e 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -56,6 +56,7 @@ import org.apache.airavata.model.security.AuthzToken;
 import org.apache.airavata.model.status.ExperimentState;
 import org.apache.airavata.model.status.ExperimentStatus;
 import org.apache.airavata.model.status.JobStatus;
+import org.apache.airavata.model.task.TaskModel;
 import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.orchestrator.client.OrchestratorClientFactory;
@@ -1568,11 +1569,17 @@ public class AiravataServerHandler implements Airavata.Iface {
             Map<String, JobStatus> jobStatus = new HashMap<String, JobStatus>();
             if (processModels != null && !processModels.isEmpty()){
                 for (Object process : processModels) {
-                    String processId =  ((ProcessModel)process).getProcessId();
-                    List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB,
Constants.FieldConstants.JobConstants.PROCESS_ID, processId);
-                    for (Object jobObject : jobs) {
-                        String jobID = ((JobModel)jobObject).getJobId();
-                        jobStatus.put(jobID, ((JobModel)jobObject).getJobStatus());
+                    ProcessModel processModel = (ProcessModel) process;
+                    List<TaskModel> tasks = processModel.getTasks();
+                    if (tasks != null && !tasks.isEmpty()){
+                      for (TaskModel task : tasks){
+                          String taskId =  task.getTaskId();
+                          List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB,
Constants.FieldConstants.JobConstants.TASK_ID, taskId);
+                          for (Object jobObject : jobs) {
+                              String jobID = ((JobModel)jobObject).getJobId();
+                              jobStatus.put(jobID, ((JobModel)jobObject).getJobStatus());
+                          }
+                      }
                     }
                 }
             }
@@ -1600,10 +1607,16 @@ public class AiravataServerHandler implements Airavata.Iface {
             List<JobModel> jobList = new ArrayList<>();
             if (processModels != null && !processModels.isEmpty()){
                 for (Object process : processModels) {
-                    String processId =  ((ProcessModel)process).getProcessId();
-                    List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB,
Constants.FieldConstants.JobConstants.PROCESS_ID, processId);
-                    for (Object jobObject : jobs) {
-                        jobList.add ((JobModel)jobObject);
+                    ProcessModel processModel = (ProcessModel) process;
+                    List<TaskModel> tasks = processModel.getTasks();
+                    if (tasks != null && !tasks.isEmpty()){
+                        for (TaskModel taskModel : tasks){
+                            String taskId =  taskModel.getTaskId();
+                            List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB,
Constants.FieldConstants.JobConstants.TASK_ID, taskId);
+                            for (Object jobObject : jobs) {
+                                jobList.add ((JobModel)jobObject);
+                            }
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
index 52f8e61..f40e8ae 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
@@ -215,7 +215,7 @@ public class GFacUtils {
             }else {
                 jobStatus.setTimeOfStateChange(jobStatus.getTimeOfStateChange());
             }
-            CompositeIdentifier ids = new CompositeIdentifier(jobModel.getProcessId(), jobModel.getJobId());
+            CompositeIdentifier ids = new CompositeIdentifier(jobModel.getTaskId(), jobModel.getJobId());
 			experimentCatalog.add(ExpCatChildDataType.JOB_STATUS, jobStatus, ids);
             JobIdentifier identifier = new JobIdentifier(jobModel.getJobId(), jobModel.getTaskId(),
                     processContext.getProcessId(), processContext.getProcessModel().getExperimentId(),

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
index 077b8e1..3a36f61 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
@@ -535,7 +535,7 @@ public class ExperimentRegistry {
     }
 
     public String addJobStatus(JobStatus jobStatus, CompositeIdentifier cis) throws RegistryException
{
-        String processId = (String)cis.getTopLevelIdentifier();
+        String taskId = (String)cis.getTopLevelIdentifier();
         String jobID = (String)cis.getSecondLevelIdentifier();
         try {
             JobResource jobResource = new JobResource();
@@ -546,7 +546,7 @@ public class ExperimentRegistry {
             }
 	        status.setStatusId(getStatusID(jobID));
 	        status.setJobId(jobID);
-	        status.setProcessId(processId);
+	        status.setTaskId(taskId);
 	        status.setTimeOfStateChange(AiravataUtils.getTime(jobStatus.getTimeOfStateChange()));
 	        status.setState(jobStatus.getJobState().toString());
 	        status.setReason(jobStatus.getReason());
@@ -876,15 +876,15 @@ public class ExperimentRegistry {
     }
 
     public String updateJob(JobModel job, CompositeIdentifier cis) throws RegistryException
{
-        String processId = (String) cis.getTopLevelIdentifier();
+        String taskId = (String) cis.getTopLevelIdentifier();
         String jobId = (String) cis.getSecondLevelIdentifier();
         try {
-	        ProcessResource processResource = new ProcessResource();
-	        processResource.setProcessId(processId);
-	        JobResource jobResource = processResource.getJob(jobId);
+	        TaskResource taskResource = new TaskResource();
+	        taskResource.setTaskId(taskId);
+	        JobResource jobResource = taskResource.getJob(jobId);
 	        jobResource.setJobId(jobId);
 	        jobResource.setTaskId(job.getTaskId());
-	        jobResource.setProcessId(processId);
+	        jobResource.setProcessId(job.getProcessId());
 	        jobResource.setJobDescription(job.getJobDescription());
 	        jobResource.setCreationTime(AiravataUtils.getTime(job.getCreationTime()));
 	        jobResource.setComputeResourceConsumed(job.getComputeResourceConsumed());
@@ -1104,12 +1104,12 @@ public class ExperimentRegistry {
     }
 
     public Object getJob(CompositeIdentifier cis, String fieldName) throws RegistryException
{
-        String processId = (String) cis.getTopLevelIdentifier();
+        String taskId = (String) cis.getTopLevelIdentifier();
         String jobId = (String) cis.getSecondLevelIdentifier();
         try {
-	        ProcessResource processResource = new ProcessResource();
-	        processResource.setProcessId(processId);
-	        JobResource resource = processResource.getJob(jobId);
+	        TaskResource taskResource = new TaskResource();
+	        taskResource.setTaskId(taskId);
+	        JobResource resource = taskResource.getJob(jobId);
 	        if (fieldName == null) {
 		        return ThriftDataModelConversion.getJobModel(resource);
 	        } else if (fieldName.equals(Constants.FieldConstants.JobConstants.JOB_STATUS)) {
@@ -1238,7 +1238,32 @@ public class ExperimentRegistry {
 	                jobs.add(jobModel);
                 }
                 return jobs;
-            } else {
+            }else if (fieldName.equals(Constants.FieldConstants.JobConstants.TASK_ID)) {
+                TaskResource taskResource = new TaskResource();
+                taskResource.setTaskId((String) value);
+                List<JobResource> resources = taskResource.getJobList();
+                for (JobResource jobResource : resources) {
+                    JobModel jobModel = ThriftDataModelConversion.getJobModel(jobResource);
+                    List<ExperimentCatResource> jobStatuses = jobResource.get(ResourceType.JOB_STATUS);
+                    JobStatusResource latestSR = null;
+                    for (ExperimentCatResource jobStatuse : jobStatuses) {
+                        JobStatusResource jobSR = (JobStatusResource) jobStatuse;
+                        if (latestSR == null) {
+                            latestSR = jobSR;
+                        } else {
+                            latestSR = (jobSR.getTimeOfStateChange().after(latestSR.getTimeOfStateChange())
? jobSR :
+                                    latestSR);
+                        }
+                    }
+                    if (latestSR != null) {
+                        JobStatus jobStatus = new JobStatus(JobState.valueOf(latestSR.getState()));
+                        jobStatus.setReason(latestSR.getReason());
+                        jobModel.setJobStatus(jobStatus);
+                    }
+                    jobs.add(jobModel);
+                }
+                return jobs;
+            }else {
                 logger.error("Unsupported field name to retrieve job list...");
             }
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java
index 5827863..84f12d4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/Job.java
@@ -56,7 +56,6 @@ public class Job {
         this.jobId = jobId;
     }
 
-	@Id
 	@Column(name = "PROCESS_ID")
 	public String getProcessId() {
 		return processId;
@@ -66,6 +65,7 @@ public class Job {
 		this.processId = processId;
 	}
 
+    @Id
     @Column(name = "TASK_ID")
     public String getTaskId() {
         return taskId;

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java
index e1f8da2..eb704d5 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobPK.java
@@ -30,7 +30,7 @@ import java.io.Serializable;
 public class JobPK implements Serializable {
     private final static Logger logger = LoggerFactory.getLogger(JobPK.class);
     private String jobId;
-    private String processId;
+    private String taskId;
 
     @Id
     @Column(name = "JOB_ID")
@@ -43,13 +43,13 @@ public class JobPK implements Serializable {
     }
 
     @Id
-    @Column(name = "PROCESS_ID")
-    public String getProcessId() {
-        return processId;
+    @Column(name = "TASK_ID")
+    public String getTaskId() {
+        return taskId;
     }
 
-    public void setProcessId(String processId) {
-        this.processId = processId;
+    public void setTaskId(String taskId) {
+        this.taskId = taskId;
     }
 
     @Override
@@ -60,7 +60,7 @@ public class JobPK implements Serializable {
         JobPK that = (JobPK) o;
 
         if (getJobId() != null ? !getJobId().equals(that.getJobId()) : that.getJobId() !=
null) return false;
-        if (getProcessId() != null ? !getProcessId().equals(that.getProcessId()) : that.getProcessId()
!= null) return false;
+        if (getTaskId() != null ? !getTaskId().equals(that.getTaskId()) : that.getTaskId()
!= null) return false;
 
         return true;
     }
@@ -68,7 +68,7 @@ public class JobPK implements Serializable {
     @Override
     public int hashCode() {
         int result = getJobId() != null ? getJobId().hashCode() : 0;
-        result = 31 * result + (getProcessId() != null ? getProcessId().hashCode() : 0);
+        result = 31 * result + (getTaskId() != null ? getTaskId().hashCode() : 0);
         return result;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java
index 2dd6d35..0aafa35 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatus.java
@@ -34,6 +34,7 @@ public class JobStatus {
     private String statusId;
     private String jobId;
     private String processId;
+    private String taskId;
     private String state;
     private Timestamp timeOfStateChange;
     private String reason;
@@ -59,12 +60,17 @@ public class JobStatus {
         this.jobId = jobId;
     }
 
-    @Id
     @Column(name = "PROCESS_ID")
     public String getProcessId() {
         return processId;
     }
 
+    @Id
+    @Column(name = "TASK_ID")
+    public String getTaskId() {
+        return taskId;
+    }
+
     public void setProcessId(String processId) {
         this.processId = processId;
     }
@@ -93,6 +99,10 @@ public class JobStatus {
         return reason;
     }
 
+    public void setTaskId(String taskId) {
+        this.taskId = taskId;
+    }
+
     public void setReason(String reason) {
         this.reason = reason;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java
index f63cbfa..7ca1636 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/JobStatusPK.java
@@ -31,7 +31,7 @@ public class JobStatusPK implements Serializable {
     private final static Logger logger = LoggerFactory.getLogger(JobStatusPK.class);
     private String statusId;
     private String jobId;
-    private String processId;
+    private String taskId;
 
     @Id
     @Column(name = "STATUS_ID")
@@ -55,12 +55,12 @@ public class JobStatusPK implements Serializable {
 
     @Id
     @Column(name = "PROCESS_ID")
-    public String getProcessId() {
-        return processId;
+    public String getTaskId() {
+        return taskId;
     }
 
-    public void setProcessId(String processId) {
-        this.processId = processId;
+    public void setTaskId(String taskId) {
+        this.taskId = taskId;
     }
 
     @Override
@@ -72,7 +72,7 @@ public class JobStatusPK implements Serializable {
 
         if (getStatusId() != null ? !getStatusId().equals(that.getStatusId()) : that.getStatusId()
!= null) return false;
         if (getJobId() != null ? !getJobId().equals(that.getJobId()) : that.getJobId() !=
null) return false;
-        if (getProcessId() != null ? !getProcessId().equals(that.getProcessId()) : that.getProcessId()
!= null) return false;
+        if (getTaskId() != null ? !getTaskId().equals(that.getTaskId()) : that.getTaskId()
!= null) return false;
 
         return true;
     }
@@ -81,7 +81,7 @@ public class JobStatusPK implements Serializable {
     public int hashCode() {
         int result = getStatusId() != null ? getStatusId().hashCode() : 0;
         result = 31 * result + (getJobId() != null ? getJobId().hashCode() : 0);
-        result = 31 * result + (getProcessId() != null ? getProcessId().hashCode() : 0);
+        result = 31 * result + (getTaskId() != null ? getTaskId().hashCode() : 0);
         return result;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
index b9bdf4b..5135a9f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
@@ -221,6 +221,7 @@ public abstract class AbstractExpCatResource implements ExperimentCatResource
{
     public final class JobConstants {
         public static final String JOB_ID = "jobId";
         public static final String PROCESS_ID = "processId";
+        public static final String TASK_ID = "taskId";
     }
 
     // Job Status table

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
index 5c90455..8855370 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
@@ -296,7 +296,7 @@ public class JobResource extends AbstractExpCatResource {
             em = ExpCatResourceUtils.getEntityManager();
             JobPK jobPK = new JobPK();
             jobPK.setJobId(jobId);
-            jobPK.setProcessId(processId);
+            jobPK.setTaskId(taskId);
             Job existingJob = em.find(Job.class, jobPK);
             if (em.isOpen()) {
                 if (em.getTransaction().isActive()){

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
index 97f2973..579219c 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
@@ -39,6 +39,7 @@ public class JobStatusResource extends AbstractExpCatResource {
     private String statusId;
     private String jobId;
     private String processId;
+    private String taskId;
     private String state;
     private Timestamp timeOfStateChange;
     private String reason;
@@ -91,6 +92,14 @@ public class JobStatusResource extends AbstractExpCatResource {
         this.reason = reason;
     }
 
+    public String getTaskId() {
+        return taskId;
+    }
+
+    public void setTaskId(String taskId) {
+        this.taskId = taskId;
+    }
+
     public ExperimentCatResource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for task status data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
@@ -126,7 +135,7 @@ public class JobStatusResource extends AbstractExpCatResource {
             JobStatusPK jobStatusPK = new JobStatusPK();
             jobStatusPK.setJobId(jobId);
             jobStatusPK.setStatusId(statusId);
-            jobStatusPK.setProcessId(processId);
+            jobStatusPK.setTaskId(taskId);
             JobStatus existingJobStatus = em.find(JobStatus.class, jobStatusPK);
             if (em.isOpen()) {
                 if (em.getTransaction().isActive()){
@@ -145,6 +154,7 @@ public class JobStatusResource extends AbstractExpCatResource {
             jobStatus.setStatusId(statusId);
             jobStatus.setJobId(jobId);
             jobStatus.setProcessId(processId);
+            jobStatus.setTaskId(taskId);
             jobStatus.setState(state);
             jobStatus.setReason(reason);
             if (existingJobStatus == null){

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
index 926f4ba..0381f90 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
@@ -115,7 +115,10 @@ public class TaskResource extends AbstractExpCatResource {
                 TaskErrorResource taskErrorResource = new TaskErrorResource();
                 taskErrorResource.setTaskId(taskId);
                 return taskErrorResource;
-
+            case JOB:
+                JobResource jobResource = new JobResource();
+                jobResource.setTaskId(taskId);
+                return jobResource;
             default:
                 logger.error("Unsupported resource type for task data resource.", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();
@@ -143,6 +146,13 @@ public class TaskResource extends AbstractExpCatResource {
                     q = generator.deleteQuery(em);
                     q.executeUpdate();
                     break;
+                case JOB:
+                    generator = new QueryGenerator(JOB);
+                    generator.setParameter(JobConstants.JOB_ID, name);
+                    generator.setParameter(JobConstants.TASK_ID, taskId);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
                 default:
                     logger.error("Unsupported resource type for job details resource.", new
IllegalArgumentException());
                     break;
@@ -206,6 +216,21 @@ public class TaskResource extends AbstractExpCatResource {
                         em.close();
                     }
                     return errorResource;
+                case JOB:
+                    generator = new QueryGenerator(JOB);
+                    generator.setParameter(JobConstants.JOB_ID, name);
+                    generator.setParameter(JobConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    Job job = (Job) q.getSingleResult();
+                    JobResource jobResource = (JobResource) Utils.getResource(ResourceType.JOB,
job);
+                    em.getTransaction().commit();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
+                    return jobResource;
                 default:
                     em.getTransaction().commit();
                     if (em.isOpen()) {
@@ -269,6 +294,20 @@ public class TaskResource extends AbstractExpCatResource {
                         }
                     }
                     break;
+                case JOB:
+                    generator = new QueryGenerator(JOB);
+                    generator.setParameter(JobConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Job job = (Job) result;
+                            JobResource jobResource =
+                                    (JobResource) Utils.getResource(ResourceType.JOB, job);
+                            resourceList.add(jobResource);
+                        }
+                    }
+                    break;
                 default:
                     logger.error("Unsupported resource type for task resource.", new UnsupportedOperationException());
                     throw new UnsupportedOperationException();
@@ -397,4 +436,18 @@ public class TaskResource extends AbstractExpCatResource {
             return max;
         }
     }
+
+    public JobResource getJob(String jobId) throws RegistryException {
+        return (JobResource) get(ResourceType.JOB, jobId);
+    }
+
+    public List<JobResource> getJobList() throws RegistryException {
+        List<JobResource> jobResources = new ArrayList();
+        List<ExperimentCatResource> resources = get(ResourceType.JOB);
+        for (ExperimentCatResource resource : resources) {
+            JobResource jobResource = (JobResource) resource;
+            jobResources.add(jobResource);
+        }
+        return jobResources;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
index 6e27462..8a1a79e 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
@@ -682,6 +682,7 @@ public class Utils {
             jobStatusResource.setJobId(o.getJobId());
 	        jobStatusResource.setStatusId(o.getStatusId());
 	        jobStatusResource.setProcessId(o.getProcessId());
+	        jobStatusResource.setTaskId(o.getTaskId());
 	        jobStatusResource.setState(o.getState());
             jobStatusResource.setTimeOfStateChange(o.getTimeOfStateChange());
             jobStatusResource.setReason(o.getReason());

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql b/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
index 02d02fb..0e91c7b 100644
--- a/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
+++ b/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
@@ -311,19 +311,20 @@ CREATE TABLE JOB (
   STD_OUT CLOB,
   STD_ERR CLOB,
   EXIT_CODE INT,
-  PRIMARY KEY (JOB_ID, PROCESS_ID),
-  FOREIGN KEY (PROCESS_ID) REFERENCES PROCESS(PROCESS_ID) ON DELETE CASCADE
+  PRIMARY KEY (JOB_ID, TASK_ID),
+  FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE JOB_STATUS (
   STATUS_ID varchar(255),
   JOB_ID varchar(255),
   PROCESS_ID varchar(255),
+  TASK_ID varchar(255),
   STATE varchar(255),
   TIME_OF_STATE_CHANGE  timestamp DEFAULT '0000-00-00 00:00:00',
   REASON CLOB,
-  PRIMARY KEY (STATUS_ID, JOB_ID, PROCESS_ID),
-  FOREIGN KEY (JOB_ID, PROCESS_ID) REFERENCES JOB(JOB_ID, PROCESS_ID) ON DELETE CASCADE
+  PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID),
+  FOREIGN KEY (JOB_ID, TASK_ID) REFERENCES JOB(JOB_ID, TASK_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE CONFIGURATION

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
index 629745d..b2795c8 100644
--- a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
+++ b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
@@ -311,19 +311,20 @@ CREATE TABLE JOB (
   STD_OUT LONGTEXT,
   STD_ERR LONGTEXT,
   EXIT_CODE INT(11),
-  PRIMARY KEY (JOB_ID, PROCESS_ID),
-  FOREIGN KEY (PROCESS_ID) REFERENCES PROCESS(PROCESS_ID) ON DELETE CASCADE
+  PRIMARY KEY (JOB_ID, TASK_ID),
+  FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE JOB_STATUS (
   STATUS_ID varchar(255),
   JOB_ID varchar(255),
   PROCESS_ID varchar(255),
+  TASK_ID varchar(255),
   STATE varchar(255),
   TIME_OF_STATE_CHANGE timestamp DEFAULT '0000-00-00 00:00:00',
   REASON LONGTEXT,
-  PRIMARY KEY (STATUS_ID, JOB_ID, PROCESS_ID),
-  FOREIGN KEY (JOB_ID, PROCESS_ID) REFERENCES JOB(JOB_ID, PROCESS_ID) ON DELETE CASCADE
+  PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID),
+  FOREIGN KEY (JOB_ID, TASK_ID) REFERENCES JOB(JOB_ID, TASK_ID) ON DELETE CASCADE
 );
 
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql b/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
index 02d02fb..0e91c7b 100644
--- a/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
+++ b/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
@@ -311,19 +311,20 @@ CREATE TABLE JOB (
   STD_OUT CLOB,
   STD_ERR CLOB,
   EXIT_CODE INT,
-  PRIMARY KEY (JOB_ID, PROCESS_ID),
-  FOREIGN KEY (PROCESS_ID) REFERENCES PROCESS(PROCESS_ID) ON DELETE CASCADE
+  PRIMARY KEY (JOB_ID, TASK_ID),
+  FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE JOB_STATUS (
   STATUS_ID varchar(255),
   JOB_ID varchar(255),
   PROCESS_ID varchar(255),
+  TASK_ID varchar(255),
   STATE varchar(255),
   TIME_OF_STATE_CHANGE  timestamp DEFAULT '0000-00-00 00:00:00',
   REASON CLOB,
-  PRIMARY KEY (STATUS_ID, JOB_ID, PROCESS_ID),
-  FOREIGN KEY (JOB_ID, PROCESS_ID) REFERENCES JOB(JOB_ID, PROCESS_ID) ON DELETE CASCADE
+  PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID),
+  FOREIGN KEY (JOB_ID, TASK_ID) REFERENCES JOB(JOB_ID, TASK_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE CONFIGURATION

http://git-wip-us.apache.org/repos/asf/airavata/blob/b442e0c3/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
index c4f4d15..581cdae 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
@@ -82,6 +82,7 @@ public class Constants {
         public final class JobConstants {
             public static final String JOB_ID = "jobId";
             public static final String PROCESS_ID = "processId";
+            public static final String TASK_ID = "taskId";
             public static final String JOB_STATUS = "taskStatus";
         }
     }


Mime
View raw message