Search in sources :

Example 1 with DynamicInvoker

use of org.apache.airavata.workflow.engine.invoker.DynamicInvoker 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);
}
Also used : DynamicComponent(org.apache.airavata.workflow.model.component.dynamic.DynamicComponent) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) URL(java.net.URL) DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DynamicInvoker(org.apache.airavata.workflow.engine.invoker.DynamicInvoker) Invoker(org.apache.airavata.workflow.engine.invoker.Invoker) DynamicInvoker(org.apache.airavata.workflow.engine.invoker.DynamicInvoker) ExpCatChildDataType(org.apache.airavata.registry.cpi.ExpCatChildDataType) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)

Aggregations

URL (java.net.URL)1 ExpCatChildDataType (org.apache.airavata.registry.cpi.ExpCatChildDataType)1 DynamicInvoker (org.apache.airavata.workflow.engine.invoker.DynamicInvoker)1 Invoker (org.apache.airavata.workflow.engine.invoker.Invoker)1 DynamicComponent (org.apache.airavata.workflow.model.component.dynamic.DynamicComponent)1 DataPort (org.apache.airavata.workflow.model.graph.DataPort)1 Node (org.apache.airavata.workflow.model.graph.Node)1 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)1 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)1 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)1 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)1