Package org.apache.airavata.workflow.model.graph

Examples of org.apache.airavata.workflow.model.graph.Node


     * @param location
     *            The location to add the node.
     */
    public synchronized Node addNode(Component component, Point location) {
        if (component != null) {
            Node node = this.workflow.addNode(component);
            node.setPosition(location);
            selectNode(node);
            updateSize();
            this.panel.repaint();
            return node;
        }
View Full Code Here


         * 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;
        }
View Full Code Here

        deselectNode();
        deselectEdge();

        if (selected instanceof Node) {
            Node node = (Node) selected;
            selectNode(node);
            if (!NodeController.getGUI(node).isInConfig(point)) {
                this.draggedNode = node;
                NodeController.getGUI(node).setDraggedFlag(true);
                this.panel.setCursor(SwingUtil.MOVE_CURSOR);
View Full Code Here

    private void mouseMoved(MouseEvent event) {
        Point point = event.getPoint();
        GraphPiece graphPiece = NodeController.getGUI(this.graph).getGraphPieceAt(point);
        if (graphPiece instanceof Node) {
            Node node = (Node) graphPiece;
            if (NodeController.getGUI(node).isInConfig(point)) {
                this.panel.setCursor(SwingUtil.HAND_CURSOR);
            } else {
                this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
            }
View Full Code Here

        if (this.selectedNode != null) {

            ArrayList<Node> exploreNodes = new ArrayList<Node>();
            exploreNodes.add(this.selectedNode);
            while (exploreNodes.size() != 0) {
                Node node = exploreNodes.get(0);
                List<DataPort> outputPorts = node.getOutputPorts();
                for (DataPort dataPort : outputPorts) {
                    exploreNodes.addAll(dataPort.getToNodes());
                }
                node.setState(NodeExecutionState.WAITING);

                exploreNodes.remove(0);
            }
            this.repaint();
        }
View Full Code Here

        List<DataPort> inputPorts = forEachNode.getInputPorts();

        Object returnValForProvenance = null;
        for (DataPort inputPort : inputPorts) {

            Node inputNode = inputPort.getFromNode();
            // if input node for for-each is WSNode
            if (inputNode instanceof InputNode) {
                for (DataPort dataPort : forEachNode.getInputPorts()) {
                    returnValForProvenance = InterpreterUtil.findInputFromPort(dataPort, invokerMap);
                    if (null == returnValForProvenance) {
                        throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
                    }
                    String[] vals = returnValForProvenance.toString().split(",");
                    listOfValues.addAll(Arrays.asList(vals));
                }
            } else {
                Invoker workflowInvoker = invokerMap.get(inputNode);
                if (workflowInvoker != null) {
                    if (workflowInvoker instanceof GenericInvoker) {

                        String outputName = inputNode.getOutputPort(0).getName();
                        returnValForProvenance = workflowInvoker.getOutput(outputName);
            Iterator children = null;
            if (returnValForProvenance instanceof org.xmlpull.v1.builder.XmlElement) {
              org.xmlpull.v1.builder.XmlElement msgElmt = (org.xmlpull.v1.builder.XmlElement) returnValForProvenance;
              children = msgElmt.children();
            } else {
              XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>");
              children = msgElmt.children().iterator();
            }
                        while (children.hasNext()) {
                            Object object = children.next();
                            if (object instanceof org.xmlpull.v1.builder.XmlElement) {
                                org.xmlpull.v1.builder.XmlElement child = (org.xmlpull.v1.builder.XmlElement) object;
                                Iterator valItr = child.children();
                                if (valItr.hasNext()) {
                                    Object object2 = valItr.next();
                                    if (object2 instanceof String) {
                                        listOfValues.add(object2.toString());
                                    }
                                }
                            }
                            if (object instanceof XmlElement) {
                                listOfValues.add(((XmlElement) object).children().iterator().next().toString());
                            }if (object instanceof String){
                                listOfValues.add(object.toString());
                            }
                        }
                    } else if (workflowInvoker instanceof SystemComponentInvoker) {
                        int index = inputNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort());
                        String outputName = "";
                        if (inputNode.getInputPort(index) instanceof SystemDataPort) {
                            outputName = ((SystemDataPort) inputNode.getInputPort(index)).getWSComponentPort().getName();
                        } else if (inputNode.getInputPort(index) instanceof WSPort) {
                            outputName = ((SystemDataPort) inputNode.getInputPort(inputNode.getOutputPorts().indexOf(
                                    inputPort.getEdge(0).getFromPort()))).getWSComponentPort().getName();
                        }
                        returnValForProvenance = workflowInvoker.getOutput(outputName);
                        XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>");
                        Iterator valItr = msgElmt.children().iterator();
View Full Code Here

     * @return
     * @throws WorkflowException
     */
    public static Object findInputFromPort(DataPort inputPort, Map<Node, Invoker> invokerMap) throws WorkflowException {
        Object outputVal = null;
        Node fromNode = inputPort.getFromNode();
        if (fromNode instanceof InputNode) {
            outputVal = ((InputNode) fromNode).getDefaultValue();
        } else if (fromNode instanceof ConstantNode) {
            outputVal = ((ConstantNode) fromNode).getValue();
        } else if (fromNode instanceof DifferedInputNode && ((DifferedInputNode) fromNode).isConfigured()) {
            outputVal = ((DifferedInputNode) fromNode).getDefaultValue();
        } else if (fromNode instanceof EndifNode || fromNode instanceof DoWhileNode  || fromNode instanceof EndDoWhileNode) {
            Invoker fromInvoker = invokerMap.get(fromNode);
            outputVal = fromInvoker.getOutput(inputPort.getFromPort().getID());
        } else if (fromNode instanceof InstanceNode) {
            return ((InstanceNode) fromNode).getOutputInstanceId();
        } else if (fromNode instanceof EndForEachNode) {
            outputVal = "";
            Invoker workflowInvoker = invokerMap.get(fromNode);
            String outputName = "";
            if (inputPort instanceof SystemDataPort) {
                outputName = ((SystemDataPort) inputPort).getWSComponentPort().getName();

            } else if (inputPort instanceof WSPort) {
                outputName = ((SystemDataPort) fromNode.getInputPort(fromNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort())))
                        .getWSComponentPort().getName();
            }
            XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + workflowInvoker.getOutput(outputName) + "</temp>");
            Iterator valItr = msgElmt.children().iterator();
            while (valItr.hasNext()) {
View Full Code Here

        Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
        if (toNodes.size() != 1) {
            throw new WorkflowRuntimeException("ForEach output does not contain single out-edge");
        }
        Node middleNode = toNodes.iterator().next();
        List<DataPort> outputPorts = middleNode.getOutputPorts();
        for (DataPort dataPort : outputPorts) {
            if (dataPort.getToNodes().size() == 1) {
                Node possibleEndForEachNode = dataPort.getToNodes().get(0);
                if (possibleEndForEachNode instanceof EndForEachNode) {
                    return possibleEndForEachNode;
                }
            }
        }
View Full Code Here

    public static Integer[] getNumberOfInputsForForEachNode(final ForEachNode forEachNode, Map<Node, Invoker> invokerMap) throws WorkflowException {
        List<DataPort> inputPorts = forEachNode.getInputPorts();
        Integer[] inputNumbers = new Integer[inputPorts.size()];
        for (DataPort forEachInputPort : inputPorts) {
            // if input node for for-each is WSNode
            Node forEachInputNode = forEachInputPort.getFromNode();
            int index = 0;
            Object returnValForProvenance = null;
            if (forEachInputNode instanceof InputNode) {
                returnValForProvenance = InterpreterUtil.findInputFromPort(forEachInputPort, invokerMap);
                if (null == returnValForProvenance) {
                    throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
                }
                String[] vals = returnValForProvenance.toString().split(",");
                inputNumbers[inputPorts.indexOf(forEachInputPort)] = vals.length;
            } else {
                Invoker workflowInvoker = invokerMap.get(forEachInputNode);
                if (workflowInvoker != null) {
                    if (workflowInvoker instanceof GenericInvoker) {

                        returnValForProvenance = ((GenericInvoker) workflowInvoker).getOutputs();
                        String message = returnValForProvenance.toString();

                        XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString(message);
                        Iterator children = msgElmt.children().iterator();
                        while (children.hasNext()) {
                            Object object = children.next();
                            // foreachWSNode.getInputPort(0).getType()
                            if (object instanceof XmlElement) {
                                index++;
                            }
                        }
                    } else if (workflowInvoker instanceof WorkflowInvokerWrapperForGFacInvoker) {
                        String outputName = forEachInputNode.getOutputPort(0).getName();
                        returnValForProvenance = workflowInvoker.getOutput(outputName);
                        org.xmlpull.v1.builder.XmlElement msgElmt = (org.xmlpull.v1.builder.XmlElement) returnValForProvenance;
                        Iterator children = msgElmt.children();
                        while (children.hasNext()) {
                            Object object = children.next();
                            if (object instanceof org.xmlpull.v1.builder.XmlElement) {
                                org.xmlpull.v1.builder.XmlElement child = (org.xmlpull.v1.builder.XmlElement) object;
                                Iterator valItr = child.children();
                                if (valItr.hasNext()) {
                                    Object object2 = valItr.next();
                                    if (object2 instanceof String) {
                                        index++;
                                    }
                                }
                            }
                        }
                        inputNumbers[inputPorts.indexOf(forEachInputPort)] = index;
                    } else if (workflowInvoker instanceof SystemComponentInvoker) {
                        int portIndex = forEachInputNode.getOutputPorts().indexOf(forEachInputPort.getEdge(0).getFromPort());
                        String outputName = "";
                        if (forEachInputNode.getInputPort(portIndex) instanceof SystemDataPort) {
                            outputName = ((SystemDataPort) forEachInputNode.getInputPort(portIndex)).getWSComponentPort().getName();
                        } else if (forEachInputNode.getInputPort(portIndex) instanceof WSPort) {
                            outputName = ((WSPort) forEachInputNode.getInputPort(portIndex)).getComponentPort().getName();
                        }
                        returnValForProvenance = workflowInvoker.getOutput(outputName);
                        XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>");
                        Iterator valItr = msgElmt.children().iterator();
                        while (valItr.hasNext()) {
View Full Code Here

        }

      } else if (node instanceof EndForEachNode) {
        // here we save the inputs for the entire foreach block
        Node middleNode = node.getInputPort(0).getFromNode();
        String nodeID = middleNode.getComponent().getName();
        XmlElement nodeElement = elem.newElement("foreach");
        elem.addChild(nodeElement);
        nodeElement.addChild(nodeID);
        inputs = elem.newElement("inputs");
        elem.addChild(inputs);
        XmlConstants.BUILDER.serializeToString(elem);
        if (middleNode instanceof ForEachExecutableNode) {
          List<DataPort> portsToBeSaved = middleNode.getInputPorts();
          for (DataPort savePort : portsToBeSaved) {
            // we will save all the inputs
            // these are static inputs and
            // input to the foreach node
View Full Code Here

TOP

Related Classes of org.apache.airavata.workflow.model.graph.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.