Search in sources :

Example 21 with DataEdge

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

the class InputNode method getParameterType.

/**
 * Returns the type of the parameter
 *
 * @return The type of the parameter (e.g. string, int)
 */
@Override
public DataType getParameterType() {
    List<DataEdge> edges = getEdges();
    DataType parameterType = super.getParameterType();
    if (parameterType == null && getEdges().size() > 0) {
        // This happens when the graph XML doesn't have parameterType.
        DataEdge edge = edges.get(0);
        DataPort toPort = edge.getToPort();
    // parameterType = toPort.getType();
    }
    return parameterType;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType)

Example 22 with DataEdge

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

the class InputNode method edgeWasAdded.

/**
 * Called whan an Edge was added to the parameter port. Change the name of this node.
 *
 * @throws GraphException
 *
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    super.edgeWasAdded(edge);
    // TODO organize this.
    if (edge instanceof DataEdge) {
        DataEdge dataEdge = (DataEdge) edge;
        DataPort toPort = dataEdge.getToPort();
        DataType toType = toPort.getType();
        List<DataEdge> edges = getEdges();
        if (edges.size() == 1) {
            // The first edge.
            setParameterType(toType);
            if (!isConfigured() && toPort instanceof WSPort) {
                // Copy
                copyDefaultConfiguration((WSPort) toPort);
            }
        } else if (edges.size() > 1) {
            // Not the first edge.
            DataType parameterType = getParameterType();
            if (!toType.equals(WSConstants.XSD_ANY_TYPE) && !parameterType.equals(toType)) {
                throw new GraphException("Cannot connect ports with different types.");
            }
        } else {
            // Should not happen.
            throw new WorkflowRuntimeException("edges.size(): " + edges.size());
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 23 with DataEdge

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

the class OutputNode method getParameterType.

/**
 * Returns the type of the parameter
 *
 * @return The type of the parameter (e.g. string, int)
 */
@Override
public DataType getParameterType() {
    List<DataEdge> edges = getEdges();
    DataType parameterType = super.getParameterType();
    if (parameterType == null && getEdges().size() > 0) {
        Edge edge = edges.get(0);
        WSPort fromPort = (WSPort) edge.getFromPort();
        setParameterType(fromPort.getType());
    }
    return parameterType;
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataType(org.apache.airavata.model.application.io.DataType) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Example 24 with DataEdge

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

the class OutputNode method edgeWasAdded.

/**
 * Called whan an Edge was added to the parameter port. Change the name of this node.
 *
 * @throws GraphException
 *
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    super.edgeWasAdded(edge);
    // TODO organize
    Port fromPort = edge.getFromPort();
    if (edge instanceof DataEdge) {
        DataPort fromDataPort = (DataPort) fromPort;
        DataType fromType = fromDataPort.getType();
        List<DataEdge> edges = getEdges();
        if (edges.size() == 1) {
            setParameterType(fromType);
            if (!isConfigured() && fromDataPort instanceof WSPort) {
                setName(fromDataPort.getName());
                WSComponentPort componentPort = ((WSPort) fromDataPort).getComponentPort();
                setDescription(componentPort.getDescription());
                setMetadata(componentPort.getAppinfo());
            }
        } else {
            throw new GraphException("Cannot connect more than one output ports to the output parameter.");
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) 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.application.io.DataType) WSComponentPort(org.apache.airavata.workflow.model.component.ws.WSComponentPort)

Example 25 with DataEdge

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

the class EndForEachNode method edgeWasAdded.

/**
 * @throws GraphException
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    // XXX cannot detect if the type is array or not from WSDL at this
    // point. so no check here.
    // super.edgeWasAdded(edge);
    Port fromPort = edge.getFromPort();
    Port toPort = edge.getToPort();
    if (edge instanceof DataEdge) {
        if (fromPort instanceof EPRPort) {
            // TODO
            return;
        }
        DataPort fromDataPort = (DataPort) fromPort;
        DataPort toDataPort = (DataPort) toPort;
        DataType fromType = fromDataPort.getType();
        DataType toType = toDataPort.getType();
        if (fromDataPort.getNode() == this) {
            if (!(toType == null || toType.equals(WSConstants.XSD_ANY_TYPE))) {
                fromDataPort.copyType(toDataPort);
            }
        } else if (toDataPort.getNode() == this) {
            if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE))) {
                toDataPort.copyType(fromDataPort);
            }
        } else {
            throw new WorkflowRuntimeException();
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)29 DataPort (org.apache.airavata.workflow.model.graph.DataPort)23 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)12 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)12 Port (org.apache.airavata.workflow.model.graph.Port)11 DataType (org.apache.airavata.model.application.io.DataType)10 GraphException (org.apache.airavata.workflow.model.graph.GraphException)9 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)8 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)5 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)4 ControlEdge (org.apache.airavata.workflow.model.graph.ControlEdge)4 Edge (org.apache.airavata.workflow.model.graph.Edge)4 EdgeImpl (org.apache.airavata.workflow.model.graph.impl.EdgeImpl)4 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)3 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)2 Node (org.apache.airavata.workflow.model.graph.Node)2 SystemDataPort (org.apache.airavata.workflow.model.graph.system.SystemDataPort)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1