airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1388646 - in /airavata/trunk/modules: commons/registry-api/src/main/java/org/apache/airavata/registry/api/ commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ registry/airavata-jpa-registry/src/main/java/o...
Date Fri, 21 Sep 2012 19:45:30 GMT
Author: samindaw
Date: Fri Sep 21 19:45:30 2012
New Revision: 1388646

URL: http://svn.apache.org/viewvc?rev=1388646&view=rev
Log:
supporting creating the node instance when it is not present

Added:
    airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
  (with props)
Modified:
    airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java

Modified: airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java?rev=1388646&r1=1388645&r2=1388646&view=diff
==============================================================================
--- airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
(original)
+++ airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
Fri Sep 21 19:45:30 2012
@@ -307,10 +307,13 @@ public interface ProvenanceRegistry exte
     
     public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId)throws
RegistryException;
     
+    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId,
boolean createIfNotPresent)throws RegistryException;
+    
     public WorkflowInstanceNodeData getWorkflowInstanceNodeData(String workflowInstanceId,
String nodeId)throws RegistryException;
 
     public boolean addWorkflowInstance(String experimentId, String workflowInstanceId, String
templateName) throws RegistryException;
     
     public boolean updateWorkflowNodeType(WorkflowInstanceNode node, WorkflowNodeType type)
throws RegistryException;
     
+    public boolean addWorkflowInstanceNode(String workflowInstance, String nodeId) throws
RegistryException;
 }
\ No newline at end of file

Added: airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java?rev=1388646&view=auto
==============================================================================
--- airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
(added)
+++ airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
Fri Sep 21 19:45:30 2012
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.registry.api.exception.worker;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+
+public class WorkflowInstanceNodeAlreadyExistsException extends RegistryException {
+
+	private static final long serialVersionUID = -8006347245307495767L;
+
+	public WorkflowInstanceNodeAlreadyExistsException(String instanceId, String nodeId) {
+		super("The node "+nodeId+" for the workflow instance "+instanceId+" is already in the registry!!!");
+	}
+
+}

Propchange: airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1388646&r1=1388645&r2=1388646&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
Fri Sep 21 19:45:30 2012
@@ -68,6 +68,7 @@ import org.apache.airavata.registry.api.
 import org.apache.airavata.registry.api.exception.worker.UserWorkflowDoesNotExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkflowInstanceAlreadyExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkflowInstanceDoesNotExistsException;
+import org.apache.airavata.registry.api.exception.worker.WorkflowInstanceNodeAlreadyExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkflowInstanceNodeDoesNotExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectAlreadyExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectDoesNotExistsException;
@@ -1022,16 +1023,11 @@ public class AiravataJPARegistry extends
 	@Override
 	public boolean updateWorkflowNodeInput(WorkflowInstanceNode node, String data)
 			throws RegistryException {
-		if (!isWorkflowInstanceExists(node.getWorkflowInstance().getWorkflowInstanceId(), true)){
-			throw new WorkflowInstanceDoesNotExistsException(node.getWorkflowInstance().getWorkflowInstanceId());
+		if (!isWorkflowInstanceNodePresent(node.getWorkflowInstance().getWorkflowInstanceId(),node.getNodeId(),true)){
+			throw new WorkflowInstanceNodeDoesNotExistsException(node.getWorkflowInstance().getWorkflowInstanceId(),
node.getNodeId());
 		}
 		WorkflowDataResource wi = jpa.getWorker().getWorkflowInstance(node.getWorkflowInstance().getWorkflowInstanceId());
-		NodeDataResource nodeData;
-		if (wi.isNodeExists(node.getNodeId())){
-			nodeData = wi.getNodeData(node.getNodeId());
-		}else{
-			nodeData = wi.createNodeData(node.getNodeId());
-		}
+		NodeDataResource nodeData = wi.getNodeData(node.getNodeId());
 		nodeData.setInputs(data);
 		nodeData.save();
 		return true;
@@ -1040,16 +1036,11 @@ public class AiravataJPARegistry extends
 
 	@Override
 	public boolean updateWorkflowNodeOutput(WorkflowInstanceNode node, String data) throws RegistryException
{
-		if (!isWorkflowInstanceExists(node.getWorkflowInstance().getWorkflowInstanceId(),true)){
-			throw new WorkflowInstanceDoesNotExistsException(node.getWorkflowInstance().getWorkflowInstanceId());
+		if (!isWorkflowInstanceNodePresent(node.getWorkflowInstance().getWorkflowInstanceId(),node.getNodeId(),true)){
+			throw new WorkflowInstanceNodeDoesNotExistsException(node.getWorkflowInstance().getWorkflowInstanceId(),
node.getNodeId());
 		}
 		WorkflowDataResource wi = jpa.getWorker().getWorkflowInstance(node.getWorkflowInstance().getWorkflowInstanceId());
-		NodeDataResource nodeData;
-		if (wi.isNodeExists(node.getNodeId())){
-			nodeData = wi.getNodeData(node.getNodeId());
-		}else{
-			nodeData = wi.createNodeData(node.getNodeId());
-		}
+		NodeDataResource nodeData = wi.getNodeData(node.getNodeId());
 		nodeData.setOutputs(data);
 		nodeData.save();
 		return true;
@@ -1191,7 +1182,7 @@ public class AiravataJPARegistry extends
 	public boolean updateWorkflowNodeStatus(
 			WorkflowInstanceNodeStatus workflowStatusNode)
 			throws RegistryException {
-		if (!isWorkflowInstanceNodePresent(workflowStatusNode.getWorkflowInstanceNode().getWorkflowInstance().getWorkflowInstanceId(),
workflowStatusNode.getWorkflowInstanceNode().getNodeId())){
+		if (!isWorkflowInstanceNodePresent(workflowStatusNode.getWorkflowInstanceNode().getWorkflowInstance().getWorkflowInstanceId(),
workflowStatusNode.getWorkflowInstanceNode().getNodeId(), true)){
 			throw new WorkflowInstanceNodeDoesNotExistsException(workflowStatusNode.getWorkflowInstanceNode().getWorkflowInstance().getWorkflowInstanceId(),
workflowStatusNode.getWorkflowInstanceNode().getNodeId());
 		}
 		NodeDataResource nodeData = jpa.getWorker().getWorkflowInstance(workflowStatusNode.getWorkflowInstanceNode().getWorkflowInstance().getWorkflowInstanceId()).getNodeData(workflowStatusNode.getWorkflowInstanceNode().getNodeId());
@@ -1261,7 +1252,7 @@ public class AiravataJPARegistry extends
 	@Override
 	public boolean updateWorkflowNodeGramData(
 			WorkflowNodeGramData workflowNodeGramData) throws RegistryException {
-		if (!isWorkflowInstanceNodePresent(workflowNodeGramData.getWorkflowInstanceId(),workflowNodeGramData.getNodeID())){
+		if (!isWorkflowInstanceNodePresent(workflowNodeGramData.getWorkflowInstanceId(),workflowNodeGramData.getNodeID(),
true)){
 			throw new WorkflowInstanceNodeDoesNotExistsException(workflowNodeGramData.getWorkflowInstanceId(),workflowNodeGramData.getNodeID());
 		}
 		WorkflowDataResource workflowInstance = jpa.getWorker().getWorkflowInstance(workflowNodeGramData.getWorkflowInstanceId());
@@ -1311,14 +1302,27 @@ public class AiravataJPARegistry extends
 	}
 
 
+
 	@Override
 	public boolean isWorkflowInstanceNodePresent(String workflowInstanceId,
 			String nodeId) throws RegistryException {
+		return isWorkflowInstanceNodePresent(workflowInstanceId, nodeId, false);
+	}
+
+	@Override
+	public boolean isWorkflowInstanceNodePresent(String workflowInstanceId,
+			String nodeId, boolean createIfNotPresent) throws RegistryException {
 		if (!isWorkflowInstanceExists(workflowInstanceId, true)){
 			throw new WorkflowInstanceDoesNotExistsException(workflowInstanceId);
 		}
-		return jpa.getWorker().getWorkflowInstance(workflowInstanceId).isNodeExists(nodeId);
-
+		if (jpa.getWorker().getWorkflowInstance(workflowInstanceId).isNodeExists(nodeId)){
+			return true;
+		}else if (createIfNotPresent){
+			addWorkflowInstanceNode(workflowInstanceId, nodeId);
+			return isWorkflowInstanceNodePresent(workflowInstanceId, nodeId);
+		}else{
+			return false;
+		}
 	}
 
 
@@ -1343,7 +1347,7 @@ public class AiravataJPARegistry extends
 	@Override
 	public boolean updateWorkflowNodeType(WorkflowInstanceNode node, WorkflowNodeType type)
 			throws RegistryException {
-		if (!isWorkflowInstanceNodePresent(node.getWorkflowInstance().getWorkflowInstanceId(),node.getNodeId())){
+		if (!isWorkflowInstanceNodePresent(node.getWorkflowInstance().getWorkflowInstanceId(),node.getNodeId(),
true)){
 			throw new WorkflowInstanceNodeDoesNotExistsException(node.getWorkflowInstance().getWorkflowInstanceId(),node.getNodeId());
 		}
 		NodeDataResource nodeData = jpa.getWorker().getWorkflowInstance(node.getWorkflowInstance().getWorkflowInstanceId()).getNodeData(node.getNodeId());
@@ -1352,4 +1356,17 @@ public class AiravataJPARegistry extends
 		return false;
 	}
 
+
+	@Override
+	public boolean addWorkflowInstanceNode(String workflowInstanceId,
+			String nodeId) throws RegistryException {
+		if (isWorkflowInstanceNodePresent(workflowInstanceId, nodeId)){
+			throw new WorkflowInstanceNodeAlreadyExistsException(workflowInstanceId, nodeId);
+		}
+		NodeDataResource nodeData = jpa.getWorker().getWorkflowInstance(workflowInstanceId).createNodeData(nodeId);
+		nodeData.save();
+		return true;
+	}
+
+
 }

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java?rev=1388646&r1=1388645&r2=1388646&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
(original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowDataResource.java
Fri Sep 21 19:45:30 2012
@@ -237,13 +237,7 @@ public class WorkflowDataResource extend
     }
     
     public NodeDataResource getNodeData(String nodeId){
-    	if (isNodeExists(nodeId)){
-    		return (NodeDataResource) get(ResourceType.NODE_DATA,nodeId);
-    	}else{
-    		NodeDataResource nodeData = createNodeData(nodeId);
-    		nodeData.save();
-    		return nodeData;
-    	}
+		return (NodeDataResource) get(ResourceType.NODE_DATA,nodeId);
     }
     
     public GramDataResource getGramData(String nodeId){



Mime
View raw message