Package org.apache.airavata.xbaya.graph

Examples of org.apache.airavata.xbaya.graph.Node


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


            Node forEachInputNode = inputPort.getFromNode();
            // if input node for for-each is WSNode
    if (forEachInputNode 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(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) {
              listOfValues.add(XmlConstants.BUILDER
                  .serializeToString(object));
              // TODO fix for simple type - Done
            }
          }
        } 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) {
                  listOfValues.add(object2.toString());
                }
              }
            }
          }
        } else if (workflowInvoker instanceof SystemComponentInvoker) {
                    int index = forEachInputNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort());
                    String outputName = "";
                    if(forEachInputNode.getInputPort(index) instanceof SystemDataPort){
                       outputName = ((SystemDataPort)forEachInputNode.getInputPort(index)).getWSComponentPort().getName();
                    }else if(forEachInputNode.getInputPort(index) instanceof WSPort){
                         outputName = ((SystemDataPort)forEachInputNode.getInputPort(
                        forEachInputNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort()))).getWSComponentPort().getName();
                    }
          returnValForProvenance = workflowInvoker
              .getOutput(outputName);
          XmlElement msgElmt = XmlConstants.BUILDER
              .parseFragmentFromString("<temp>"
View Full Code Here


        ifNode.setPosition(new Point(170, 180));

        // Adder nodes
        Component adderComp = this.componentRegistry.getComponent(Adder.WSDL_PATH);

        Node adder = workflow.addNode(adderComp);
        adder.setPosition(new Point(400, 10));

        // Multiplier node
        Component multiComp = this.componentRegistry.getComponent(Multiplier.WSDL_PATH);

        Node multiplier = workflow.addNode(multiComp);
        multiplier.setPosition(new Point(400, 90));

        // endif
        Node endif = workflow.addNode(this.endifComponent);
        endif.setPosition(new Point(550, 40));

        // Output
        OutputNode output = (OutputNode) workflow.addNode(this.outputComponent);
        output.setConfiguredName("output");
        output.setPosition(new Point(700, 40));

        // Connect ports
        graph.addEdge(x.getOutputPort(0), adder.getInputPort(0));
        graph.addEdge(x.getOutputPort(0), multiplier.getInputPort(0));
        graph.addEdge(y.getOutputPort(0), adder.getInputPort(1));
        graph.addEdge(y.getOutputPort(0), multiplier.getInputPort(1));
        graph.addEdge(const0.getOutputPort(0), ifNode.getInputPort(0));
        graph.addEdge(ifNode.getControlOutPorts().get(0), adder.getControlInPort());
        graph.addEdge(ifNode.getControlOutPorts().get(1), multiplier.getControlInPort());
        graph.addEdge(adder.getOutputPort(0), endif.getInputPort(0));
        graph.addEdge(multiplier.getOutputPort(0), endif.getInputPort(1));
        graph.addEdge(endif.getOutputPort(0), output.getInputPort(0));

        // Set the default values
        // This needs to be after connection.
        x.setDefaultValue("2");
        y.setDefaultValue("3");
View Full Code Here

        Graph graph = workflow.getGraph();

        // Adder nodes
        Component echoComponent = this.componentRegistry.getComponent(Echo.WSDL_PATH);

        Node echo = workflow.addNode(echoComponent);
        echo.setPosition(new Point(40, 40));

        // receive
        ReceiveNode receive = (ReceiveNode) workflow.addNode(this.receiveComponent);
        receive.setPosition(new Point(200, 200));

        // Output
        OutputNode output1 = (OutputNode) workflow.addNode(this.outputComponent);
        output1.setPosition(new Point(350, 40));

        OutputNode output2 = (OutputNode) workflow.addNode(this.outputComponent);
        output2.setPosition(new Point(350, 200));

        // Connect ports
        graph.addEdge(receive.getEPRPort(), echo.getInputPort(0));
        graph.addEdge(echo.getOutputPort(0), output1.getInputPort(0));
        graph.addEdge(receive.getOutputPort(0), output2.getInputPort(0));
        graph.addEdge(echo.getControlOutPorts().get(0), receive.getControlInPort());

        // Confugure
        output1.setConfiguredName("output1");
        output1.setConfigured(true);
        output2.setConfiguredName("output2");
View Full Code Here

     * @return
     * @throws XBayaException
     */
  public static Object  findInputFromPort(DataPort inputPort, Map<Node,Invoker>  invokerMap) throws XBayaException {
    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) {
      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();
View Full Code Here

        Graph graph = workflow.getGraph();

        // Adder node
        Component gfacComp = this.componentRegistry.getComponent(GFAC_TEST_AWSDL);
        Node gfacNode = workflow.addNode(gfacComp);
        gfacNode.setPosition(new Point(250, 100));

        // Input parameter node 1
        InputNode paramNode1 = (InputNode) workflow.addNode(this.inputComponent);
        paramNode1.setPosition(new Point(50, 50));
        String paramValue1 = "300";
        paramNode1.setDefaultValue(paramValue1);

        // Output parameter
        OutputNode outParamNode = (OutputNode) workflow.addNode(this.outputComponent);
        outParamNode.setPosition(new Point(300, 220));

        // Connect ports
        graph.addEdge(paramNode1.getOutputPort(0), gfacNode.getInputPort(0));
        graph.addEdge(gfacNode.getOutputPort(0), outParamNode.getInputPort(0));

        return workflow;
    }
View Full Code Here

    Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
    if(toNodes.size() != 1){
      throw new XBayaRuntimeException("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

        ifNode.setPosition(new Point(200, 100));

        // Approver nodes
        Component approverComponent = this.componentRegistry.getComponent(Approver.WSDL_PATH);

        Node approver = workflow.addNode(approverComponent);
        approver.setPosition(new Point(350, 10));

        // const
        ConstantNode constYes = (ConstantNode) workflow.addNode(this.constantComponent);
        constYes.setPosition(new Point(350, 200));

        // endif
        Node endif = workflow.addNode(this.endifComponent);
        endif.setPosition(new Point(550, 100));

        // Output
        OutputNode output = (OutputNode) workflow.addNode(this.outputComponent);
        output.setPosition(new Point(700, 100));

        // Connect ports
        graph.addEdge(amount.getOutputPort(0), approver.getInputPort(0));
        graph.addEdge(amount.getOutputPort(0), ifNode.getInputPort(0));
        graph.addEdge(ifNode.getControlOutPorts().get(0), approver.getControlInPort());
        graph.addEdge(ifNode.getControlOutPorts().get(1), constYes.getControlInPort());
        graph.addEdge(approver.getOutputPort(0), endif.getInputPort(0));
        graph.addEdge(constYes.getOutputPort(0), endif.getInputPort(1));
        graph.addEdge(endif.getOutputPort(0), output.getInputPort(0));

        // Set the default values
        // This needs to be after connection.
        amount.setDefaultValue("500");
        constYes.setValue("Yes");
View Full Code Here

                                                            Map<Node,Invoker> invokerMap) throws XBayaException {
        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>"
View Full Code Here

     */
    private GpelAssignCopyFrom createAssignCopyFrom(Port port) throws GraphException {
        GpelAssignCopyFrom from = new GpelAssignCopyFrom(this.bpelNS);

        Port fromPort = port.getFromPort();
        Node fromNode = fromPort.getNode();
        if (fromNode instanceof InputNode) {
            from.setVariable(WORKFLOW_INPUT_NAME);
            from.setPart(WorkflowWSDL.INPUT_PART_NAME);
            from.setQuery("/" + this.typesNamespace.getPrefix() + ":"
                    + this.workflowWSDL.getWorkflowInputMessageElelmentName() + "/" + fromNode.getID());
        } else if (fromNode instanceof ConstantNode) {
            ConstantNode constNode = (ConstantNode) fromNode;
            Object value = constNode.getValue();
            // The namaspace and name of the literal element will be set
            // correctly in from.setLiteral().
            XmlElement literalElement = XMLUtil.BUILDER.newFragment(GpelAssignCopyFrom.LITERAL_EL);
            literalElement.addChild(value);
            from.setLiteral(literalElement);
        } else if (fromNode instanceof WSNode) {
            String fromID = fromNode.getID();
            WSComponent fromWsdlComponent = (WSComponent) fromNode.getComponent();

            WSComponentPort fromWsdlPort = (WSComponentPort) fromPort.getComponentPort();

            from.setVariable(fromID + OUTPUT_SUFFIX);
            from.setPart(fromWsdlComponent.getOutputPartName());

            if (fromWsdlPort.isSchemaUsed()) {
                String typesTargetNamespace = fromWsdlPort.getTargetNamespace();
                XmlNamespace namespace = XMLUtil.declareNamespaceIfNecessary(fromID.toLowerCase() + TYPENS_SUFFIX,
                        typesTargetNamespace, false, this.process.xml());

                from.setQuery("/" + namespace.getPrefix() + ":" + fromWsdlComponent.getOutputTypeName() + "/"
                        + fromWsdlPort.getName());
            } else {
                // No query needed?
            }
        } else if (fromNode instanceof ForEachNode) {
            from.setVariable(fromNode.getID() + FOREACH_VALUE_SUFFIX);
        } else if (fromNode instanceof EndForEachNode) {
            from.setVariable(fromNode.getID() + ARRAY_SUFIX);
        } else if (fromNode instanceof EndifNode) {
            // endif has multiple outputs, so we use port ID here.
            from.setVariable(fromPort.getID() + OUTPUT_SUFFIX);
        } else if (fromNode instanceof ReceiveNode) {
            if (fromPort instanceof EPRPort) {
                from.setPartnerLink(fromNode.getID() + PARTNER_LINK_NAME_SUFFIX);
                from.setEndpointReference("myRole");
            } else {
                from.setVariable(fromNode.getID() + INPUT_SUFFIX);
            }
        } else if (fromNode instanceof InstanceNode) {
            // no op
        } else {
            throw new GraphException("Unexpected node," + fromNode.getClass().getName() + " is connected");
        }
        return from;
    }
View Full Code Here

     * @return The GpelAssignCopyTo created
     */
    private GpelAssignCopyTo createAssignCopyTo(Port toPort, boolean input) {
        GpelAssignCopyTo to = new GpelAssignCopyTo(this.bpelNS);

        Node toNode = toPort.getNode();
        if (toNode instanceof OutputNode) {
            to.setVariable(WORKFLOW_OUTPUT_NAME);
            to.setPart(WorkflowWSDL.OUTPUT_PART_NAME);
            to.setQuery("/" + this.typesNamespace.getPrefix() + ":"
                    + this.workflowWSDL.getWorkflowOutputMessageElementName() + "/" + toNode.getID());
        } else {
            WSComponentPort toComponentPort = (WSComponentPort) toPort.getComponentPort();

            String toID = toNode.getID();
            WSComponent toWSComponent = (WSComponent) toNode.getComponent();
            to.setVariable(toID + INPUT_SUFFIX);
            to.setPart(toWSComponent.getInputPartName());

            if (toComponentPort.isSchemaUsed()) {
                // Normal case.
View Full Code Here

TOP

Related Classes of org.apache.airavata.xbaya.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.