Search in sources :

Example 1 with WSPort

use of org.apache.airavata.workflow.model.graph.ws.WSPort 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)

Example 2 with WSPort

use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.

the class GraphUtil method propagateTypes.

/**
 * @param graph
 * @throws GraphException
 */
public static void propagateTypes(Graph graph) throws GraphException {
    List<WSPort> wsPorts = getPorts(graph, WSPort.class);
    for (WSPort wsPort : wsPorts) {
        List<DataEdge> edges = wsPort.getEdges();
        for (DataEdge edge : edges) {
            DataPort fromPort = edge.getFromPort();
            DataPort toPort = edge.getToPort();
            if (fromPort == wsPort) {
                toPort.copyType(wsPort);
            } else if (toPort == wsPort) {
                fromPort.copyType(wsPort);
            } else {
                throw new WorkflowRuntimeException();
            }
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 3 with WSPort

use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.

the class WorkflowModifier method getFinalOutputPorts.

/**
 * @param originalGraph
 * @param graph
 * @return The final output ports.
 */
private Set<WSPort> getFinalOutputPorts(WSGraph originalGraph, WSGraph graph) {
    Collection<Port> inputPorts = GraphUtil.getPorts(graph, Port.Kind.DATA_IN);
    Set<WSPort> originalFromPorts = new HashSet<WSPort>();
    for (Port inputPort : inputPorts) {
        Port fromPort = inputPort.getFromPort();
        if (fromPort == null) {
            // This input port is not connected.
            String inputPortID = inputPort.getID();
            logger.debug("id: " + inputPortID);
            Port originalInputPort = originalGraph.getPort(inputPortID);
            // No duplicate in set.
            Port originalFromPort = originalInputPort.getFromPort();
            originalFromPorts.add((WSPort) originalFromPort);
        }
    }
    return originalFromPorts;
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) HashSet(java.util.HashSet)

Example 4 with WSPort

use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.

the class InputNode method edgeWasRemoved.

/**
 * Called whan an Edge was removed from the parameter port. Change the name of the node.
 *
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
 */
@Override
protected void edgeWasRemoved(Edge removedEdge) {
    super.edgeWasRemoved(removedEdge);
    // TODO organize this.
    List<DataEdge> edges = getEdges();
    if (edges.size() == 0) {
        setParameterType(null);
        if (!isConfigured()) {
            // Reset
            setName(getComponent().getName());
            setDescription("");
            setDefaultValue(null);
            setMetadata(null);
        }
    } else {
        Edge edge = edges.get(0);
        Port toPort = edge.getToPort();
        WSPort toWsPort = (WSPort) toPort;
        DataType toType = toWsPort.getType();
        setParameterType(toType);
        if (!isConfigured()) {
            // Copy
            copyDefaultConfiguration(toWsPort);
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponentPort(org.apache.airavata.workflow.model.component.ws.WSComponentPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Example 5 with WSPort

use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.

the class S3InputNode method edgeWasRemoved.

/**
 * Called whan an Edge was removed from the parameter port. Change the name of the node.
 *
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
 */
@Override
protected void edgeWasRemoved(Edge removedEdge) {
    super.edgeWasRemoved(removedEdge);
    // TODO organize this.
    List<DataEdge> edges = getEdges();
    if (edges.size() == 0) {
        setParameterType(null);
        if (!isConfigured()) {
            // Reset
            setName(getComponent().getName());
            setDescription("");
            setDefaultValue(null);
            setMetadata(null);
        }
    } else {
        Edge edge = edges.get(0);
        Port toPort = edge.getToPort();
        WSPort toWsPort = (WSPort) toPort;
        DataType toType = toWsPort.getType();
        setParameterType(toType);
        if (!isConfigured()) {
            // Copy
            copyDefaultConfiguration(toWsPort);
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponentPort(org.apache.airavata.workflow.model.component.ws.WSComponentPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Aggregations

WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)17 DataPort (org.apache.airavata.workflow.model.graph.DataPort)12 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)11 Port (org.apache.airavata.workflow.model.graph.Port)7 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)6 DataType (org.apache.airavata.model.application.io.DataType)5 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)4 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)4 Edge (org.apache.airavata.workflow.model.graph.Edge)4 GraphException (org.apache.airavata.workflow.model.graph.GraphException)4 Node (org.apache.airavata.workflow.model.graph.Node)3 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)3 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)3 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)2 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)2 Point (java.awt.Point)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 ExpCatChildDataType (org.apache.airavata.registry.cpi.ExpCatChildDataType)1 RegistryException (org.apache.airavata.registry.cpi.RegistryException)1