Search in sources :

Example 1 with ControlEdge

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

the class EdgeGUI method paint.

/**
 * @param g
 */
protected void paint(Graphics2D g) {
    DrawUtils.initializeGraphics2D(g);
    Point point1 = getFromPosition();
    Point point2 = getToPosition();
    g.setColor(lineColor);
    Stroke originalStroke = g.getStroke();
    if (this.edge instanceof ControlEdge) {
        g.setStroke(EdgeGUI.CONTROL_EDGE_STROKE);
    }
    paintLine(point1, point2, g);
    g.setStroke(originalStroke);
    g.setColor(this.selected ? pointColor : selectedPointColor);
    Point midPoint = getMiddlePosition();
    g.fillArc(midPoint.x - POINT_SIZE / 2, midPoint.y - POINT_SIZE / 2, POINT_SIZE, POINT_SIZE, 0, 360);
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Point(java.awt.Point) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Example 2 with ControlEdge

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

the class ExitNode method getEdges.

protected List<ControlEdge> getEdges() {
    PortImpl port = getControlInPort();
    List<ControlEdge> edges = (List<ControlEdge>) port.getEdges();
    return edges;
}
Also used : List(java.util.List) PortImpl(org.apache.airavata.workflow.model.graph.impl.PortImpl) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Example 3 with ControlEdge

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

the class InstanceNode method edgeWasAdded.

/**
 * @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);
    if (edge instanceof ControlEdge) {
        Port toPort = edge.getToPort();
        Node toNode = toPort.getNode();
        /*
             * check if there is already more than instance node connecting to destination node
             */
        if (!(toNode instanceof InstanceNode)) {
            for (Node node : toNode.getControlInPort().getFromNodes()) {
                if ((node instanceof InstanceNode) && this != node) {
                    throw new GraphException("Cannot connect more than one instance node to another node.");
                }
            }
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Example 4 with ControlEdge

use of org.apache.airavata.workflow.model.graph.ControlEdge 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 5 with ControlEdge

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

the class WSGraphFactory method createEdge.

/**
 * @see org.apache.airavata.workflow.model.graph.GraphFactory#createEdge(org.xmlpull.infoset.XmlElement)
 */
public EdgeImpl createEdge(XmlElement edgeElement) {
    String type = edgeElement.attributeValue(GraphSchema.NS, GraphSchema.EDGE_TYPE_ATTRIBUTE);
    EdgeImpl edge;
    if (GraphSchema.EDGE_TYPE_DATA.equals(type)) {
        edge = new DataEdge(edgeElement);
    } else if (GraphSchema.PORT_TYPE_CONTROL.equals(type)) {
        edge = new ControlEdge(edgeElement);
    } else {
        // Default is WsPort because of backword compatibility
        edge = new DataEdge(edgeElement);
    }
    return edge;
}
Also used : DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) EdgeImpl(org.apache.airavata.workflow.model.graph.impl.EdgeImpl) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Aggregations

ControlEdge (org.apache.airavata.workflow.model.graph.ControlEdge)7 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)4 EdgeImpl (org.apache.airavata.workflow.model.graph.impl.EdgeImpl)3 GraphException (org.apache.airavata.workflow.model.graph.GraphException)2 Port (org.apache.airavata.workflow.model.graph.Port)2 BasicStroke (java.awt.BasicStroke)1 Point (java.awt.Point)1 Stroke (java.awt.Stroke)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)1 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)1 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)1 DataPort (org.apache.airavata.workflow.model.graph.DataPort)1 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)1 Node (org.apache.airavata.workflow.model.graph.Node)1 Kind (org.apache.airavata.workflow.model.graph.Port.Kind)1 PortImpl (org.apache.airavata.workflow.model.graph.impl.PortImpl)1 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)1 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)1