use of org.apache.airavata.workflow.engine.invoker.Invoker in project airavata by apache.
the class WorkflowInterpreter method handleDynamicComponent.
private void handleDynamicComponent(Node node) throws WorkflowException {
DynamicComponent dynamicComponent = (DynamicComponent) node.getComponent();
String className = dynamicComponent.getClassName();
String operationName = dynamicComponent.getOperationName();
URL implJarLocation = dynamicComponent.getImplJarLocation();
DynamicNode dynamicNode = (DynamicNode) node;
LinkedList<Object> inputs = new LinkedList<Object>();
List<DataPort> inputPorts = dynamicNode.getInputPorts();
for (DataPort dataPort : inputPorts) {
Object inputVal = InterpreterUtil.findInputFromPort(dataPort, this.invokerMap);
/*
* Set type after get input value, and override inputValue if output
* type is array
*/
Node fromNode = dataPort.getFromNode();
DataType type = null;
if (fromNode instanceof InputNode) {
type = DataType.STRING;
} else if (fromNode instanceof ConstantNode) {
type = ((ConstantNode) fromNode).getType();
} else if ((dataPort.getFromPort() instanceof WSPort) && BasicTypeMapping.isArrayType(((WSPort) dataPort.getFromPort()).getComponentPort().getElement())) {
Invoker fromInvoker = this.invokerMap.get(fromNode);
// inputVal = BasicTypeMapping.getOutputArray(XmlConstants.BUILDER.parseFragmentFromString(fromInvoker.getOutputs().toString()), dataPort
// .getFromPort().getName(), BasicTypeMapping.getSimpleTypeIndex(((DataPort) dataPort.getFromPort()).getType()));
type = ((DataPort) dataPort.getFromPort()).getType();
} else {
type = ((DataPort) dataPort.getFromPort()).getType();
}
if (null == inputVal) {
throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + node.getID());
}
// inputs.add(BasicTypeMapping.getObjectOfType(type, inputVal));
}
DynamicInvoker dynamicInvoker = new DynamicInvoker(className, implJarLocation, operationName, inputs.toArray());
this.invokerMap.put(node, dynamicInvoker);
dynamicInvoker.setup();
dynamicInvoker.invoke();
node.setState(NodeExecutionState.FINISHED);
}
Aggregations