Search in sources :

Example 11 with WSPort

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

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

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

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

the class SystemDataPort method copyType.

/**
 * @param port
 * @param arrayIncrement
 * @throws GraphException
 */
public void copyType(DataPort port, int arrayIncrement) throws GraphException {
    DataType newType = port.getType();
    if (this.type != newType) {
        this.type = newType;
        if (port instanceof WSPort) {
            WSPort wsPort = (WSPort) port;
            this.wsComponentPort = wsPort.getComponentPort();
            this.arrayDimension = 0;
        } else if (port instanceof SystemDataPort) {
            SystemDataPort systemPort = (SystemDataPort) port;
            this.wsComponentPort = systemPort.getWSComponentPort();
            this.arrayDimension = systemPort.getArrayDimension() + arrayIncrement;
        }
        // propagate to other ports of this node.
        getNode().portTypeChanged(this);
        // propagate to the connected ports.
        Kind kind = getKind();
        for (DataEdge edge : getEdges()) {
            if (kind == Kind.DATA_IN) {
                DataPort fromPort = edge.getFromPort();
                fromPort.copyType(this);
            } else if (kind == Kind.DATA_OUT) {
                DataPort toPort = edge.getToPort();
                toPort.copyType(this);
            } 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) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 15 with WSPort

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

the class WorkflowModifier method createInputNodes.

/**
 * @param graph
 * @param originalFromPorts
 * @throws GraphException
 */
private void createInputNodes(WSGraph graph, Set<WSPort> originalFromPorts) throws GraphException {
    InputComponent inputComponent = new InputComponent();
    for (WSPort originalFromPort : originalFromPorts) {
        InputNode inputNode = inputComponent.createNode(graph);
        List<Port> originalToPorts = originalFromPort.getToPorts();
        boolean first = true;
        for (Port originalToPort : originalToPorts) {
            String toPortID = originalToPort.getID();
            Port toPort = graph.getPort(toPortID);
            graph.addEdge(inputNode.getPort(), toPort);
            if (first) {
                first = false;
                Point position = NodeController.getGUI(originalToPort).getPosition();
                Point inputNodePosition = new Point(0, position.y);
                inputNode.setPosition(inputNodePosition);
            }
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) Point(java.awt.Point)

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