airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1401892 - in /airavata/sandbox/airavata-registry-rest: ./ src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ src/main/java/org/apache/airavata/services/registry/rest/resources/
Date Wed, 24 Oct 2012 21:21:16 GMT
Author: chathuri
Date: Wed Oct 24 21:21:15 2012
New Revision: 1401892

URL: http://svn.apache.org/viewvc?rev=1401892&view=rev
Log:
updating workflow execution related methods

Added:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceMapping.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceStatusMapping.java
Modified:
    airavata/sandbox/airavata-registry-rest/README.txt
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstancesList.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java

Modified: airavata/sandbox/airavata-registry-rest/README.txt
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/README.txt?rev=1401892&r1=1401891&r2=1401892&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/README.txt (original)
+++ airavata/sandbox/airavata-registry-rest/README.txt Wed Oct 24 21:21:15 2012
@@ -75,6 +75,27 @@ To test
     curl --request DELETE 'http://localhost:9080/airavata-services/registry/api/delete/experiment?experimentId=eb9e67cf-6fe3-46f1-b50b-7b42936d347d
     curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiments/all'
     curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiments/project?projectName=default'
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiments/date?fromDate=2012-10-16%2000:00:00&toDate=2012-10-18%2000:00:00'
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiments/project/date?projectName=default&fromDate=2012-10-16%2000:00:00&toDate=2012-10-18%2000:00:00'
+    curl -H "Accept: text/plain" -X POST -d 'projectName=project1&experimentID=testexpID1&submittedDate=2012-10-18
00:00:00' http://localhost:9080/airavata-services/registry/api/add/experiment
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/experiment/exist?experimentId=testexpID1'
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/experiment/notexist/create?experimentId=testExpID2&createIfNotPresent=true'
+    curl -H "Accept: text/plain" -X POST -d 'experimentId=testExpID2&user=abc' http://localhost:9080/airavata-services/registry/api/update/experiment
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiment/executionuser?experimentId=testExpID2'
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiment/name?experimentId=testExpID2'
+    curl -H "Accept: text/plain" -X POST -d 'experimentId=testExpID2&experimentName=ddscsddsss111'
http://localhost:9080/airavata-services/registry/api/update/experimentname
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experimentmetadata?experimentId=testExpID2'
+    curl -H "Accept: text/plain" -X POST -d 'experimentId=testExpID2&metadata=aaaaaaa'
http://localhost:9080/airavata-services/registry/api/update/experimentmetadata
+
+************* Workflow Execution *************************************
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/workflowtemplatename?workflowInstanceId=e00ddc5e-f8d5-4492-9eb2-10372efb103c'
+    curl -H "Accept: text/plain" -X POST -d 'workflowInstanceId=e00ddc5e-f8d5-4492-9eb2-10372efb103c&templateName=wftemplate1'
http://localhost:9080/airavata-services/registry/api/update/workflowinstancetemplatename
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experimentworkflowinstances?experimentId=ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4'
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/workflowinstance/exist/check?instanceId=e00ddc5e-f8d5-4492-9eb2-10372efb103c'
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/workflowinstance/exist/create?instanceId=testWFInstanceID&createIfNotPresent=true'
+    curl -H "Accept: text/plain" -X POST -d 'instanceId=testWFInstanceID&executionStatus=FINISHED'
http://localhost:9080/airavata-services/registry/api/update/workflowinstancestatus/instanceid
+    curl -H "Accept: text/plain" -X POST -d 'experimentId=testWFInstanceID&workflowInstanceId=testWFInstanceID&executionStatus=STARTED&statusUpdateTime=2012-10-23
00:00:00' http://localhost:9080/airavata-services/registry/api/update/workflowinstancestatus/experimentid
+    curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/workflowinstancestatus?instanceId=testWFInstanceID'
 
 
 

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceMapping.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceMapping.java?rev=1401892&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceMapping.java
(added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceMapping.java
Wed Oct 24 21:21:15 2012
@@ -0,0 +1,58 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.services.registry.rest.resourcemappings;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class WorkflowInstanceMapping {
+    private String experimentId;
+    private String workflowInstanceId;
+    private String templateName;
+
+    public WorkflowInstanceMapping() {
+    }
+
+    public String getExperimentId() {
+        return experimentId;
+    }
+
+    public String getWorkflowInstanceId() {
+        return workflowInstanceId;
+    }
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    public void setExperimentId(String experimentId) {
+        this.experimentId = experimentId;
+    }
+
+    public void setWorkflowInstanceId(String workflowInstanceId) {
+        this.workflowInstanceId = workflowInstanceId;
+    }
+
+    public void setTemplateName(String templateName) {
+        this.templateName = templateName;
+    }
+}

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceStatusMapping.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceStatusMapping.java?rev=1401892&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceStatusMapping.java
(added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstanceStatusMapping.java
Wed Oct 24 21:21:15 2012
@@ -0,0 +1,88 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.services.registry.rest.resourcemappings;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Date;
+
+@XmlRootElement
+public class WorkflowInstanceStatusMapping {
+    private String executionStatus;
+    private Date statusUpdateTime = null;
+    private String experimentId;
+    private String workflowInstanceId;
+    private String templateName;
+
+    private WorkflowInstanceMapping workflowInstanceMapping;
+
+    public WorkflowInstanceStatusMapping() {
+    }
+
+    public String getExecutionStatus() {
+        return executionStatus;
+    }
+
+    public Date getStatusUpdateTime() {
+        return statusUpdateTime;
+    }
+
+
+    public void setExecutionStatus(String executionStatus) {
+        this.executionStatus = executionStatus;
+    }
+
+    public void setStatusUpdateTime(Date statusUpdateTime) {
+        this.statusUpdateTime = statusUpdateTime;
+    }
+
+    public void setWorkflowInstanceMapping(WorkflowInstanceMapping workflowInstanceStatusMapping)
{
+        this.workflowInstanceMapping = workflowInstanceStatusMapping;
+    }
+
+    public String getExperimentId() {
+        return experimentId;
+    }
+
+    public String getWorkflowInstanceId() {
+        return workflowInstanceId;
+    }
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    public WorkflowInstanceMapping getWorkflowInstanceMapping() {
+        return workflowInstanceMapping;
+    }
+
+    public void setExperimentId(String experimentId) {
+        this.experimentId = experimentId;
+    }
+
+    public void setWorkflowInstanceId(String workflowInstanceId) {
+        this.workflowInstanceId = workflowInstanceId;
+    }
+
+    public void setTemplateName(String templateName) {
+        this.templateName = templateName;
+    }
+}

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstancesList.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstancesList.java?rev=1401892&r1=1401891&r2=1401892&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstancesList.java
(original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowInstancesList.java
Wed Oct 24 21:21:15 2012
@@ -1,18 +1,16 @@
 package org.apache.airavata.services.registry.rest.resourcemappings;
 
-import org.apache.airavata.registry.api.workflow.WorkflowInstance;
-
 import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 public class WorkflowInstancesList {
-    WorkflowInstance[] workflowInstances = null;
+    WorkflowInstanceMapping[] workflowInstanceMappings = null;
 
-    public WorkflowInstance[] getWorkflowInstances() {
-        return workflowInstances;
+    public WorkflowInstanceMapping[] getWorkflowInstanceMappings() {
+        return workflowInstanceMappings;
     }
 
-    public void setWorkflowInstances(WorkflowInstance[] workflowInstances) {
-        this.workflowInstances = workflowInstances;
+    public void setWorkflowInstanceMappings(WorkflowInstanceMapping[] workflowInstanceMappings)
{
+        this.workflowInstanceMappings = workflowInstanceMappings;
     }
 }

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java?rev=1401892&r1=1401891&r2=1401892&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java
(original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java
Wed Oct 24 21:21:15 2012
@@ -9,9 +9,9 @@ import org.apache.airavata.registry.api.
 import org.apache.airavata.registry.api.exception.gateway.*;
 import org.apache.airavata.registry.api.exception.worker.*;
 import org.apache.airavata.registry.api.workflow.*;
-import org.apache.airavata.registry.services.*;
 import org.apache.airavata.services.registry.rest.resourcemappings.*;
 import org.apache.airavata.registry.api.AiravataExperiment;
+import org.apache.airavata.services.registry.rest.resourcemappings.WorkflowInstanceMapping;
 import org.apache.airavata.services.registry.rest.utils.RestServicesConstants;
 import org.apache.xmlbeans.XmlException;
 import org.slf4j.Logger;
@@ -26,7 +26,6 @@ import java.net.URI;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -1349,6 +1348,7 @@ import java.util.Map;
 
     @GET
     @Path("get/experiments/date")
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     public Response getExperimentsByDate(@QueryParam("fromDate") String fromDate,
                                          @QueryParam("toDate") String toDate) {
@@ -1390,6 +1390,7 @@ import java.util.Map;
 
     @GET
     @Path("get/experiments/project/date")
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     public Response getExperimentsByProjectDate(@QueryParam("projectName") String projectName,
                                                 @QueryParam("fromDate") String fromDate,
@@ -1432,6 +1433,7 @@ import java.util.Map;
 
     @POST
     @Path("add/experiment")
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces(MediaType.TEXT_PLAIN)
     public Response addExperiment(@FormParam("projectName") String projectName,
                                   @FormParam("experimentID") String experimentID,
@@ -1507,18 +1509,13 @@ import java.util.Map;
     @POST
     @Path("update/experiment")
     @Produces(MediaType.TEXT_PLAIN)
-    public Response updateExperimentExecutionUser(@QueryParam("experimentId") String experimentId,
-                                                  @QueryParam("user") String user) {
+    public Response updateExperimentExecutionUser(@FormParam("experimentId") String experimentId,
+                                                  @FormParam("user") String user) {
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
-            Boolean result = airavataRegistry.updateExperimentExecutionUser(experimentId,user);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            airavataRegistry.updateExperimentExecutionUser(experimentId,user);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();
@@ -1549,7 +1546,7 @@ import java.util.Map;
     @GET
     @Path("get/experiment/name")
     @Produces(MediaType.TEXT_PLAIN)
-    public Response getExperimentName(@QueryParam("experimentID") String experimentId) {
+    public Response getExperimentName(@QueryParam("experimentId") String experimentId) {
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
             String result = airavataRegistry.getExperimentName(experimentId);
@@ -1570,18 +1567,13 @@ import java.util.Map;
     @POST
     @Path("update/experimentname")
     @Produces(MediaType.TEXT_PLAIN)
-    public Response updateExperimentName(@QueryParam("experimentId") String experimentId,
-                                         @QueryParam("experimentName") String experimentName){
-        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+    public Response updateExperimentName(@FormParam("experimentId") String experimentId,
+                                         @FormParam("experimentName") String experimentName){
+            airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
-            Boolean result = airavataRegistry.updateExperimentName(experimentId, experimentName);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            airavataRegistry.updateExperimentName(experimentId, experimentName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();
@@ -1617,14 +1609,9 @@ import java.util.Map;
                                              @FormParam("metadata") String metadata) {
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
-            Boolean result = airavataRegistry.updateExperimentMetadata(experimentId, metadata);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            airavataRegistry.updateExperimentMetadata(experimentId, metadata);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();
@@ -1676,11 +1663,16 @@ import java.util.Map;
         try{
             List<WorkflowInstance> experimentWorkflowInstances = airavataRegistry.getExperimentWorkflowInstances(experimentId);
             WorkflowInstancesList workflowInstancesList = new WorkflowInstancesList();
-            WorkflowInstance[] workflowInstances = new WorkflowInstance[experimentWorkflowInstances.size()];
+            WorkflowInstanceMapping[] workflowInstanceMappings = new WorkflowInstanceMapping[experimentWorkflowInstances.size()];
             for (int i=0; i<experimentWorkflowInstances.size(); i++){
-                workflowInstances[i] = experimentWorkflowInstances.get(i);
+                WorkflowInstanceMapping workflowInstanceMapping = new WorkflowInstanceMapping();
+                WorkflowInstance workflowInstance = experimentWorkflowInstances.get(i);
+                workflowInstanceMapping.setExperimentId(workflowInstance.getExperimentId());
+                workflowInstanceMapping.setTemplateName(workflowInstance.getTemplateName());
+                workflowInstanceMapping.setWorkflowInstanceId(workflowInstance.getWorkflowInstanceId());
+                workflowInstanceMappings[i] = workflowInstanceMapping;
             }
-            workflowInstancesList.setWorkflowInstances(workflowInstances);
+            workflowInstancesList.setWorkflowInstanceMappings(workflowInstanceMappings);
             if (experimentWorkflowInstances.size() != 0) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
                 builder.entity(workflowInstancesList);
@@ -1704,9 +1696,11 @@ import java.util.Map;
             Boolean result = airavataRegistry.isWorkflowInstanceExists(instanceId);
             if (result) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
                 return builder.build();
             } else {
                 Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+                builder.entity("False");
                 return builder.build();
             }
         } catch (RegistryException e) {
@@ -1726,6 +1720,7 @@ import java.util.Map;
             Boolean result = airavataRegistry.isWorkflowInstanceExists(instanceId, createIfNotPresent);
             if (result) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
                 return builder.build();
             } else {
                 Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
@@ -1745,14 +1740,9 @@ import java.util.Map;
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
             WorkflowInstanceStatus.ExecutionStatus status = WorkflowInstanceStatus.ExecutionStatus.valueOf(executionStatus);
-            Boolean result = airavataRegistry.updateWorkflowInstanceStatus(instanceId, status);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            airavataRegistry.updateWorkflowInstanceStatus(instanceId, status);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();
@@ -1760,41 +1750,51 @@ import java.util.Map;
     }
 
     @POST
-    @Path("update/workflowinstancestatus/experimentid")
+    @Path("update/workflowinstancestatus")
     @Produces(MediaType.TEXT_PLAIN)
-    public Response updateWorkflowInstanceStatusByExperiment(@FormParam("experimentId") String
experimentId,
-                                                             @FormParam("workflowInstanceId")
String workflowInstanceId,
-                                                             @FormParam("executionStatus")
String executionStatus,
-                                                             @FormParam("statusUpdateTime")
Date statusUpdateTime) {
+    public Response updateWorkflowInstanceStatus(@FormParam("workflowInstanceId") String
workflowInstanceId,
+                                                 @FormParam("executionStatus") String executionStatus,
+                                                 @FormParam("statusUpdateTime") String statusUpdateTime)
{
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
-            WorkflowInstance workflowInstance =  new WorkflowInstance(experimentId, workflowInstanceId);
+            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date formattedDate = dateFormat.parse(statusUpdateTime);
+            WorkflowInstance workflowInstance = airavataRegistry.getWorkflowInstanceData(workflowInstanceId).getWorkflowInstance();
             WorkflowInstanceStatus.ExecutionStatus status = WorkflowInstanceStatus.ExecutionStatus.valueOf(executionStatus);
-            WorkflowInstanceStatus workflowInstanceStatus = new WorkflowInstanceStatus(workflowInstance,
status, statusUpdateTime);
-            Boolean result = airavataRegistry.updateWorkflowInstanceStatus(workflowInstanceStatus);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            WorkflowInstanceStatus workflowInstanceStatus = new WorkflowInstanceStatus(workflowInstance,
status, formattedDate);
+            airavataRegistry.updateWorkflowInstanceStatus(workflowInstanceStatus);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();
+        } catch (ParseException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
         }
     }
 
     @GET
     @Path("get/workflowinstancestatus")
-    @Produces(MediaType.TEXT_PLAIN)
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     public Response getWorkflowInstanceStatus(@QueryParam("instanceId") String instanceId)
{
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
             WorkflowInstanceStatus workflowInstanceStatus = airavataRegistry.getWorkflowInstanceStatus(instanceId);
-            if(workflowInstanceStatus != null){
+            WorkflowInstanceStatusMapping workflowInstanceStatusMapping = new WorkflowInstanceStatusMapping();
+            workflowInstanceStatusMapping.setExecutionStatus(workflowInstanceStatus.getExecutionStatus().name());
+            workflowInstanceStatusMapping.setStatusUpdateTime(workflowInstanceStatus.getStatusUpdateTime());
+            WorkflowInstance workflowInstance = workflowInstanceStatus.getWorkflowInstance();
+            WorkflowInstanceMapping workflowInstanceMapping = new WorkflowInstanceMapping();
+            if(workflowInstance != null){
+                workflowInstanceStatusMapping.setExperimentId(workflowInstance.getExperimentId());
+                workflowInstanceStatusMapping.setTemplateName(workflowInstance.getTemplateName());
+                workflowInstanceStatusMapping.setWorkflowInstanceId(workflowInstance.getWorkflowInstanceId());
+            }
+//            workflowInstanceStatusMapping.setWorkflowInstanceMapping(workflowInstanceMapping);
+            if(workflowInstanceStatusMapping != null){
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(workflowInstanceStatus);
+                builder.entity(workflowInstanceStatusMapping);
                 return builder.build();
             }else{
                 Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
@@ -1809,22 +1809,17 @@ import java.util.Map;
     @POST
     @Path("update/workflownodeinput")
     @Produces(MediaType.TEXT_PLAIN)
-    public Response updateWorkflowNodeInput(@FormParam("experimentID") String experimentID,
+    public Response updateWorkflowNodeInput(@FormParam("experimentId") String experimentID,
                                             @FormParam("nodeID") String nodeID,
-                                            @FormParam("workflowInstanceID") String workflowInstanceID,
+                                            @FormParam("workflowInstanceId") String workflowInstanceID,
                                             @FormParam("data") String data){
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
-            WorkflowInstance workflowInstance = new WorkflowInstance(experimentID, nodeID);
-            WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(workflowInstance,
nodeID);
-            boolean result = airavataRegistry.updateWorkflowNodeInput(workflowInstanceNode,
data);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceID);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceData.getNodeData(nodeID).getWorkflowInstanceNode();
+            airavataRegistry.updateWorkflowNodeInput(workflowInstanceNode, data);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();
@@ -1841,16 +1836,11 @@ import java.util.Map;
                                              @FormParam("data") String data) {
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try{
-            WorkflowInstance workflowInstance = new WorkflowInstance(experimentID, nodeID);
-            WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(workflowInstance,
nodeID);
-            boolean result = airavataRegistry.updateWorkflowNodeOutput(workflowInstanceNode,
data);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceID);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceData.getNodeData(nodeID).getWorkflowInstanceNode();
+            airavataRegistry.updateWorkflowNodeOutput(workflowInstanceNode, data);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
             return builder.build();



Mime
View raw message