use of org.apache.airavata.workflow.model.component.ws.WSComponent in project airavata by apache.
the class Workflow method bindComponents.
/**
* Binds WSNodes to components
*
* @throws ComponentException
* @throws GraphException
*/
public void bindComponents() throws ComponentException, GraphException {
// This map is to avoid creating multiple instances for the a component
Map<WSComponentKey, WSComponent> components = new HashMap<WSComponentKey, WSComponent>();
for (WSNode node : GraphUtil.getWSNodes(this.graph)) {
String id = node.getWSDLID();
logger.debug("id: " + id);
// WsdlDefinitions wsdl = this.wsdlMap.get(id);
//
// if (wsdl == null) {
// // XXX This happens while loading a workflow that is created by
// // the version 2.2.6_2 or below from GPEL.
// // Need to look for wsdl manually.
// // id should be look like
// // {http://www.extreme.indiana.edu/math/}Adder
// for (WsdlDefinitions w : this.wsdlMap.values()) {
// QName name = WSDLUtil.getWSDLQName(w);
// if (name.toString().equals(id)) {
// wsdl = w;
// break;
// }
// }
// }
// if (wsdl == null) {
// continue;
// }
// try {
// QName portType = node.getPortTypeQName();
// if (portType == null) {
// // XXX This happens while parsing xwf created by the version
// // 2.2.6_1 or below.
// portType = WSDLUtil.getFirstPortTypeQName(wsdl);
// }
// String operation = node.getOperationName();
// if (operation == null) {
// // XXX This happens while parsing xwf created by the version
// // 2.2.6_1 or below.
// operation = WSDLUtil.getFirstOperationName(wsdl, portType);
// }
// WSComponentKey key = new WSComponentKey(id, portType, operation);
//
// WSComponent component = null;
// if (components.containsKey(key)) {
// component = components.get(key);
// } else {
// //FIXME
// // component = WSComponentFactory.createComponent(wsdl, portType, operation);
// components.put(key, component);
// }
// node.setComponent(component);
// } catch (UtilsException e) {
// logger.error(e.getMessage(), e);
// }
}
this.graph.fixParameterNodes();
GraphUtil.propagateTypes(this.graph);
}
use of org.apache.airavata.workflow.model.component.ws.WSComponent in project airavata by apache.
the class WorkflowInterpreter method runInThread.
private void runInThread(final LinkedList<String> listOfValues, ForEachNode forEachNode, final Node middleNode, List<Node> endForEachNodes, Map<Node, Invoker> tempInvoker, AtomicInteger counter, final Integer[] inputNumber) throws WorkflowException, RegistryException, TException {
final LinkedList<String> taskIdList = new LinkedList<String>();
if (inputNumber.length > 1) {
List<String> inputValues = createInputValues(listOfValues, inputNumber);
for (final Iterator<String> iterator = inputValues.iterator(); iterator.hasNext(); ) {
final String input = iterator.next();
WSComponent wsComponent = (WSComponent) middleNode.getComponent();
final String invoker2 = createInvokerForEachSingleWSNode(middleNode, wsComponent);
taskIdList.add(invoker2);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
log.error(e.getLocalizedMessage(), e);
}
}
} else {
String invoker = null;
for (Iterator<String> iterator = listOfValues.iterator(); iterator.hasNext(); ) {
String input = iterator.next();
WSComponent wsComponent = (WSComponent) middleNode.getComponent();
taskIdList.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 = WorkflowInputUtil.parseValue((WSComponentPort) port.getComponentPort(), input);
// // }
//
// if (null == inputVal) {
// throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + middleNode.getID());
// }
// }
invoker = createInvokerForEachSingleWSNode(middleNode, wsComponent);
}
}
// String arrayElementName = foreachWSNode.getOperationName() +
// "ArrayResponse";
// String outputStr = "<" + arrayElementName + ">";
// invokerMap size and endForEachNodes size can be difference
// because we can create endForEachNode with n number of input/output
// ports so always have to use
// middleNode.getOutputPorts when iterate
String[] outputStr = new String[middleNode.getOutputPorts().size()];
int i = 0;
for (DataPort port : middleNode.getOutputPorts()) {
String outputString = "";
// for (Iterator<Invoker> iterator = taskIdList.iterator(); iterator.hasNext();) {
// Invoker workflowInvoker = iterator.next();
//
// // /
// Object output = workflowInvoker.getOutput(port.getName());
// if (output instanceof org.xmlpull.v1.builder.XmlElement) {
// org.xmlpull.v1.builder.XmlElement element = (org.xmlpull.v1.builder.XmlElement) ((org.xmlpull.v1.builder.XmlElement) output).children()
// .next();
// outputString += "\n" + XMLUtil.xmlElementToString(element);
// } else {
// outputString += "\n<value>" + output + "</value>";
// }
// counter.incrementAndGet();
// }
outputStr[i] = outputString;
System.out.println(outputStr[i]);
i++;
}
i = 0;
// outputStr += "\n</" + arrayElementName + ">";
int outputPortIndex = 0;
for (DataPort port : middleNode.getOutputPorts()) {
for (Node endForEachNode : endForEachNodes) {
if (tempInvoker.get(endForEachNode) != null) {
if (!(endForEachNode instanceof OutputNode)) {
((SystemComponentInvoker) tempInvoker.get(endForEachNode)).addOutput(port.getName(), outputStr[i]);
}
}
outputPortIndex++;
}
i++;
}
forEachNode.setState(NodeExecutionState.FINISHED);
}
use of org.apache.airavata.workflow.model.component.ws.WSComponent in project airavata by apache.
the class DoWhileHandler method handleDowhile.
/**
* To get only web service components attached to dowhile
*
* @param waitingNode
* @return list
*/
private ArrayList<Node> handleDowhile(ArrayList<Node> waitingNode, ArrayList<Node> finishedNodes) {
ArrayList<Node> list = new ArrayList<Node>();
for (Node node : waitingNode) {
Component component = node.getComponent();
if (component instanceof WSComponent) {
ControlPort control = node.getControlInPort();
boolean controlDone = true;
if (control != null) {
for (EdgeImpl edge : control.getEdges()) {
controlDone = controlDone && (finishedNodes.contains(edge.getFromPort().getNode()) || ((ControlPort) edge.getFromPort()).isConditionMet());
}
}
/*
* Check for input ports
*/
List<DataPort> inputPorts = node.getInputPorts();
boolean inputsDone = true;
for (DataPort dataPort : inputPorts) {
inputsDone = inputsDone && finishedNodes.contains(dataPort.getFromNode());
}
if (inputsDone && controlDone) {
list.add(node);
}
}
}
return list;
}
Aggregations