Search in sources :

Example 6 with DataEdge

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

the class OutputNode 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
    List<DataEdge> edges = getEdges();
    if (edges.size() == 0) {
        setParameterType(null);
        if (!isConfigured()) {
            // Reset
            setName(OutputComponent.NAME);
            setDescription("");
            setMetadata(null);
        }
    } else if (edges.size() == 1) {
    // This happens when the second edges was wrongly added and removed.
    } else {
        // Should not happen
        throw new WorkflowRuntimeException("edges.size(): " + edges.size());
    }
}
Also used : DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 7 with DataEdge

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

the class ParameterNode method getEdges.

protected List<DataEdge> getEdges() {
    DataPort port = getPort();
    List<DataEdge> edges = port.getEdges();
    return edges;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Example 8 with DataEdge

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

Example 9 with DataEdge

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

the class S3InputNode 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 10 with DataEdge

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

the class S3InputNode 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)

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