Search in sources :

Example 6 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType 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 7 with DataType

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

use of org.apache.airavata.model.appcatalog.appinterface.DataType in project airavata by apache.

the class GraphUtil method validateConnection.

/**
 * @param edge
 * @throws GraphException
 */
public static void validateConnection(Edge edge) throws GraphException {
    Port fromPort = edge.getFromPort();
    Port toPort = edge.getToPort();
    if (edge instanceof ControlEdge) {
        if (!(fromPort instanceof ControlPort && toPort instanceof ControlPort)) {
            throw new GraphException(MessageConstants.UNEXPECTED_ERROR);
        }
    } else if (edge instanceof DataEdge) {
        if (fromPort instanceof EPRPort) {
            // TODO
            return;
        }
        if (!(fromPort instanceof DataPort || fromPort instanceof EPRPort) || !(toPort instanceof DataPort)) {
            throw new GraphException(MessageConstants.UNEXPECTED_ERROR);
        }
        DataPort fromDataPort = (DataPort) fromPort;
        DataPort toDataPort = (DataPort) toPort;
        DataType fromType = fromDataPort.getType();
        DataType toType = toDataPort.getType();
        if (toDataPort.getEdges().size() > 1) {
            throw new GraphException(MessageConstants.MORE_THAN_ONE_CONNECTIONS);
        }
        // ok
        if (fromPort.getNode() instanceof WSNode) {
            if ("registerStream".equals(((WSNode) fromPort.getNode()).getOperationName())) {
                return;
            }
        }
        if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE) || fromType.equals(new QName(WSConstants.XSD_NS_URI, "anyType")) || toType == null || toType.equals(WSConstants.XSD_ANY_TYPE) || toType.equals(new QName(WSConstants.XSD_NS_URI, "anyType")) || fromType.equals(toType)) && (fromType == null || fromType.equals(WSConstants.LEAD_ANY_TYPE) || fromType.equals(new QName(WSConstants.LEAD_NS_URI, "anyType")) || toType == null || toType.equals(WSConstants.LEAD_ANY_TYPE) || toType.equals(new QName(WSConstants.LEAD_NS_URI, "anyType")) || fromType.equals(toType))) {
            throw new GraphException("Cannot connect ports with different types:" + " \nfrom=\t" + fromType + " \nto=\t" + toType + "");
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) DataPort(org.apache.airavata.workflow.model.graph.DataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort) QName(javax.xml.namespace.QName) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Example 9 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType 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 10 with DataType

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

Aggregations

DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)15 DataPort (org.apache.airavata.workflow.model.graph.DataPort)10 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)8 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)4 Port (org.apache.airavata.workflow.model.graph.Port)4 XmlElement (org.xmlpull.infoset.XmlElement)4 GraphException (org.apache.airavata.workflow.model.graph.GraphException)3 XBayaTextComponent (org.apache.airavata.xbaya.ui.widgets.XBayaTextComponent)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 JComboBox (javax.swing.JComboBox)2 JLabel (javax.swing.JLabel)2 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)2 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)2 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)2 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)2 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)2 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)2