You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/20 23:01:56 UTC
[05/11] airavata git commit: minor modifications for the experiment
registry model and resources layer
minor modifications for the experiment registry model and resources layer
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/066030bc
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/066030bc
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/066030bc
Branch: refs/heads/master
Commit: 066030bc53f00d3378655f0cda50ec5bfbf6c924
Parents: 3a00366
Author: Supun Nakandala <sc...@apache.org>
Authored: Sat Jun 20 18:18:00 2015 +0530
Committer: Supun Nakandala <sc...@apache.org>
Committed: Sat Jun 20 18:18:00 2015 +0530
----------------------------------------------------------------------
.../catalog/model/ExperimentInputPK.java | 7 +-
.../catalog/model/ExperimentOutputPK.java | 5 +-
.../catalog/model/ExperimentStatusPK.java | 4 +-
.../catalog/model/ExperimentSummary.java | 7 +-
.../catalog/model/GatewayWorkerPK.java | 5 +-
.../catalog/model/ProcessErrorPK.java | 4 +-
.../catalog/model/ProcessInputPK.java | 7 +-
.../catalog/model/ProcessOutputPK.java | 5 +-
.../catalog/model/ProcessStatusPK.java | 5 +-
.../experiment/catalog/model/ProjectUserPK.java | 4 +-
.../experiment/catalog/model/TaskStatusPK.java | 4 +-
.../resources/AbstractExpCatResource.java | 4 +
.../resources/ExperimentErrorResource.java | 10 +-
.../resources/ExperimentInputResource.java | 17 +--
.../catalog/resources/ExperimentResource.java | 76 ++++++++--
.../resources/ExperimentStatusResource.java | 19 ++-
.../catalog/resources/ProcessErrorResource.java | 10 +-
.../catalog/resources/ProcessInputResource.java | 15 +-
.../catalog/resources/ProcessResource.java | 88 ++++++++++-
.../resources/ProcessStatusResource.java | 19 ++-
.../catalog/resources/TaskErrorResource.java | 11 +-
.../catalog/resources/TaskResource.java | 152 +++++++++++++++----
.../catalog/resources/TaskStatusResource.java | 19 ++-
23 files changed, 373 insertions(+), 124 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentInputPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentInputPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentInputPK.java
index c84b541..1db370e 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentInputPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentInputPK.java
@@ -23,7 +23,6 @@ package org.apache.airavata.registry.core.experiment.catalog.model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
@@ -33,9 +32,8 @@ public class ExperimentInputPK implements Serializable {
private String experimentId;
private String inputName;
- @Column(name = "EXPERIMENT_ID")
- @Basic
@Id
+ @Column(name = "EXPERIMENT_ID")
public String getExperimentId() {
return experimentId;
}
@@ -44,9 +42,8 @@ public class ExperimentInputPK implements Serializable {
this.experimentId = experimentId;
}
- @Column(name = "INPUT_NAME")
- @Basic
@Id
+ @Column(name = "INPUT_NAME")
public String getInputName() {
return inputName;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentOutputPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentOutputPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentOutputPK.java
index 08285c1..ac52859 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentOutputPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentOutputPK.java
@@ -33,9 +33,8 @@ public class ExperimentOutputPK implements Serializable {
private String experimentId;
private String outputName;
- @Column(name = "EXPERIMENT_ID")
- @Basic
@Id
+ @Column(name = "EXPERIMENT_ID")
public String getExperimentId() {
return experimentId;
}
@@ -44,8 +43,8 @@ public class ExperimentOutputPK implements Serializable {
this.experimentId = experimentId;
}
- @Column(name = "OUTPUT_NAME")
@Id
+ @Column(name = "OUTPUT_NAME")
public String getOutputName() {
return outputName;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentStatusPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentStatusPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentStatusPK.java
index de17178..98d928d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentStatusPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentStatusPK.java
@@ -32,8 +32,8 @@ public class ExperimentStatusPK implements Serializable {
private String statusId;
private String experimentId;
- @Column(name = "STATUS_ID")
@Id
+ @Column(name = "STATUS_ID")
public String getStatusId() {
return statusId;
}
@@ -42,8 +42,8 @@ public class ExperimentStatusPK implements Serializable {
this.statusId = statusId;
}
- @Column(name = "EXPERIMENT_ID")
@Id
+ @Column(name = "EXPERIMENT_ID")
public String getExperimentId() {
return experimentId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentSummary.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentSummary.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentSummary.java
index 0323d01..bc88d93 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentSummary.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ExperimentSummary.java
@@ -23,10 +23,7 @@ package org.apache.airavata.registry.core.experiment.catalog.model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
+import javax.persistence.*;
import java.sql.Timestamp;
@Entity
@@ -44,7 +41,7 @@ public class ExperimentSummary {
private String resourceHostId;
private Timestamp timeOfStateChange;
- @Basic
+ @Id
@Column(name = "EXPERIMENT_ID")
public String getExperimentId() {
return experimentId;
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/GatewayWorkerPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/GatewayWorkerPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/GatewayWorkerPK.java
index 449f890..1820042 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/GatewayWorkerPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/GatewayWorkerPK.java
@@ -32,8 +32,8 @@ public class GatewayWorkerPK implements Serializable {
private String gatewayId;
private String userName;
- @Column(name = "GATEWAY_ID")
@Id
+ @Column(name = "GATEWAY_ID")
public String getGatewayId() {
return gatewayId;
}
@@ -42,8 +42,9 @@ public class GatewayWorkerPK implements Serializable {
this.gatewayId = gatewayId;
}
- @Column(name = "USER_NAME")
+
@Id
+ @Column(name = "USER_NAME")
public String getUserName() {
return userName;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessErrorPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessErrorPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessErrorPK.java
index c335016..5dd05dc 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessErrorPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessErrorPK.java
@@ -32,8 +32,8 @@ public class ProcessErrorPK implements Serializable {
private String errorId;
private String processId;
- @Column(name = "ERROR_ID")
@Id
+ @Column(name = "ERROR_ID")
public String getErrorId() {
return errorId;
}
@@ -42,8 +42,8 @@ public class ProcessErrorPK implements Serializable {
this.errorId = errorId;
}
- @Column(name = "PROCESS_ID")
@Id
+ @Column(name = "PROCESS_ID")
public String getProcessId() {
return processId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessInputPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessInputPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessInputPK.java
index 8731d36..6650e07 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessInputPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessInputPK.java
@@ -23,7 +23,6 @@ package org.apache.airavata.registry.core.experiment.catalog.model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
@@ -33,9 +32,8 @@ public class ProcessInputPK implements Serializable {
private String processId;
private String inputName;
- @Column(name = "PROCESS_ID")
- @Basic
@Id
+ @Column(name = "PROCESS_ID")
public String getProcessId() {
return processId;
}
@@ -44,9 +42,8 @@ public class ProcessInputPK implements Serializable {
this.processId = processId;
}
- @Column(name = "INPUT_NAME")
- @Basic
@Id
+ @Column(name = "INPUT_NAME")
public String getInputName() {
return inputName;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessOutputPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessOutputPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessOutputPK.java
index 5a64b86..0d98d4d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessOutputPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessOutputPK.java
@@ -33,9 +33,8 @@ public class ProcessOutputPK implements Serializable {
private String processId;
private String outputName;
- @Column(name = "PROCESS_ID")
- @Basic
@Id
+ @Column(name = "PROCESS_ID")
public String getProcessId() {
return processId;
}
@@ -44,8 +43,8 @@ public class ProcessOutputPK implements Serializable {
this.processId = processId;
}
- @Column(name = "OUTPUT_NAME")
@Id
+ @Column(name = "OUTPUT_NAME")
public String getOutputName() {
return outputName;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessStatusPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessStatusPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessStatusPK.java
index a57a4d8..3158e15 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessStatusPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProcessStatusPK.java
@@ -32,8 +32,9 @@ public class ProcessStatusPK implements Serializable {
private String statusId;
private String processId;
- @Column(name = "STATUS_ID")
+
@Id
+ @Column(name = "STATUS_ID")
public String getStatusId() {
return statusId;
}
@@ -42,8 +43,8 @@ public class ProcessStatusPK implements Serializable {
this.statusId = statusId;
}
- @Column(name = "PROCESS_ID")
@Id
+ @Column(name = "PROCESS_ID")
public String getProcessId() {
return processId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProjectUserPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProjectUserPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProjectUserPK.java
index 5cf3364..2d32627 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProjectUserPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/ProjectUserPK.java
@@ -32,8 +32,8 @@ public class ProjectUserPK implements Serializable {
private String projectId;
private String userName;
- @Column(name = "PROJECT_ID")
@Id
+ @Column(name = "PROJECT_ID")
public String getProjectId() {
return projectId;
}
@@ -42,8 +42,8 @@ public class ProjectUserPK implements Serializable {
this.projectId = projectId;
}
- @Column(name = "USER_NAME")
@Id
+ @Column(name = "USER_NAME")
public String getUserName() {
return userName;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/TaskStatusPK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/TaskStatusPK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/TaskStatusPK.java
index 3855294..502852b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/TaskStatusPK.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/model/TaskStatusPK.java
@@ -32,8 +32,8 @@ public class TaskStatusPK implements Serializable {
private String statusId;
private String taskId;
- @Column(name = "STATUS_ID")
@Id
+ @Column(name = "STATUS_ID")
public String getStatusId() {
return statusId;
}
@@ -42,8 +42,8 @@ public class TaskStatusPK implements Serializable {
this.statusId = statusId;
}
- @Column(name = "TASK_ID")
@Id
+ @Column(name = "TASK_ID")
public String getTaskId() {
return taskId;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/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 875240c..8faf1aa 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
@@ -127,6 +127,7 @@ public abstract class AbstractExpCatResource implements ExperimentCatResource {
//Experiment Error table
public final class ExperimentErrorConstants {
+ public static final String ERROR_ID = "errorId";
public static final String EXPERIMENT_ID = "experimentId";
public static final String CREATION_TIME = "creationTime";
public static final String ACTUAL_ERROR_MESSAGE = "actualErrorMsg";
@@ -213,6 +214,7 @@ public abstract class AbstractExpCatResource implements ExperimentCatResource {
// Task Status table
public final class TaskStatusConstants {
+ public static final String STATUS_ID = "statusId";
public static final String TASK_ID = "taskId";
public static final String STATE = "state";
public static final String TIME_OF_STATE_CHANGE = "timeOfStateChange";
@@ -221,6 +223,7 @@ public abstract class AbstractExpCatResource implements ExperimentCatResource {
// Process Status table
public final class ProcessStatusConstants {
+ public static final String STATUS_ID = "statusId";
public static final String PROCESS_ID = "processId";
public static final String STATE = "state";
public static final String TIME_OF_STATE_CHANGE = "timeOfStateChange";
@@ -229,6 +232,7 @@ public abstract class AbstractExpCatResource implements ExperimentCatResource {
// Experiment Status table
public final class ExperimentStatusConstants {
+ public static final String STATUS_ID = "statusId";
public static final String EXPERIMENT_ID = "experimentId";
public static final String STATE = "state";
public static final String TIME_OF_STATE_CHANGE = "timeOfStateChange";
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentErrorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentErrorResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentErrorResource.java
index b07bd82..1a35455 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentErrorResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentErrorResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentError;
+import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentErrorPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -129,10 +130,13 @@ public class ExperimentErrorResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
ExperimentError experimentError;
- if(experimentId == null || actualErrorMessage == null){
- throw new RegistryException("Does not have the experiment id or error message");
+ if(experimentId == null || errorId == null){
+ throw new RegistryException("Does not have the experiment id or error id");
}
- experimentError = em.find(ExperimentError.class, experimentId);
+ ExperimentErrorPK experimentErrorPK = new ExperimentErrorPK();
+ experimentErrorPK.setExperimentId(experimentId);
+ experimentErrorPK.setErrorId(errorId);
+ experimentError = em.find(ExperimentError.class, experimentErrorPK);
if(experimentError == null){
experimentError = new ExperimentError();
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
index 3415b2b..5c6524d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentInput;
+import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentInputPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +35,6 @@ import java.util.List;
public class ExperimentInputResource extends AbstractExpCatResource {
private static final Logger logger = LoggerFactory.getLogger(ExperimentInputResource.class);
- private int experimentInputId;
private String experimentId;
private String inputName;
private String inputValue;
@@ -48,14 +48,6 @@ public class ExperimentInputResource extends AbstractExpCatResource {
private Boolean requiredToAddedToCmd;
private Boolean dataStaged;
- public int getExperimentInputId() {
- return experimentInputId;
- }
-
- public void setExperimentInputId(int experimentInputId) {
- this.experimentInputId = experimentInputId;
- }
-
public String getExperimentId() {
return experimentId;
}
@@ -185,11 +177,13 @@ public class ExperimentInputResource extends AbstractExpCatResource {
throw new RegistryException("Does not have the experiment id");
}
ExperimentInput experimentInput;
- experimentInput = em.find(ExperimentInput.class, experimentInputId);
+ ExperimentInputPK experimentInputPK = new ExperimentInputPK();
+ experimentInputPK.setExperimentId(experimentId);
+ experimentInputPK.setInputName(inputName);
+ experimentInput = em.find(ExperimentInput.class, experimentInputPK);
if(experimentInput == null){
experimentInput = new ExperimentInput();
}
- experimentInput.setExperimentInputId(experimentInputId);
experimentInput.setExperimentId(experimentId);
experimentInput.setInputName(inputName);
experimentInput.setInputValue(inputValue);
@@ -205,7 +199,6 @@ public class ExperimentInputResource extends AbstractExpCatResource {
em.persist(experimentInput);
em.getTransaction().commit();
em.close();
- this.experimentInputId = experimentInput.getExperimentInputId();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RegistryException(e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
index 8ca7c05..26a1ea1 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
@@ -191,13 +191,15 @@ public class ExperimentResource extends AbstractExpCatResource {
switch (type) {
case EXPERIMENT_ERROR:
generator = new QueryGenerator(EXPERIMENT_ERROR);
- generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, name);
+ generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, experimentId);
+ generator.setParameter(ExperimentErrorConstants.ERROR_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case EXPERIMENT_STATUS:
generator = new QueryGenerator(EXPERIMENT_STATUS);
- generator.setParameter(ExperimentStatusConstants.EXPERIMENT_ID, name);
+ generator.setParameter(ExperimentStatusConstants.EXPERIMENT_ID, experimentId);
+ generator.setParameter(ExperimentStatusConstants.STATUS_ID, name);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
@@ -258,7 +260,8 @@ public class ExperimentResource extends AbstractExpCatResource {
switch (type) {
case EXPERIMENT_STATUS:
generator = new QueryGenerator(EXPERIMENT_STATUS);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ generator.setParameter(ExperimentStatusConstants.STATUS_ID, name);
+ generator.setParameter(ExperimentStatusConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
ExperimentStatus status = (ExperimentStatus) q.getSingleResult();
ExperimentStatusResource statusResource = (ExperimentStatusResource) Utils.getResource(ResourceType.EXPERIMENT_STATUS, status);
@@ -267,7 +270,8 @@ public class ExperimentResource extends AbstractExpCatResource {
return statusResource;
case EXPERIMENT_ERROR:
generator = new QueryGenerator(EXPERIMENT_ERROR);
- generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, name);
+ generator.setParameter(ExperimentErrorConstants.ERROR_ID, name);
+ generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
ExperimentError experimentError = (ExperimentError) q.getSingleResult();
ExperimentErrorResource processErrorResource = (ExperimentErrorResource) Utils.getResource(ResourceType.EXPERIMENT_ERROR, experimentError);
@@ -384,17 +388,31 @@ public class ExperimentResource extends AbstractExpCatResource {
}
}
break;
- case PROCESS_ERROR:
+ case EXPERIMENT_ERROR:
generator = new QueryGenerator(EXPERIMENT_ERROR);
generator.setParameter(ExperimentErrorConstants.EXPERIMENT_ID, experimentId);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
- ProcessError processError = (ProcessError) result;
- ProcessErrorResource processErrorResource =
- (ProcessErrorResource) Utils.getResource(ResourceType.PROCESS_ERROR, processError);
- resourceList.add(processErrorResource);
+ ExperimentError experimentError = (ExperimentError) result;
+ ExperimentErrorResource experimentErrorResource =
+ (ExperimentErrorResource) Utils.getResource(ResourceType.EXPERIMENT_ERROR, experimentError);
+ resourceList.add(experimentErrorResource);
+ }
+ }
+ break;
+ case EXPERIMENT_STATUS:
+ generator = new QueryGenerator(EXPERIMENT_STATUS);
+ generator.setParameter(ExperimentStatusConstants.EXPERIMENT_ID, experimentId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ExperimentStatus experimentStatus = (ExperimentStatus) result;
+ ExperimentStatusResource experimentStatusResource =
+ (ExperimentStatusResource) Utils.getResource(ResourceType.EXPERIMENT_STATUS, experimentStatus);
+ resourceList.add(experimentStatusResource);
}
}
break;
@@ -424,6 +442,7 @@ public class ExperimentResource extends AbstractExpCatResource {
EntityManager em = null;
try {
em = ExpCatResourceUtils.getEntityManager();
+
Experiment experiment = em.find(Experiment.class, experimentId);
em.close();
em = ExpCatResourceUtils.getEntityManager();
@@ -478,9 +497,29 @@ public class ExperimentResource extends AbstractExpCatResource {
return outputResources;
}
+ public List<ExperimentStatusResource> getExperimentStatuses() throws RegistryException{
+ List<ExperimentStatusResource> experimentStatusResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_STATUS);
+ for (ExperimentCatResource resource : resources) {
+ ExperimentStatusResource statusResource = (ExperimentStatusResource) resource;
+ experimentStatusResources.add(statusResource);
+ }
+ return experimentStatusResources;
+ }
+
public ExperimentStatusResource getExperimentStatus() throws RegistryException{
- ExperimentCatResource resource = get(ResourceType.EXPERIMENT_STATUS, executionId);
- return (ExperimentStatusResource)resource;
+ List<ExperimentStatusResource> experimentStatusResources = getExperimentStatuses();
+ if(experimentStatusResources.size() == 0){
+ return null;
+ }else{
+ ExperimentStatusResource max = experimentStatusResources.get(0);
+ for(int i=1; i<experimentStatusResources.size();i++){
+ if(experimentStatusResources.get(i).getTimeOfStateChange().after(max.getTimeOfStateChange())){
+ max = experimentStatusResources.get(i);
+ }
+ }
+ return max;
+ }
}
public List<ExperimentErrorResource> getExperimentErrors() throws RegistryException{
@@ -493,6 +532,21 @@ public class ExperimentResource extends AbstractExpCatResource {
return experimentErrorResources;
}
+ public ExperimentErrorResource getExperimentError() throws RegistryException{
+ List<ExperimentErrorResource> experimentErrorResources = getExperimentErrors();
+ if(experimentErrorResources.size() == 0){
+ return null;
+ }else{
+ ExperimentErrorResource max = experimentErrorResources.get(0);
+ for(int i=1; i<experimentErrorResources.size();i++){
+ if(experimentErrorResources.get(i).getCreationTime().after(max.getCreationTime())){
+ max = experimentErrorResources.get(i);
+ }
+ }
+ return max;
+ }
+ }
+
public UserConfigurationDataResource getUserConfigurationDataResource() throws RegistryException{
ExperimentCatResource resource = get(ResourceType.USER_CONFIGURATION_DATA, experimentId);
return (UserConfigurationDataResource)resource;
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
index 53ef1da..558762e 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentStatus;
+import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentStatusPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,11 +36,20 @@ import java.util.List;
public class ExperimentStatusResource extends AbstractExpCatResource {
private static final Logger logger = LoggerFactory.getLogger(ExperimentStatusResource.class);
+ private String statusId;
private String experimentId;
private String state;
private Timestamp timeOfStateChange;
private String reason;
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
public String getExperimentId() {
return experimentId;
}
@@ -102,10 +112,13 @@ public class ExperimentStatusResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
ExperimentStatus experimentStatus;
- if(experimentId == null || state == null){
- throw new RegistryException("Does not have the experiment id or state");
+ if(experimentId == null || statusId == null){
+ throw new RegistryException("Does not have the experiment id or status id");
}
- experimentStatus = em.find(ExperimentStatus.class, experimentId);
+ ExperimentStatusPK experimentStatusPK = new ExperimentStatusPK();
+ experimentStatusPK.setStatusId(statusId);
+ experimentStatusPK.setExperimentId(experimentId);
+ experimentStatus = em.find(ExperimentStatus.class, experimentStatusPK);
if(experimentStatus == null){
experimentStatus = new ExperimentStatus();
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
index 343b6e4..127b4c0 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.ProcessError;
+import org.apache.airavata.registry.core.experiment.catalog.model.ProcessErrorPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -129,10 +130,13 @@ public class ProcessErrorResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
ProcessError processError;
- if(processId == null || actualErrorMessage == null){
- throw new RegistryException("Does not have the process id or error message");
+ if(processId == null || errorId == null){
+ throw new RegistryException("Does not have the process id or error id");
}
- processError = em.find(ProcessError.class, processId);
+ ProcessErrorPK processErrorPK = new ProcessErrorPK();
+ processErrorPK.setProcessId(processId);
+ processErrorPK.setErrorId(errorId);
+ processError = em.find(ProcessError.class, processErrorPK);
if(processError == null){
processError = new ProcessError();
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
index 6da7297..5a1eff9 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.ProcessInput;
+import org.apache.airavata.registry.core.experiment.catalog.model.ProcessInputPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +35,6 @@ import java.util.List;
public class ProcessInputResource extends AbstractExpCatResource {
private static final Logger logger = LoggerFactory.getLogger(ProcessInputResource.class);
- private int processInputId;
private String processId;
private String inputName;
private String inputValue;
@@ -48,14 +48,6 @@ public class ProcessInputResource extends AbstractExpCatResource {
private Boolean requiredToAddedToCmd;
private Boolean dataStaged;
- public int getProcessInputId() {
- return processInputId;
- }
-
- public void setProcessInputId(int processInputId) {
- this.processInputId = processInputId;
- }
-
public String getProcessId() {
return processId;
}
@@ -185,7 +177,10 @@ public class ProcessInputResource extends AbstractExpCatResource {
throw new RegistryException("Does not have the process id");
}
ProcessInput processInput;
- processInput = em.find(ProcessInput.class, processInputId);
+ ProcessInputPK processInputPk = new ProcessInputPK();
+ processInputPk.setProcessId(processId);
+ processInputPk.setInputName(inputName);
+ processInput = em.find(ProcessInput.class, processInputPk);
if(processInput == null){
processInput = new ProcessInput();
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
index 6faed3c..e162d45 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
@@ -146,13 +146,15 @@ public class ProcessResource extends AbstractExpCatResource {
switch (type) {
case PROCESS_ERROR:
generator = new QueryGenerator(PROCESS_ERROR);
- generator.setParameter(ProcessErrorConstants.PROCESS_ID, name);
+ generator.setParameter(ProcessErrorConstants.ERROR_ID, name);
+ generator.setParameter(ProcessErrorConstants.PROCESS_ID, processId);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case PROCESS_STATUS:
generator = new QueryGenerator(PROCESS_STATUS);
- generator.setParameter(ProcessStatusConstants.PROCESS_ID, name);
+ generator.setParameter(ProcessStatusConstants.STATUS_ID, name);
+ generator.setParameter(ProcessStatusConstants.PROCESS_ID, processId);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
@@ -213,7 +215,8 @@ public class ProcessResource extends AbstractExpCatResource {
switch (type) {
case PROCESS_STATUS:
generator = new QueryGenerator(PROCESS_STATUS);
- generator.setParameter(ProcessStatusConstants.PROCESS_ID, name);
+ generator.setParameter(ProcessStatusConstants.STATUS_ID, name);
+ generator.setParameter(ProcessStatusConstants.PROCESS_ID, processId);
q = generator.selectQuery(em);
ProcessStatus status = (ProcessStatus) q.getSingleResult();
ProcessStatusResource statusResource = (ProcessStatusResource) Utils.getResource(ResourceType.PROCESS_STATUS, status);
@@ -222,7 +225,8 @@ public class ProcessResource extends AbstractExpCatResource {
return statusResource;
case PROCESS_ERROR:
generator = new QueryGenerator(PROCESS_ERROR);
- generator.setParameter(ProcessErrorConstants.PROCESS_ID, name);
+ generator.setParameter(ProcessErrorConstants.ERROR_ID, name);
+ generator.setParameter(ProcessErrorConstants.PROCESS_ID, processId);
q = generator.selectQuery(em);
ProcessError processError = (ProcessError) q.getSingleResult();
ProcessErrorResource processErrorResource = (ProcessErrorResource) Utils.getResource(ResourceType.PROCESS_ERROR, processError);
@@ -340,6 +344,34 @@ public class ProcessResource extends AbstractExpCatResource {
}
}
break;
+ case PROCESS_ERROR:
+ generator = new QueryGenerator(PROCESS_ERROR);
+ generator.setParameter(ProcessErrorConstants.PROCESS_ID, processId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ProcessError processError = (ProcessError) result;
+ ProcessErrorResource processErrorResource =
+ (ProcessErrorResource) Utils.getResource(ResourceType.PROCESS_ERROR, processError);
+ resourceList.add(processErrorResource);
+ }
+ }
+ break;
+ case PROCESS_STATUS:
+ generator = new QueryGenerator(PROCESS_STATUS);
+ generator.setParameter(ProcessStatusConstants.PROCESS_ID, processId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ProcessStatus processStatus = (ProcessStatus) result;
+ ProcessStatusResource processStatusResource =
+ (ProcessStatusResource) Utils.getResource(ResourceType.PROCESS_STATUS, processStatus);
+ resourceList.add(processStatusResource);
+ }
+ }
+ break;
default:
em.getTransaction().commit();
em.close();
@@ -416,14 +448,54 @@ public class ProcessResource extends AbstractExpCatResource {
return outputResources;
}
+ public List<ProcessStatusResource> getProcessStatuses() throws RegistryException{
+ List<ProcessStatusResource> processStatusResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.PROCESS_STATUS);
+ for (ExperimentCatResource resource : resources) {
+ ProcessStatusResource statusResource = (ProcessStatusResource) resource;
+ processStatusResources.add(statusResource);
+ }
+ return processStatusResources;
+ }
+
public ProcessStatusResource getProcessStatus() throws RegistryException{
- ExperimentCatResource resource = get(ResourceType.PROCESS_STATUS, processId);
- return (ProcessStatusResource)resource;
+ List<ProcessStatusResource> processStatusResources = getProcessStatuses();
+ if(processStatusResources.size() == 0){
+ return null;
+ }else{
+ ProcessStatusResource max = processStatusResources.get(0);
+ for(int i=1; i<processStatusResources.size();i++){
+ if(processStatusResources.get(i).getTimeOfStateChange().after(max.getTimeOfStateChange())){
+ max = processStatusResources.get(i);
+ }
+ }
+ return max;
+ }
+ }
+
+ public List<ProcessErrorResource> getProcessErrors() throws RegistryException{
+ List<ProcessErrorResource> processErrorResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.PROCESS_ERROR);
+ for (ExperimentCatResource resource : resources) {
+ ProcessErrorResource errorResource = (ProcessErrorResource) resource;
+ processErrorResources.add(errorResource);
+ }
+ return processErrorResources;
}
public ProcessErrorResource getProcessError() throws RegistryException{
- ExperimentCatResource resource = get(ResourceType.PROCESS_ERROR, processId);
- return (ProcessErrorResource)resource;
+ List<ProcessErrorResource> processErrorResources = getProcessErrors();
+ if(processErrorResources.size() == 0){
+ return null;
+ }else{
+ ProcessErrorResource max = processErrorResources.get(0);
+ for(int i=1; i<processErrorResources.size();i++){
+ if(processErrorResources.get(i).getCreationTime().after(max.getCreationTime())){
+ max = processErrorResources.get(i);
+ }
+ }
+ return max;
+ }
}
public ProcessResourceScheduleResource getProcessResourceSchedule() throws RegistryException{
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
index 4ae5298..6892510 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.ProcessStatus;
+import org.apache.airavata.registry.core.experiment.catalog.model.ProcessStatusPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,11 +36,20 @@ import java.util.List;
public class ProcessStatusResource extends AbstractExpCatResource {
private static final Logger logger = LoggerFactory.getLogger(ProcessStatusResource.class);
+ private String statusId;
private String processId;
private String state;
private Timestamp timeOfStateChange;
private String reason;
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
public String getProcessId() {
return processId;
}
@@ -102,10 +112,13 @@ public class ProcessStatusResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
ProcessStatus processStatus;
- if(processId == null || state == null){
- throw new RegistryException("Does not have the process id or state");
+ if(processId == null || statusId == null){
+ throw new RegistryException("Does not have the process id or status id");
}
- processStatus = em.find(ProcessStatus.class, processId);
+ ProcessStatusPK processStatusPK = new ProcessStatusPK();
+ processStatusPK.setStatusId(statusId);
+ processStatusPK.setProcessId(processId);
+ processStatus = em.find(ProcessStatus.class, processStatusPK);
if(processStatus == null){
processStatus = new ProcessStatus();
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
index b57a348..b8239c4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.TaskError;
+import org.apache.airavata.registry.core.experiment.catalog.model.TaskErrorPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -129,13 +130,17 @@ public class TaskErrorResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
TaskError taskError;
- if(taskId == null || actualErrorMessage == null){
- throw new RegistryException("Does not have the task id or error message");
+ if(taskId == null || errorId == null){
+ throw new RegistryException("Does not have the task id or error id");
}
- taskError = em.find(TaskError.class, taskId);
+ TaskErrorPK taskErrorPK = new TaskErrorPK();
+ taskErrorPK.setTaskId(taskId);
+ taskErrorPK.setErrorId(errorId);
+ taskError = em.find(TaskError.class, taskErrorPK);
if(taskError == null){
taskError = new TaskError();
}
+
taskError.setTaskId(taskId);
taskError.setActualErrorMessage(actualErrorMessage);
taskError.setUserFriendlyMessage(userFriendlyMessage);
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/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 01a0a9c..862c2a4 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
@@ -35,6 +35,7 @@ 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 TaskResource extends AbstractExpCatResource {
@@ -130,13 +131,15 @@ public class TaskResource extends AbstractExpCatResource {
switch (type) {
case TASK_STATUS:
generator = new QueryGenerator(TASK_STATUS);
- generator.setParameter(TaskStatusConstants.TASK_ID, name);
+ generator.setParameter(TaskStatusConstants.STATUS_ID, name);
+ generator.setParameter(TaskStatusConstants.TASK_ID, taskId);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
case TASK_ERROR:
generator = new QueryGenerator(TASK_ERROR);
- generator.setParameter(TaskErrorConstants.TASK_ID, name);
+ generator.setParameter(TaskErrorConstants.ERROR_ID, name);
+ generator.setParameter(TaskErrorConstants.TASK_ID, taskId);
q = generator.deleteQuery(em);
q.executeUpdate();
break;
@@ -170,7 +173,8 @@ public class TaskResource extends AbstractExpCatResource {
switch (type) {
case TASK_STATUS:
generator = new QueryGenerator(TASK_STATUS);
- generator.setParameter(TaskStatusConstants.TASK_ID, name);
+ generator.setParameter(TaskStatusConstants.STATUS_ID, name);
+ generator.setParameter(TaskStatusConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
TaskStatus status = (TaskStatus) q.getSingleResult();
TaskStatusResource statusResource = (TaskStatusResource) Utils.getResource(ResourceType.TASK_STATUS, status);
@@ -180,6 +184,7 @@ public class TaskResource extends AbstractExpCatResource {
case TASK_ERROR:
generator = new QueryGenerator(TASK_ERROR);
generator.setParameter(TaskErrorConstants.ERROR_ID, name);
+ generator.setParameter(TaskErrorConstants.TASK_ID, taskId);
q = generator.selectQuery(em);
TaskError error = (TaskError) q.getSingleResult();
TaskErrorResource errorResource = (TaskErrorResource) Utils.getResource(
@@ -209,8 +214,63 @@ public class TaskResource extends AbstractExpCatResource {
public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for task resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ List results;
+ switch (type) {
+ case TASK_ERROR:
+ generator = new QueryGenerator(TASK_ERROR);
+ generator.setParameter(TaskErrorConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ TaskError taskError = (TaskError) result;
+ TaskErrorResource taskErrorResource =
+ (TaskErrorResource) Utils.getResource(ResourceType.TASK_ERROR, taskError);
+ resourceList.add(taskErrorResource);
+ }
+ }
+ break;
+ case TASK_STATUS:
+ generator = new QueryGenerator(TASK_STATUS);
+ generator.setParameter(TaskStatusConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ TaskStatus taskStatus = (TaskStatus) result;
+ TaskStatusResource taskStatusResource =
+ (TaskStatusResource) Utils.getResource(ResourceType.TASK_STATUS, taskStatus);
+ resourceList.add(taskStatusResource);
+ }
+ }
+ break;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for task resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
}
@@ -218,30 +278,22 @@ public class TaskResource extends AbstractExpCatResource {
EntityManager em = null;
try {
em = ExpCatResourceUtils.getEntityManager();
- Task existingTask = em.find(Task.class, taskId);
+ Task task = em.find(Task.class, taskId);
em.close();
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
- if (existingTask != null) {
- existingTask.setTaskType(taskType);
- existingTask.setParentProcessId(parentProcessId);
- existingTask.setCreationTime(creationTime);
- existingTask.setLastUpdateTime(lastUpdateTime);
- existingTask.setTaskDetail(taskDetail);
- existingTask.setTaskInternalStore(taskInternalStore);
- em.merge(existingTask);
- } else {
- Task task = new Task();
- task.setTaskId(taskId);
- task.setTaskType(taskType);
- task.setParentProcessId(parentProcessId);
- task.setCreationTime(creationTime);
- task.setLastUpdateTime(lastUpdateTime);
- task.setTaskDetail(taskDetail);
- task.setTaskInternalStore(taskInternalStore);
- em.persist(task);
+ if(task == null){
+ task = new Task();
}
+ task.setTaskId(taskId);
+ task.setTaskType(taskType);
+ task.setParentProcessId(parentProcessId);
+ task.setCreationTime(creationTime);
+ task.setLastUpdateTime(lastUpdateTime);
+ task.setTaskDetail(taskDetail);
+ task.setTaskInternalStore(taskInternalStore);
+ em.persist(task);
em.getTransaction().commit();
em.close();
} catch (Exception e) {
@@ -257,17 +309,53 @@ public class TaskResource extends AbstractExpCatResource {
}
}
+ public List<TaskStatusResource> getTaskStatuses() throws RegistryException{
+ List<TaskStatusResource> taskStatusResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.TASK_STATUS);
+ for (ExperimentCatResource resource : resources) {
+ TaskStatusResource statusResource = (TaskStatusResource) resource;
+ taskStatusResources.add(statusResource);
+ }
+ return taskStatusResources;
+ }
+
public TaskStatusResource getTaskStatus() throws RegistryException{
- ExperimentCatResource resource = get(ResourceType.TASK_STATUS, taskId);
- TaskStatusResource status = (TaskStatusResource) resource;
- if (status.getState() == null || status.getState().equals("") ){
- status.setState("UNKNOWN");
+ List<TaskStatusResource> taskStatusResources = getTaskStatuses();
+ if(taskStatusResources.size() == 0){
+ return null;
+ }else{
+ TaskStatusResource max = taskStatusResources.get(0);
+ for(int i=1; i<taskStatusResources.size();i++){
+ if(taskStatusResources.get(i).getTimeOfStateChange().after(max.getTimeOfStateChange())){
+ max = taskStatusResources.get(i);
+ }
+ }
+ return max;
}
- return status;
}
- public TaskErrorResource getTaskError () throws RegistryException{
- ExperimentCatResource resource = get(ResourceType.TASK_ERROR, taskId);;
- return (TaskErrorResource) resource;
+ public List<TaskErrorResource> getTaskErrors() throws RegistryException{
+ List<TaskErrorResource> taskErrorResources = new ArrayList();
+ List<ExperimentCatResource> resources = get(ResourceType.TASK_ERROR);
+ for (ExperimentCatResource resource : resources) {
+ TaskErrorResource errorResource = (TaskErrorResource) resource;
+ taskErrorResources.add(errorResource);
+ }
+ return taskErrorResources;
+ }
+
+ public TaskErrorResource getTaskError() throws RegistryException{
+ List<TaskErrorResource> taskErrorResources = getTaskErrors();
+ if(taskErrorResources.size() == 0){
+ return null;
+ }else{
+ TaskErrorResource max = taskErrorResources.get(0);
+ for(int i=1; i<taskErrorResources.size();i++){
+ if(taskErrorResources.get(i).getCreationTime().after(max.getCreationTime())){
+ max = taskErrorResources.get(i);
+ }
+ }
+ return max;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/066030bc/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
index 24650b1..fbc812f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
import org.apache.airavata.registry.core.experiment.catalog.model.TaskStatus;
+import org.apache.airavata.registry.core.experiment.catalog.model.TaskStatusPK;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,11 +36,20 @@ import java.util.List;
public class TaskStatusResource extends AbstractExpCatResource {
private static final Logger logger = LoggerFactory.getLogger(TaskStatusResource.class);
+ private String statusId;
private String taskId;
private String state;
private Timestamp timeOfStateChange;
private String reason;
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
public String getTaskId() {
return taskId;
}
@@ -102,10 +112,13 @@ public class TaskStatusResource extends AbstractExpCatResource {
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
TaskStatus taskStatus;
- if(taskId == null || state == null){
- throw new RegistryException("Does not have the task id or state");
+ if(taskId == null || statusId == null){
+ throw new RegistryException("Does not have the task id or status id");
}
- taskStatus = em.find(TaskStatus.class, taskId);
+ TaskStatusPK taskStatusPK = new TaskStatusPK();
+ taskStatusPK.setTaskId(taskId);
+ taskStatusPK.setStatusId(statusId);
+ taskStatus = em.find(TaskStatus.class, taskStatusPK);
if(taskStatus == null){
taskStatus = new TaskStatus();
}