You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ra...@apache.org on 2014/01/10 19:18:33 UTC
svn commit: r1557210 - in
/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa:
ResourceType.java model/OrchestratorData.java
resources/OrchestratorDataResource.java
Author: raminder
Date: Fri Jan 10 18:18:33 2014
New Revision: 1557210
URL: http://svn.apache.org/r1557210
Log:
orchestrator data rescource
Added:
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/OrchestratorDataResource.java
Modified:
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/OrchestratorData.java
Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java?rev=1557210&r1=1557209&r2=1557210&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java (original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java Fri Jan 10 18:18:33 2014
@@ -39,6 +39,7 @@ public enum ResourceType {
GRAM_DATA,
EXECUTION_ERROR,
GFAC_JOB_DATA,
- GFAC_JOB_STATUS
+ GFAC_JOB_STATUS,
+ ORCHESTRATOR_DATA
}
Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/OrchestratorData.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/OrchestratorData.java?rev=1557210&r1=1557209&r2=1557210&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/OrchestratorData.java (original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/OrchestratorData.java Fri Jan 10 18:18:33 2014
@@ -35,6 +35,10 @@ public class OrchestratorData {
return status.toString();
}
+ public void setOrchestratorId(String orchestratorId) {
+ this.orchestratorId = orchestratorId;
+ }
+
public void setExperimentId(String experimentId) {
this.experimentId = experimentId;
}
Added: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/OrchestratorDataResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/OrchestratorDataResource.java?rev=1557210&view=auto
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/OrchestratorDataResource.java (added)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/OrchestratorDataResource.java Fri Jan 10 18:18:33 2014
@@ -0,0 +1,181 @@
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.OrchestratorData;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OrchestratorDataResource extends AbstractResource {
+
+ private final static Logger log = LoggerFactory.getLogger(OrchestratorDataResource.class);
+ private String experimentID;
+ private String orchestratorID;
+ private String userName;
+ private String status;
+ private String state;
+ private String gfacEPR;
+
+ public String getExperimentID() {
+ return experimentID;
+ }
+
+ public String getOrchestratorID() {
+ return orchestratorID;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setExperimentID(String experimentID) {
+ this.experimentID = experimentID;
+ }
+
+ public void setOrchestratorID(String orchestratorID) {
+ this.orchestratorID = orchestratorID;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getGfacEPR() {
+ return gfacEPR;
+ }
+
+ public void setGfacEPR(String gfacEPR) {
+ this.gfacEPR = gfacEPR;
+ }
+
+ @Override
+ public Resource create(ResourceType type) {
+ if (type == ResourceType.ORCHESTRATOR_DATA) {
+ OrchestratorDataResource orchestratorResource = new OrchestratorDataResource();
+ orchestratorResource.setOrchestratorID(orchestratorID);
+ orchestratorResource.setExperimentID(experimentID);
+ orchestratorResource.setUserName(userName);
+ orchestratorResource.setState(state);
+ orchestratorResource.setStatus(status);
+ orchestratorResource.setGfacEPR(gfacEPR);
+ return orchestratorResource;
+ } else {
+ log.error("Unsupported resource type for orchestrator resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for orchestrator resource.");
+ }
+ }
+
+ @Override
+ public void remove(ResourceType type, Object name) {
+ log.error("Unsupported operation to remove orchestrator data.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Resource get(ResourceType type, Object name) {
+ EntityManager em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case ORCHESTRATOR_DATA:
+ generator = new QueryGenerator(ORCHESTRATORDATA);
+ generator.setParameter(OrchestratorDataConstants.ORCHESTRATOR_ID, name);
+ q = generator.selectQuery(em);
+ OrchestratorData orchestrator_data = (OrchestratorData)q.getSingleResult();
+ OrchestratorDataResource orchestratorDataResource = (OrchestratorDataResource)Utils.getResource(ResourceType.ORCHESTRATOR_DATA, orchestrator_data);
+ em.getTransaction().commit();
+ em.close();
+ return orchestratorDataResource;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ log.error("Unsupported resource type for node data resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for node data resource.");
+ }
+ }
+
+ @Override
+ public List<Resource> get(ResourceType type) {
+ List<Resource> resourceList = new ArrayList<Resource>();
+
+ if (type == ResourceType.ORCHESTRATOR_DATA) {
+ EntityManager em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(ORCHESTRATORDATA);
+ generator.setParameter(OrchestratorDataConstants.ORCHESTRATOR_ID, orchestratorID);
+ Query q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ OrchestratorData orchestratorData = (OrchestratorData) result;
+ OrchestratorDataResource orchestratorDataResource = (OrchestratorDataResource)
+ Utils.getResource(ResourceType.ORCHESTRATOR_DATA, orchestratorData);
+ resourceList.add(orchestratorDataResource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } else {
+ log.error("Unsupported resource type for orchestrator data resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for orchestrator data resource.");
+ }
+ return resourceList;
+ }
+
+ @Override
+ public void save() {
+ EntityManager em = ResourceUtils.getEntityManager();
+ OrchestratorData existingOrchestratorData = em.find(OrchestratorData.class,
+ experimentID);
+ em.close();
+
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ OrchestratorData orchestratorData = new OrchestratorData();
+ orchestratorData.setExperimentId(experimentID);
+ orchestratorData.setOrchestratorId(orchestratorID);
+ orchestratorData.setUser(userName);
+ orchestratorData.setGFACServiceEPR(gfacEPR);
+ orchestratorData.setState(state);
+ orchestratorData.setStatus(status);
+ if (existingOrchestratorData != null) {
+ existingOrchestratorData.setExperimentId(experimentID);
+ existingOrchestratorData.setUser(userName);
+ existingOrchestratorData.setGFACServiceEPR(gfacEPR);
+ existingOrchestratorData.setState(state);
+ existingOrchestratorData.setStatus(status);
+ orchestratorData = em.merge(existingOrchestratorData);
+ } else {
+ em.persist(orchestratorData);
+ }
+ em.getTransaction().commit();
+ em.close();
+
+ }
+
+}
\ No newline at end of file