Package org.apache.airavata.xbaya.interpretor

Examples of org.apache.airavata.xbaya.interpretor.WorkFlowInterpreterException


    if (forEachInputNode instanceof InputNode) {
      for (DataPort dataPort : forEachNode.getInputPorts()) {
        returnValForProvenance = XBayaUtil
            .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) {
          String outputName = forEachInputNode.getOutputPort(0)
              .getName();
          returnValForProvenance = workflowInvoker
              .getOutput(outputName);
          XmlElement msgElmt = XmlConstants.BUILDER
              .parseFragmentFromString("<temp>"
                  + returnValForProvenance + "</temp>");
          Iterator valItr = msgElmt.children().iterator();
          while (valItr.hasNext()) {
            Object object2 = valItr.next();
            if (object2 instanceof XmlElement) {
              listOfValues.add(((XmlElement) object2).children()
                  .iterator().next().toString());
            }
          }
        }
      } else {
        throw new WorkFlowInterpreterException(
            "Did not find inputs from WS to foreach");
      }
    }
    return returnValForProvenance;
  }
View Full Code Here


            // 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();
                        while (valItr.hasNext()) {
                            Object object2 = valItr.next();
                            if (object2 instanceof XmlElement) {
                                listOfValues.add(((XmlElement) object2).children().iterator().next().toString());
                            }
                        }
                    }
                } else {
                    throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
                }
            }
        }
        return returnValForProvenance;
    }
View Full Code Here

            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()) {
                            Object object2 = valItr.next();
                            if (object2 instanceof XmlElement) {
                                index++;
                            }
                        }
                        inputNumbers[inputPorts.indexOf(forEachInputPort)] = index;
                    }

                } else {
                    throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
                }
            }
        }
        return inputNumbers;
    }
View Full Code Here

    if (forEachInputNode instanceof InputNode) {
      for (DataPort dataPort : forEachNode.getInputPorts()) {
        returnValForProvenance = XBayaUtil
            .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) {
          String outputName = forEachInputNode.getOutputPort(0)
              .getName();
          returnValForProvenance = workflowInvoker
              .getOutput(outputName);
          XmlElement msgElmt = XmlConstants.BUILDER
              .parseFragmentFromString("<temp>"
                  + returnValForProvenance + "</temp>");
          Iterator valItr = msgElmt.children().iterator();
          while (valItr.hasNext()) {
            Object object2 = valItr.next();
            if (object2 instanceof XmlElement) {
              listOfValues.add(((XmlElement) object2).children()
                  .iterator().next().toString());
            }
          }
        }
      } else {
        throw new WorkFlowInterpreterException(
            "Did not find inputs from WS to foreach");
      }
    }
    return returnValForProvenance;
  }
View Full Code Here

            // 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();
                        while (valItr.hasNext()) {
                            Object object2 = valItr.next();
                            if (object2 instanceof XmlElement) {
                                listOfValues.add(((XmlElement) object2).children().iterator().next().toString());
                            }
                        }
                    }
                } else {
                    throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
                }
            }
        }
        return returnValForProvenance;
    }
View Full Code Here

            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()) {
                            Object object2 = valItr.next();
                            if (object2 instanceof XmlElement) {
                                index++;
                            }
                        }
                        inputNumbers[inputPorts.indexOf(forEachInputPort)] = index;
                    }

                } else {
                    throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
                }
            }
        }
        return inputNumbers;
    }
View Full Code Here

    if (forEachInputNode instanceof InputNode) {
      for (DataPort dataPort : forEachNode.getInputPorts()) {
        returnValForProvenance = XBayaUtil
            .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) {
          String outputName = forEachInputNode.getOutputPort(0)
              .getName();
          returnValForProvenance = workflowInvoker
              .getOutput(outputName);
          XmlElement msgElmt = XmlConstants.BUILDER
              .parseFragmentFromString("<temp>"
                  + returnValForProvenance + "</temp>");
          Iterator valItr = msgElmt.children().iterator();
          while (valItr.hasNext()) {
            Object object2 = valItr.next();
            if (object2 instanceof XmlElement) {
              listOfValues.add(((XmlElement) object2).children()
                  .iterator().next().toString());
            }
          }
        }
      } else {
        throw new WorkFlowInterpreterException(
            "Did not find inputs from WS to foreach");
      }
    }
    return returnValForProvenance;
  }
View Full Code Here

      // 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);
            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 = 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();
            while (valItr.hasNext()) {
              Object object2 = valItr.next();
              if (object2 instanceof XmlElement) {
                listOfValues.add(((XmlElement) object2).children().iterator().next().toString());
              }
            }
          }
        } else {
          throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
        }
      }
    }
    return returnValForProvenance;
  }
View Full Code Here

      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()) {
              Object object2 = valItr.next();
              if (object2 instanceof XmlElement) {
                index++;
              }
            }
            inputNumbers[inputPorts.indexOf(forEachInputPort)] = index;
          }

        } else {
          throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
        }
      }
    }
    return inputNumbers;
  }
View Full Code Here

            // if input node for for-each is WSNode
            if (inputNode instanceof InputNode) {
//                for (DataPort dataPort : forEachNode.getInputPorts()) {
                    returnValForProvenance = InterpreterUtil.findInputFromPort(inputPort, invokerMap);
                    if (null == returnValForProvenance) {
                        throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
                    }
                    String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
                    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();
                        while (valItr.hasNext()) {
                            Object object2 = valItr.next();
                            if (object2 instanceof XmlElement) {
                                listOfValues.add(((XmlElement) object2).children().iterator().next().toString());
                            }
                        }
                    }
                } else {
                    throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach");
                }
            }
        }
        return returnValForProvenance;
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.xbaya.interpretor.WorkFlowInterpreterException

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.