Search in sources :

Example 1 with StreamSourceNode

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

the class StreamSourceComponent method createNode.

/**
 * @see org.apache.airavata.workflow.model.component.Component#createNode(org.apache.airavata.workflow.model.graph.Graph)
 */
@Override
public StreamSourceNode createNode(Graph graph) {
    StreamSourceNode node = new StreamSourceNode(graph);
    if (this.streamName != null) {
        node.setName(NAME + "_" + this.streamName);
    } else {
        node.setName(NAME);
    }
    node.setComponent(this);
    // Creates a unique ID for the node. This has to be after setName().
    node.createID();
    // Creates a output port
    createPorts(node);
    return node;
}
Also used : StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode)

Example 2 with StreamSourceNode

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

the class GraphCanvas method mouseReleased.

private void mouseReleased(MouseEvent event) {
    Point point = event.getPoint();
    if (this.draggedNode != null) {
        NodeController.getGUI(this.draggedNode).setDraggedFlag(false);
        this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
        // Check if it s stream grouping
        if (draggedNode instanceof InputNode) {
            StreamSourceNode streamNode = NodeController.getGUI(this.graph).getStreamSourceAt(point);
            if (streamNode != null) {
                streamNode.addInputNode((InputNode) draggedNode);
            }
        }
        this.draggedNode = null;
    }
    if (this.draggedPort != null) {
        GraphPiece graphPiece = NodeController.getGUI(this.graph).getGraphPieceAt(point);
        if (graphPiece instanceof DynamicNode) {
            if (this.draggedPort.getKind() == Kind.DATA_OUT && draggedPort instanceof DataPort) {
                this.panel.setCursor(SwingUtil.CROSSHAIR_CURSOR);
                DynamicNode dynamicNode = (DynamicNode) graphPiece;
                dynamicNode.getComponent();
                DataPort freePort = dynamicNode.getFreeInPort();
                try {
                    freePort.copyType((DataPort) draggedPort);
                } catch (GraphException e) {
                    engine.getGUI().getErrorWindow().error(e);
                    return;
                }
                // selectInputPort(freePort);
                connect(this.draggedPort, freePort);
                this.dynamicNodeWithFreePort = null;
            }
        } else if (graphPiece instanceof Port) {
            Port port = (Port) graphPiece;
            if (this.draggedPort.getKind() == Kind.DATA_OUT && port.getKind() == Kind.DATA_IN) {
                connect(this.draggedPort, port);
            } else if (port.getKind() == Kind.DATA_OUT && this.draggedPort.getKind() == Kind.DATA_IN) {
                connect(port, this.draggedPort);
            } else if (this.draggedPort.getKind() == Kind.CONTROL_OUT && port.getKind() == Kind.CONTROL_IN) {
                connect(this.draggedPort, port);
            } else if (this.draggedPort.getKind() == Kind.CONTROL_IN && port.getKind() == Kind.CONTROL_OUT) {
                connect(port, this.draggedPort);
            } else if (this.draggedPort.getKind() == Kind.EPR && port.getKind() == Kind.DATA_IN) {
                connect(this.draggedPort, port);
            } else if (this.draggedPort.getKind() == Kind.DATA_IN && port.getKind() == Kind.EPR) {
                connect(port, this.draggedPort);
            }
        }
        this.draggedPort = null;
    }
    if (this.dynamicNodeWithFreePort != null) {
        try {
            this.dynamicNodeWithFreePort.removeLastDynamicallyAddedInPort();
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(e);
        }
    }
    /*
         * Multiple selected
         */
    if (this.mousePointForSelection != null) {
        double width = Math.abs(this.mousePoint.getX() - this.mousePointForSelection.getX());
        double height = Math.abs(this.mousePoint.getY() - this.mousePointForSelection.getY());
        int x = (int) (this.mousePoint.getX() > this.mousePointForSelection.getX() ? this.mousePointForSelection.getX() : this.mousePoint.getX());
        int y = (int) (this.mousePoint.getY() > this.mousePointForSelection.getY() ? this.mousePointForSelection.getY() : this.mousePoint.getY());
        this.multipleSelectedNodes = NodeController.getGUI(this.graph).getNodesIn(new Rectangle(x, y, (int) width, (int) height));
        selectNodes(this.multipleSelectedNodes);
        // clear mousepoint
        this.mousePointForSelection = null;
    }
    if (this.multipleSelectedNodes != null) {
        this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
    }
    maybeShowPopup(event);
    updateSize();
    this.panel.repaint();
    event.consume();
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) GraphPiece(org.apache.airavata.workflow.model.graph.GraphPiece) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) Rectangle(java.awt.Rectangle) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Point(java.awt.Point) Point(java.awt.Point)

Example 3 with StreamSourceNode

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

the class GraphUtil method getStreamSourceNodes.

/**
 * @param graph
 * @return
 */
public static LinkedList<StreamSourceNode> getStreamSourceNodes(WSGraph graph) {
    List<NodeImpl> nodes = graph.getNodes();
    LinkedList<StreamSourceNode> ret = new LinkedList<StreamSourceNode>();
    for (NodeImpl nodeImpl : nodes) {
        if (nodeImpl instanceof StreamSourceNode) {
            ret.add((StreamSourceNode) nodeImpl);
        }
    }
    return ret;
}
Also used : StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) LinkedList(java.util.LinkedList)

Example 4 with StreamSourceNode

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

the class WSGraphFactory method createNode.

/**
 * @see org.apache.airavata.workflow.model.graph.GraphFactory#createNode(org.xmlpull.infoset.XmlElement)
 */
public NodeImpl createNode(XmlElement nodeElement) throws GraphException {
    String type = nodeElement.attributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE);
    if (type == null) {
        // Old graphs don't have the namespace for the attribute.
        type = nodeElement.attributeValue(GraphSchema.NODE_TYPE_ATTRIBUTE);
    }
    NodeImpl node;
    if (GraphSchema.NODE_TYPE_WS.equals(type)) {
        node = new WSNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_STREAM_SOURCE.equals(type)) {
        node = new StreamSourceNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_WORKFLOW.equals(type)) {
        node = new WorkflowNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_INPUT.equals(type)) {
        node = new InputNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_OUTPUT.equals(type)) {
        node = new OutputNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_CONSTANT.equals(type)) {
        node = new ConstantNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_SPLIT.equals(type)) {
        node = new ForEachNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_MERGE.equals(type)) {
        node = new EndForEachNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_IF.equals(type)) {
        node = new IfNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDIF.equals(type)) {
        node = new EndifNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_DOWHILE.equals(type)) {
        node = new DoWhileNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDDOWHILE.equals(type)) {
        node = new EndDoWhileNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_MEMO.equals(type)) {
        node = new MemoNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_RECEIVE.equals(type)) {
        node = new ReceiveNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_BLOCK.equals(type)) {
        node = new BlockNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDBLOCK.equals(type)) {
        node = new EndBlockNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_INSTANCE.equals(type)) {
        node = new InstanceNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_TERMINATE.equals(type)) {
        node = new TerminateInstanceNode(nodeElement);
    } else {
        // Default is WsNode for backward compatibility.
        node = new WSNode(nodeElement);
    }
    return node;
}
Also used : BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) ReceiveNode(org.apache.airavata.workflow.model.graph.system.ReceiveNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) InstanceNode(org.apache.airavata.workflow.model.graph.amazon.InstanceNode) TerminateInstanceNode(org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) DoWhileNode(org.apache.airavata.workflow.model.graph.system.DoWhileNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) TerminateInstanceNode(org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Aggregations

StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)4 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)2 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)2 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 LinkedList (java.util.LinkedList)1 DataPort (org.apache.airavata.workflow.model.graph.DataPort)1 GraphException (org.apache.airavata.workflow.model.graph.GraphException)1 GraphPiece (org.apache.airavata.workflow.model.graph.GraphPiece)1 Port (org.apache.airavata.workflow.model.graph.Port)1 InstanceNode (org.apache.airavata.workflow.model.graph.amazon.InstanceNode)1 TerminateInstanceNode (org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode)1 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)1 BlockNode (org.apache.airavata.workflow.model.graph.system.BlockNode)1 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)1 DoWhileNode (org.apache.airavata.workflow.model.graph.system.DoWhileNode)1 EndBlockNode (org.apache.airavata.workflow.model.graph.system.EndBlockNode)1 EndDoWhileNode (org.apache.airavata.workflow.model.graph.system.EndDoWhileNode)1 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)1 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)1