Search in sources :

Example 6 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class EndDoWhileNode method portTypeChanged.

/**
 * @see org.apache.airavata.workflow.model.graph.system.SystemNode#portTypeChanged(org.apache.airavata.workflow.model.graph.system.SystemDataPort)
 */
@Override
protected void portTypeChanged(SystemDataPort port) throws GraphException {
    super.portTypeChanged(port);
    List<DataPort> inputPorts = getInputPorts();
    List<DataPort> outputPorts = getOutputPorts();
    Kind kind = port.getKind();
    int index;
    if (kind == Kind.DATA_IN) {
        index = inputPorts.indexOf(port);
    } else if (kind == Kind.DATA_OUT) {
        index = outputPorts.indexOf(port);
    } else {
        throw new WorkflowRuntimeException();
    }
    SystemDataPort inputPort = (SystemDataPort) inputPorts.get(index);
    SystemDataPort outputPort = (SystemDataPort) outputPorts.get(index);
    DataType inputType = inputPort.getType();
    DataType outputType = outputPort.getType();
    DataType portType = port.getType();
    if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
        // Do nothing
        return;
    }
    if (port == inputPort) {
        // input -> output
        if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
            outputPort.copyType(port, 1);
        } else if (outputType.equals(portType)) {
        // Do nothing.
        } else {
        // XXX cannot parse array from WSDL.
        // String message = "The type of input " + index + " ("
        // + inputType + ") of " + getID()
        // + " must be same as the type of output " + index + " ("
        // + outputType + ").";
        // throw new GraphException(message);
        }
    } else if (port == outputPort) {
        // output -> input1
        if (inputType.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort.copyType(port, -1);
        } else if (inputType.equals(portType)) {
        // Do nothing.
        } else {
        // XXX cannot parse array from WSDL.
        // String message = "The type of input " + index + " ("
        // + inputType + ") of " + getID()
        // + " must be same as the type of output " + index + " ("
        // + outputType + ").";
        // throw new GraphException(message);
        }
    } else {
        throw new WorkflowRuntimeException();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 7 with DataType

use of org.apache.airavata.model.application.io.DataType 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 8 with DataType

use of org.apache.airavata.model.application.io.DataType 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)

Example 9 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class DifferedInputNode method edgeWasRemoved.

/**
 * Called whan an Edge was removed from the parameter port. Change the name
 * of the node.
 *
 * @see edu.indiana.extreme.xbaya.graph.impl.NodeImpl#edgeWasRemoved(edu.indiana.extreme.xbaya.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.application.io.DataType) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Example 10 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class SystemNode 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 {
    super.edgeWasAdded(edge);
    GraphUtil.validateConnection(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) {
            // setType() propagates the change to the whole workflow.
            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) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) 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

DataType (org.apache.airavata.model.application.io.DataType)18 DataPort (org.apache.airavata.workflow.model.graph.DataPort)13 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)10 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)10 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)6 GraphException (org.apache.airavata.workflow.model.graph.GraphException)6 Port (org.apache.airavata.workflow.model.graph.Port)6 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)5 Kind (org.apache.airavata.workflow.model.graph.Port.Kind)4 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)3 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)2 Edge (org.apache.airavata.workflow.model.graph.Edge)2 List (java.util.List)1 TaskException (org.apache.airavata.gfac.core.task.TaskException)1 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)1 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)1 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)1 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)1 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)1 TException (org.apache.thrift.TException)1