Search in sources :

Example 11 with GraphException

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

the class GraphImpl method removePort.

/**
 * @param port
 * @throws GraphException
 */
public void removePort(Port port) throws GraphException {
    if (port == null) {
        throw new IllegalArgumentException("null");
    }
    if (!this.ports.contains(port)) {
        throw new GraphException("The graph doesn't contain the port that is being removed.");
    }
    // copy it so that we can remove edge without worrying about the
    // iteration issue.
    ArrayList<Edge> edgesToBeRemoved = new ArrayList<Edge>(port.getEdges());
    for (Edge edge : edgesToBeRemoved) {
        removeEdge(edge);
    }
    this.ports.remove(port);
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ArrayList(java.util.ArrayList) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Example 12 with GraphException

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

the class GraphImpl method removeNode.

/**
 * @see org.apache.airavata.workflow.model.graph.Graph#removeNode(org.apache.airavata.workflow.model.graph.Node)
 */
public void removeNode(Node node) throws GraphException {
    if (node == null) {
        throw new IllegalArgumentException("null");
    }
    if (!this.nodes.contains(node)) {
        throw new GraphException("The graph doesn't contain the node that is being removed.");
    }
    NodeImpl nodeImpl = (NodeImpl) node;
    // Remove edges connected to input ports.
    for (Iterator<DataPort> portItr = nodeImpl.getInputPorts().iterator(); portItr.hasNext(); ) {
        DataPort port = portItr.next();
        for (Iterator<DataEdge> edgeItr = port.getEdges().iterator(); edgeItr.hasNext(); ) {
            DataEdge edge = edgeItr.next();
            // Remove the edge from from-port.
            DataPort fromPort = edge.getFromPort();
            fromPort.removeEdge(edge);
            // remove the edge from this port. This is necessary so that
            // type update works properly.
            edgeItr.remove();
            // Remove the edge from the graph.
            this.edges.remove(edge);
            fromPort.getNode().edgeWasRemoved(edge);
        }
        // Remove the port from the node.
        portItr.remove();
        // Remove the port from the graph.
        this.ports.remove(port);
    }
    // Remove edges connected to output ports.
    for (Iterator<DataPort> portItr = nodeImpl.getOutputPorts().iterator(); portItr.hasNext(); ) {
        DataPort port = portItr.next();
        for (Iterator<DataEdge> edgeItr = port.getEdges().iterator(); edgeItr.hasNext(); ) {
            DataEdge edge = edgeItr.next();
            DataPort toPort = edge.getToPort();
            toPort.removeEdge(edge);
            edgeItr.remove();
            this.edges.remove(edge);
            toPort.getNode().edgeWasRemoved(edge);
        }
        portItr.remove();
        this.ports.remove(port);
    }
    for (Iterator<ControlPort> portItr = nodeImpl.getControlOutPorts().iterator(); portItr.hasNext(); ) {
        PortImpl port = portItr.next();
        for (Iterator<? extends EdgeImpl> edgeItr = port.getEdges().iterator(); edgeItr.hasNext(); ) {
            EdgeImpl edge = edgeItr.next();
            PortImpl toPort = edge.getToPort();
            toPort.removeEdge(edge);
            edgeItr.remove();
            this.edges.remove(edge);
            toPort.getNode().edgeWasRemoved(edge);
        }
        portItr.remove();
        this.ports.remove(port);
    }
    PortImpl controlInPort = nodeImpl.getControlInPort();
    if (controlInPort != null) {
        for (Iterator<? extends EdgeImpl> edgeItr = controlInPort.getEdges().iterator(); edgeItr.hasNext(); ) {
            EdgeImpl edge = edgeItr.next();
            PortImpl fromPort = edge.getFromPort();
            fromPort.removeEdge(edge);
            edgeItr.remove();
            this.edges.remove(edge);
            fromPort.getNode().edgeWasRemoved(edge);
        }
        this.ports.remove(controlInPort);
    }
    PortImpl eprPort = nodeImpl.getEPRPort();
    if (eprPort != null) {
        for (Iterator<? extends EdgeImpl> edgeItr = eprPort.getEdges().iterator(); edgeItr.hasNext(); ) {
            EdgeImpl edge = edgeItr.next();
            PortImpl toPort = edge.getToPort();
            toPort.removeEdge(edge);
            edgeItr.remove();
            this.edges.remove(edge);
            toPort.getNode().edgeWasRemoved(edge);
        }
        this.ports.remove(eprPort);
    }
    this.nodes.remove(node);
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) SystemDataPort(org.apache.airavata.workflow.model.graph.system.SystemDataPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort)

Example 13 with GraphException

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

the class ConstantNode 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 this method can be removed.
    Port toPort = edge.getToPort();
    if (edge instanceof DataEdge) {
        DataPort toDataPort = (DataPort) toPort;
        DataType toType = toDataPort.getType();
        List edges = getEdges();
        if (edges.size() == 1) {
            // The first edge.
            this.type = toType;
        } else if (edges.size() > 1) {
            // Not the first edge.
            if (!toType.equals(WSConstants.XSD_ANY_TYPE) && !this.type.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) GraphException(org.apache.airavata.workflow.model.graph.GraphException) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.application.io.DataType) List(java.util.List) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 14 with GraphException

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

Example 15 with GraphException

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

the class DifferedInputNode method edgeWasAdded.

/**
 * Called when an Edge was added to the parameter port. Change the name of
 * this node.
 *
 * @throws GraphException
 *
 * @see edu.indiana.extreme.xbaya.graph.impl.NodeImpl#edgeWasAdded(edu.indiana.extreme.xbaya.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.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

GraphException (org.apache.airavata.workflow.model.graph.GraphException)38 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)18 DataPort (org.apache.airavata.workflow.model.graph.DataPort)15 Node (org.apache.airavata.workflow.model.graph.Node)11 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)10 Port (org.apache.airavata.workflow.model.graph.Port)9 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)9 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)9 Workflow (org.apache.airavata.workflow.model.wf.Workflow)9 IOException (java.io.IOException)6 DataType (org.apache.airavata.model.application.io.DataType)6 LinkedList (java.util.LinkedList)5 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)5 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)5 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)5 XmlElement (org.xmlpull.infoset.XmlElement)5 Point (java.awt.Point)4 File (java.io.File)4 JsonObject (com.google.gson.JsonObject)3 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)3