airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hes...@apache.org
Subject svn commit: r1234195 - /incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
Date Fri, 20 Jan 2012 22:48:39 GMT
Author: heshan
Date: Fri Jan 20 22:48:38 2012
New Revision: 1234195

URL: http://svn.apache.org/viewvc?rev=1234195&view=rev
Log:
Fix for AIRAVATA-263

Modified:
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java?rev=1234195&r1=1234194&r2=1234195&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
Fri Jan 20 22:48:38 2012
@@ -1331,146 +1331,155 @@ public class WorkflowInterpreter {
 		return invoker;
 	}
 
-	private void runInThread(LinkedList<String> listOfValues,
-			ForEachNode forEachNode, Node middleNode, Node endForEachNode,
-			SystemComponentInvoker tempInvoker, AtomicInteger counter,
-			Integer[] inputNumber) throws XBayaException {
-
-		Invoker invoker = null;
-		LinkedList<Invoker> invokerList = new LinkedList<Invoker>();
-
-		if (inputNumber.length > 1) {
-			List<String> inputValues = createInputValues(listOfValues,
-					inputNumber);
-			for (Iterator<String> iterator = inputValues.iterator(); iterator
-					.hasNext();) {
-				String input = iterator.next();
-				final String gfacURLString = this.configuration
-						.getGFacURL().toString();
-
-				if (middleNode instanceof WSNode) {
-					WSComponent wsComponent = (WSComponent) middleNode
-							.getComponent();
-					invoker = createInvokerForEachSingleWSNode(middleNode,
-							gfacURLString, wsComponent);
-					invoker.setup();
-					invoker.setOperation(wsComponent.getOperationName());
-				} else if (middleNode instanceof SubWorkflowNode) {
-					// ((SubWorkflowNode) middleNode).getWorkflow();
-					// this.configuration;
-					// TODO : Need to create a invoker!
-					// new WorkflowInterpreter()
-				} else {
-					throw new XBayaRuntimeException(
-							"Only Web services and subworkflows are supported for For-Each : Found : "
-									+ middleNode);
-				}
-
-				invokerList.add(invoker);
-				// find inputs
-				List<DataPort> inputPorts = middleNode.getInputPorts();
-				String[] inputArray = null;
-				if (inputNumber.length == 1) {
-					inputArray = listOfValues.toArray(new String[listOfValues
-							.size()]);
-				} else {
-					inputArray = input.split(",");
-				}
-				int index = 0;
-				for (DataPort port : inputPorts) {
-					Object inputVal = InterpreterUtil.findInputFromPort(port,
-							this.invokerMap);
-					/*
-					 * Handle ForEachNode
-					 */
-					Node fromNode = port.getFromNode();
-					if (fromNode instanceof ForEachNode) {
-						inputVal = inputArray[index++];
-					}
+    private void runInThread(final LinkedList<String> listOfValues,
+                             ForEachNode forEachNode, final Node middleNode,
+                             Node endForEachNode, SystemComponentInvoker tempInvoker,
+                             AtomicInteger counter, final Integer[] inputNumber) throws XBayaException
{
+
+        final LinkedList<Invoker> invokerList = new LinkedList<Invoker>();
+
+        if(inputNumber.length > 1){
+            List<String> inputValues = createInputValues(listOfValues,inputNumber);
+            for (final Iterator<String> iterator = inputValues.iterator(); iterator.hasNext();)
{
+                final String gfacURLString = this.configuration.getGFacURL().toString();
+                final String input = iterator.next();
+                WSComponent wsComponent = (WSComponent) middleNode.getComponent();
+                final Invoker invoker2 = createInvokerForEachSingleWSNode(middleNode, gfacURLString,
wsComponent);
+                invokerList.add(invoker2);
+
+                new Thread() {
+                    @Override
+                    public void run() {
+                        try {
+                            getInvoker(middleNode, invoker2);
+                            invokeGFacService(listOfValues, middleNode, inputNumber, input,
invoker2);
+
+                        } catch (XBayaException e) {
+                            WorkflowInterpreter.this.engine.getErrorWindow().error(e);
+                        }
+                    }
+
+                }.start();
+
+                try {
+                    Thread.sleep(3000);
+                } catch (InterruptedException e) {
+                    WorkflowInterpreter.this.engine.getErrorWindow().error(e);
+                }
+            }
+        }else{
+            Invoker invoker = null;
+            for (Iterator<String> iterator = listOfValues.iterator(); iterator
+                    .hasNext();) {
+                String input = iterator.next();
+                final String gfacURLString = this.configuration
+                        .getGFacURL().toString();
+
+                WSComponent wsComponent = (WSComponent) middleNode.getComponent();
+                invoker = createInvokerForEachSingleWSNode(middleNode, gfacURLString, wsComponent);
+                invokerList.add(invoker);
+                getInvoker(middleNode, invoker);
+
+                // find inputs
+                List<DataPort> inputPorts = middleNode.getInputPorts();
+                for (DataPort port : inputPorts) {
+                    Object inputVal = InterpreterUtil.findInputFromPort(port,
+                            this.invokerMap);
+
+                    /*
+                    * Handle ForEachNode
+                    */
+                    Node fromNode = port.getFromNode();
+//                if (fromNode instanceof ForEachNode) {
+                    inputVal = input;
+//                }
+
+                    if (null == inputVal) {
+                        throw new WorkFlowInterpreterException(
+                                "Unable to find inputs for the node:"
+                                        + middleNode.getID());
+                    }
+                    invoker.setInput(port.getName(), inputVal);
+                }
+                invoker.invoke();
+            }
+        }
+
+        // String arrayElementName = foreachWSNode.getOperationName() +
+        // "ArrayResponse";
+        // String outputStr = "<" + arrayElementName + ">";
+        String outputStr = "";
+        for (Iterator<Invoker> iterator = invokerList.iterator(); iterator
+                .hasNext();) {
+            Invoker workflowInvoker = iterator.next();
+
+            // /
+            Object output = workflowInvoker.getOutput(endForEachNode
+                    .getInputPort(0).getFromPort().getName());
+            outputStr += "\n<value>" + output + "</value>";
+            counter.incrementAndGet();
+        }
+        // outputStr += "\n</" + arrayElementName + ">";
+        System.out.println(outputStr);
+        if(!(endForEachNode instanceof OutputNode)){
+            tempInvoker.addOutput(endForEachNode.getOutputPort(0).getName(),
+                    outputStr);
+        }
+        forEachNode.getGUI().setBodyColor(NodeState.FINISHED.color);
+    }
 
-					if (null == inputVal) {
-						throw new WorkFlowInterpreterException(
-								"Unable to find inputs for the node:"
-										+ middleNode.getID());
-					}
-					invoker.setInput(port.getName(), inputVal);
-				}
-				invoker.invoke();
+    private void invokeGFacService(LinkedList<String> listOfValues, Node middleNode,
+                                   Integer[] inputNumber, String input,
+                                   Invoker invoker) throws XBayaException {
+
+
+        // find inputs
+        List<DataPort> inputPorts = middleNode.getInputPorts();
+        String[] inputArray = null;
+        if(inputNumber.length == 1){
+            inputArray = listOfValues.toArray(new String[listOfValues.size()]);
+        }else{
+            inputArray = input.split(",");
+        }
+        int index = 0;
+        for (DataPort port : inputPorts) {
+            Object inputVal = InterpreterUtil.findInputFromPort(port,
+                    this.invokerMap);
+            /*
+            * Handle ForEachNode
+            */
+            Node fromNode = port.getFromNode();
+            if (fromNode instanceof ForEachNode) {
+                inputVal = inputArray[index++];
+            }
+
+
+            if (null == inputVal) {
+                throw new WorkFlowInterpreterException(
+                        "Unable to find inputs for the node:"
+                                + middleNode.getID());
+            }
+            invoker.setInput(port.getName(), inputVal);
+        }
+        invoker.invoke();
 
-			}
-		} else {
-			for (Iterator<String> iterator = listOfValues.iterator(); iterator
-					.hasNext();) {
-				String input = iterator.next();
-				final String gfacURLString = this.configuration
-						.getGFacURL().toString();
-
-				if (middleNode instanceof WSNode) {
-					WSComponent wsComponent = (WSComponent) middleNode
-							.getComponent();
-					invoker = createInvokerForEachSingleWSNode(middleNode,
-							gfacURLString, wsComponent);
-					invoker.setup();
-					invoker.setOperation(wsComponent.getOperationName());
-				} else if (middleNode instanceof SubWorkflowNode) {
-					// ((SubWorkflowNode) middleNode).getWorkflow();
-					// this.configuration;
-					// TODO : Need to create a invoker!
-					// new WorkflowInterpreter()
-				} else {
-					throw new XBayaRuntimeException(
-							"Only Web services and subworkflows are supported for For-Each : Found : "
-									+ middleNode);
-				}
-
-				invokerList.add(invoker);
-				// find inputs
-				List<DataPort> inputPorts = middleNode.getInputPorts();
-				for (DataPort port : inputPorts) {
-					Object inputVal = InterpreterUtil.findInputFromPort(port,
-							this.invokerMap);
-
-					/*
-					 * Handle ForEachNode
-					 */
-					Node fromNode = port.getFromNode();
-					// if (fromNode instanceof ForEachNode) {
-					inputVal = input;
-					// }
-
-					if (null == inputVal) {
-						throw new WorkFlowInterpreterException(
-								"Unable to find inputs for the node:"
-										+ middleNode.getID());
-					}
-					invoker.setInput(port.getName(), inputVal);
-				}
-				invoker.invoke();
-			}
-		}
-
-		// String arrayElementName = foreachWSNode.getOperationName() +
-		// "ArrayResponse";
-		// String outputStr = "<" + arrayElementName + ">";
-		String outputStr = "";
-		for (Iterator<Invoker> iterator = invokerList.iterator(); iterator
-				.hasNext();) {
-			Invoker workflowInvoker = iterator.next();
+    }
 
-			// /
-			Object output = workflowInvoker.getOutput(endForEachNode
-					.getInputPort(0).getFromPort().getName());
-			outputStr += "\n<value>" + output + "</value>";
-			counter.incrementAndGet();
-		}
-		// outputStr += "\n</" + arrayElementName + ">";
-		System.out.println(outputStr);
-		if (!(endForEachNode instanceof OutputNode)) {
-			tempInvoker.addOutput(endForEachNode.getOutputPort(0).getName(),
-					outputStr);
-		}
-		forEachNode.getGUI().setBodyColor(NodeState.FINISHED.color);
-	}
+    private Invoker getInvoker(Node middleNode, Invoker invoker) throws XBayaException {
+        if(middleNode instanceof WSNode) {
+            WSComponent wsComponent = (WSComponent) middleNode.getComponent();
+            invoker.setup();
+            invoker.setOperation(wsComponent.getOperationName());
+        } else if (middleNode instanceof SubWorkflowNode){
+            //((SubWorkflowNode) middleNode).getWorkflow();
+            //this.configuration;
+            // TODO : Need to create a invoker!
+            //new WorkflowInterpreter()
+        } else {
+            throw new XBayaRuntimeException("Only Web services and subworkflows are supported
for For-Each : Found : " + middleNode);
+        }
+        return invoker;
+    }
 
 	private void setInputValuesForForEach(Node middleNode,
 			LinkedList<String> listOfValues, Integer[] inputNumbers,



Mime
View raw message