Search in sources :

Example 1 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class InterpreterUtil method findInputFromPort.

public static Object findInputFromPort(DataPort inputPort) throws WorkflowException {
    Object outputVal = null;
    Node fromNode = inputPort.getFromNode();
    if (fromNode instanceof InputNode) {
        outputVal = ((InputNode) fromNode).getDefaultValue();
    // } else if (fromNode instanceof ConstantNode) {
    // outputVal = ((ConstantNode) fromNode).getValue();
    // } else if (fromNode instanceof DifferedInputNode && ((DifferedInputNode) fromNode).isConfigured()) {
    // outputVal = ((DifferedInputNode) fromNode).getDefaultValue();
    // } else if (fromNode instanceof EndifNode || fromNode instanceof DoWhileNode  || fromNode instanceof EndDoWhileNode) {
    // Invoker fromInvoker = invokerMap.get(fromNode);
    // outputVal = fromInvoker.getOutput(inputPort.getFromPort().getID());
    // } else if (fromNode instanceof InstanceNode) {
    // return ((InstanceNode) fromNode).getOutputInstanceId();
    // } else if (fromNode instanceof EndForEachNode) {
    // outputVal = "";
    // Invoker workflowInvoker = invokerMap.get(fromNode);
    // String outputName = "";
    // if (inputPort instanceof SystemDataPort) {
    // outputName = ((SystemDataPort) inputPort).getWSComponentPort().getName();
    // 
    // } else if (inputPort instanceof WSPort) {
    // outputName = ((SystemDataPort) fromNode.getInputPort(fromNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort())))
    // .getWSComponentPort().getName();
    // }
    // XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + workflowInvoker.getOutput(outputName) + "</temp>");
    // Iterator valItr = msgElmt.children().iterator();
    // while (valItr.hasNext()) {
    // Object object2 = valItr.next();
    // if (object2 instanceof XmlElement) {
    // 
    // if (((XmlElement) object2).children().iterator().hasNext()) {
    // outputVal = outputVal + StringUtil.DELIMETER  + StringUtil.quoteString(((XmlElement) object2).children().iterator().next().toString());
    // }
    // }
    // }
    // 
    // if (((String) outputVal).length() == 0) {
    // throw new WorkflowException("Empty Output Generated");
    // }
    // outputVal = ((String) outputVal).substring(1, ((String) outputVal).length());
    // } else {
    // Invoker fromInvoker = invokerMap.get(fromNode);
    // try {
    // if (fromInvoker != null)
    // outputVal = fromInvoker.getOutput(inputPort.getFromPort().getName());
    // 
    // } catch (Exception e) {
    // // if the value is still null look it up from the inputport name
    // // because the value is set to the input port name at some point
    // // there is no harm in doing this
    // if (null == outputVal) {
    // outputVal = fromInvoker.getOutput(inputPort.getName());
    // }
    // }
    }
    return outputVal;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node)

Example 2 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class InterpreterUtil method getNumberOfInputsForForEachNode.

public static Integer[] getNumberOfInputsForForEachNode(final ForEachNode forEachNode, Map<Node, Invoker> invokerMap) throws WorkflowException {
    List<DataPort> inputPorts = forEachNode.getInputPorts();
    Integer[] inputNumbers = new Integer[inputPorts.size()];
    for (DataPort forEachInputPort : inputPorts) {
        // if input node for for-each is WSNode
        Node forEachInputNode = forEachInputPort.getFromNode();
        int index = 0;
        Object returnValForProvenance = null;
        if (forEachInputNode instanceof InputNode) {
            returnValForProvenance = InterpreterUtil.findInputFromPort(forEachInputPort, invokerMap);
            if (null == returnValForProvenance) {
                throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
            }
            String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
            inputNumbers[inputPorts.indexOf(forEachInputPort)] = vals.length;
        }
    }
    return inputNumbers;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkFlowInterpreterException(org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)

Example 3 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class Workflow method getInputs.

/**
 * Returns the inputs of the workflow.
 *
 * @return The inputs of the workflow.
 * @throws ComponentException
 */
public List<WSComponentPort> getInputs() throws ComponentException {
    List<InputNode> nodes = GraphUtil.getNodes(this.graph, InputNode.class);
    List<WSComponentPort> ports = new ArrayList<WSComponentPort>();
    for (InputNode inputNode : nodes) {
        ports.add(new WSComponentPort(inputNode.getName(), inputNode.getOutputPorts().get(0).getType(), null));
    }
    return ports;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) ArrayList(java.util.ArrayList) WSComponentPort(org.apache.airavata.workflow.model.component.ws.WSComponentPort)

Example 4 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class WorkflowWSDL method addParameter.

/**
 * Adds the parameter element.
 *
 * @param node
 * @param sequence
 * @param schema
 * @return The parameter element
 */
private XmlElement addParameter(ParameterNode node, XmlElement sequence, XmlElement schema) {
    XmlElement element;
    SystemDataPort port = node.getPort();
    element = addParameter(node, port, sequence, schema);
    // 
    // Annotation
    // 
    String description = node.getDescription();
    XmlElement appinfo = node.getMetadata();
    // description
    if (description != null && description.trim().length() != 0) {
        XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
        XmlElement documentation = annotation.addElement(WSConstants.DOCUMENTATION_TAG);
        documentation.setText(node.getDescription());
    }
    // appinfo
    if (appinfo != null) {
        XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
        try {
            annotation.addElement(XMLUtil.deepClone(appinfo));
        } catch (AiravataException e) {
            log.error(e.getMessage(), e);
        }
    }
    // 
    if (node instanceof InputNode) {
        InputNode inputNode = (InputNode) node;
        Object value = inputNode.getDefaultValue();
        if (value instanceof String) {
            element.setAttributeValue(WSConstants.DEFAULT_ATTRIBUTE, (String) value);
        } else if (value instanceof XmlElement) {
            // Add the default value in <annotation><default> because there
            // is no standard way.
            XmlElement valueElement = null;
            try {
                valueElement = XMLUtil.deepClone((XmlElement) value);
            } catch (AiravataException e) {
                log.error(e.getMessage(), e);
            }
            XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
            XmlElement defaultElement = annotation.addElement(WSComponentPort.DEFAULT);
            defaultElement.addElement(valueElement);
        }
    }
    return element;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) SystemDataPort(org.apache.airavata.workflow.model.graph.system.SystemDataPort) XmlElement(org.xmlpull.infoset.XmlElement) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 5 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class XBayaUtil method getInputsForForEachNode.

public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) throws WorkflowException {
    Node forEachInputNode = forEachNode.getInputPort(0).getFromNode();
    // if input node for for-each is WSNode
    Object returnValForProvenance = null;
    if (forEachInputNode instanceof InputNode) {
        for (DataPort dataPort : forEachNode.getInputPorts()) {
            returnValForProvenance = XBayaUtil.findInputFromPort(dataPort, invokerMap);
            if (null == returnValForProvenance) {
                throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
            }
            String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
            listOfValues.addAll(Arrays.asList(vals));
        }
    }
    return returnValForProvenance;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkFlowInterpreterException(org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)

Aggregations

InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)29 Node (org.apache.airavata.workflow.model.graph.Node)14 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)10 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)10 Port (org.apache.airavata.workflow.model.graph.Port)9 DataPort (org.apache.airavata.workflow.model.graph.DataPort)7 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)7 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)7 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)7 GraphException (org.apache.airavata.workflow.model.graph.GraphException)6 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)6 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)6 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)6 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)6 LinkedList (java.util.LinkedList)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)4 WorkFlowInterpreterException (org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)3