Search in sources :

Example 1 with InputComponent

use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.

the class GraphCanvas method mouseClicked.

private void mouseClicked(MouseEvent event) {
    /*
         * If there is multi-selected and a click on a node, switch to that node or deselect node if it is already
         * selected
         */
    Point point = event.getPoint();
    GraphPiece clicked = NodeController.getGUI(this.graph).getGraphPieceAt(point);
    if ((clicked instanceof Node) && this.multipleSelectedNodes != null) {
        Node node = (Node) clicked;
        if (!this.crtlPressed) {
            selectNode(node);
        }
        return;
    } else if ((clicked instanceof Port) && event.getClickCount() == 2) {
        // double click to add Input/Output nodes and connect with them when a DataPort is double clicked
        Port port = (Port) clicked;
        Point pos = port.getNode().getPosition();
        Node node = null;
        int xgap = (int) (1.5 * NodeGUI.MINIMUM_WIDTH);
        int ygap = (int) (NodeGUI.MINIMUM_HEIGHT / 2);
        Point nodePos = null;
        switch(port.getKind()) {
            case DATA_IN:
                if (port.getFromNode() == null) {
                    nodePos = new Point(Math.max(0, pos.x - xgap), Math.max(0, pos.y - ygap));
                    node = addNode(new InputComponent(), nodePos);
                    connect(node.getOutputPorts().get(0), port);
                }
                break;
            case DATA_OUT:
                nodePos = new Point(pos.x + NodeGUI.MINIMUM_WIDTH + xgap, pos.y + ygap);
                node = addNode(new OutputComponent(), nodePos);
                connect(port, node.getInputPorts().get(0));
                break;
            default:
        }
    }
    // delegate the event.
    NodeController.getGUI(this.graph).mouseClicked(event, this.engine);
}
Also used : InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) GraphPiece(org.apache.airavata.workflow.model.graph.GraphPiece) OutputComponent(org.apache.airavata.workflow.model.component.system.OutputComponent) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) Point(java.awt.Point)

Example 2 with InputComponent

use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.

the class InputNode method getComponent.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#getComponent()
 */
@Override
public Component getComponent() {
    Component component = super.getComponent();
    if (component == null) {
        // The component is null when read from the graph XML.
        component = new InputComponent();
        setComponent(component);
    }
    return component;
}
Also used : InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) Component(org.apache.airavata.workflow.model.component.Component)

Example 3 with InputComponent

use of org.apache.airavata.workflow.model.component.system.InputComponent 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)

Example 4 with InputComponent

use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.

the class WorkflowHarvester method harvest.

public Workflow[] harvest(Workflow workflow, QName dataType) {
    LinkedList<Workflow> harvest = new LinkedList<Workflow>();
    LinkedList<Pair<String, String>> candidates = getCandidates(workflow, dataType);
    for (Pair<String, String> pair : candidates) {
        Workflow clone = workflow.clone();
        NodeImpl node = clone.getGraph().getNode(pair.getLeft());
        if (null == node) {
            throw new WorkflowRuntimeException("Specified node not found:" + pair.getLeft());
        }
        Port candidatePort = null;
        List<DataPort> inPorts = node.getInputPorts();
        for (DataPort dataPort : inPorts) {
            if (pair.getRight().equals(dataPort.getID())) {
                candidatePort = dataPort;
                break;
            }
        }
        if (null == candidatePort) {
            throw new WorkflowRuntimeException("Specifies Port was not found:" + pair.getRight());
        }
        if (!(candidatePort.getFromNode() instanceof InputNode)) {
            removeUnnecessaryNodes(node, candidatePort, clone);
            Node input = clone.addNode(new InputComponent());
            input.setPosition(new Point(Math.max(0, node.getPosition().x - 150), node.getPosition().y));
            // original
            if (clone.getGraph().getNodes().size() < workflow.getGraph().getNodes().size() && // its not the same as one already harvested
            !isWorkflowAlreadyHarvested(harvest, clone)) {
                try {
                    clone.getGraph().addEdge(input.getOutputPort(0), candidatePort);
                    cleanLeftOverInputNodes(clone);
                } catch (GraphException e) {
                    throw new RuntimeException(e);
                }
                harvest.add(clone);
            }
        }
    }
    return harvest.toArray(new Workflow[0]);
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Node(org.apache.airavata.workflow.model.graph.Node) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Point(java.awt.Point) LinkedList(java.util.LinkedList) DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Pair(org.apache.airavata.common.utils.Pair)

Example 5 with InputComponent

use of org.apache.airavata.workflow.model.component.system.InputComponent in project airavata by apache.

the class WorkflowHarvester method harvest.

public Workflow[] harvest(Workflow workflow, QName dataType) {
    LinkedList<Workflow> harvest = new LinkedList<Workflow>();
    LinkedList<Pair<String, String>> candidates = getCandidates(workflow, dataType);
    for (Pair<String, String> pair : candidates) {
        Workflow clone = workflow.clone();
        NodeImpl node = clone.getGraph().getNode(pair.getLeft());
        if (null == node) {
            throw new WorkflowRuntimeException("Specified node not found:" + pair.getLeft());
        }
        Port candidatePort = null;
        List<DataPort> inPorts = node.getInputPorts();
        for (DataPort dataPort : inPorts) {
            if (pair.getRight().equals(dataPort.getID())) {
                candidatePort = dataPort;
                break;
            }
        }
        if (null == candidatePort) {
            throw new WorkflowRuntimeException("Specifies Port was not found:" + pair.getRight());
        }
        if (!(candidatePort.getFromNode() instanceof InputNode)) {
            removeUnnecessaryNodes(node, candidatePort, clone);
            Node input = clone.addNode(new InputComponent());
            input.setPosition(new Point(Math.max(0, node.getPosition().x - 150), node.getPosition().y));
            // original
            if (clone.getGraph().getNodes().size() < workflow.getGraph().getNodes().size() && // its not the same as one already harvested
            !isWorkflowAlreadyHarvested(harvest, clone)) {
                try {
                    clone.getGraph().addEdge(input.getOutputPort(0), candidatePort);
                    cleanLeftOverInputNodes(clone);
                } catch (GraphException e) {
                    throw new RuntimeException(e);
                }
                harvest.add(clone);
            }
        }
    }
    return harvest.toArray(new Workflow[0]);
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Node(org.apache.airavata.workflow.model.graph.Node) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Point(java.awt.Point) LinkedList(java.util.LinkedList) DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Pair(org.apache.airavata.common.utils.Pair)

Aggregations

InputComponent (org.apache.airavata.workflow.model.component.system.InputComponent)5 Point (java.awt.Point)4 Port (org.apache.airavata.workflow.model.graph.Port)4 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)3 Node (org.apache.airavata.workflow.model.graph.Node)3 LinkedList (java.util.LinkedList)2 Pair (org.apache.airavata.common.utils.Pair)2 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)2 GraphException (org.apache.airavata.workflow.model.graph.GraphException)2 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)2 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)2 Workflow (org.apache.airavata.workflow.model.wf.Workflow)2 Component (org.apache.airavata.workflow.model.component.Component)1 OutputComponent (org.apache.airavata.workflow.model.component.system.OutputComponent)1 GraphPiece (org.apache.airavata.workflow.model.graph.GraphPiece)1 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)1 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)1 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)1