public static String getEPR(WSNode wsNode) {
   Iterable<WsdlService> services = wsNode.getComponent().getWSDL().services();
   Iterator<WsdlService> iterator = services.iterator();
   if (iterator.hasNext()) {
     Iterable<WsdlPort> ports = iterator.next().ports();
     Iterator<WsdlPort> portIterator = ports.iterator();
     if (portIterator.hasNext()) {
       WsdlPort port = portIterator.next();
       Iterable children = port.xml().children();
       Iterator childIterator = children.iterator();
       while (childIterator.hasNext()) {
         Object next = childIterator.next();
         if (next instanceof XmlElementWithViewsImpl) {
           org.xmlpull.infoset.XmlAttribute epr =
               ((XmlElementWithViewsImpl) next).attribute("location");
           return epr.getValue();
         }
       }
     }
   }
   return null;
 }
Example #2
0
  /**
   * @param node
   * @param thread
   * @param pw
   */
  private void writeInvocation(WSNode node, boolean thread, PrintWriter pw) {
    String id = node.getID();
    String wsdlID = getWSDLID(node);

    WSComponent component = node.getComponent();
    QName portTypeQName = component.getPortTypeQName();
    String operation = component.getOperationName();

    pw.println(TAB + "# Invoke " + id + ".");
    pw.println(
        TAB
            + id
            + QNAME_SUFFIX
            + " = QName('"
            + portTypeQName.getNamespaceURI()
            + "', '"
            + portTypeQName.getLocalPart()
            + "')");
    pw.println(
        TAB
            + wsdlID
            + " = "
            + PROPERTIES_VARIABLE
            + "."
            + GET_PROPERTY_METHOD
            + "('"
            + wsdlID
            + "')");
    pw.println(
        TAB
            + id
            + INVOKER_SUFFIX
            + " = "
            + "("
            + id
            + QNAME_SUFFIX
            + ", "
            + wsdlID
            + ", '"
            + id
            + "',");
    pw.println(
        TAB
            + TAB
            + MESSAGE_BOX_URL_VARIABLE
            + ", "
            + GFAC_VARIABLE
            + ", "
            + NOTIFICATION_VARIABLE
            + ")");

    pw.println(TAB + "def " + INVOKE_METHOD + id + "():");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SETUP_METHOD + "()");
    pw.println(
        TAB + TAB + id + INVOKER_SUFFIX + "." + SET_OPERATION_METHOD + "('" + operation + "')");

    // Ports
    for (Port port : node.getInputPorts()) {
      String portName = port.getName();
      String value;
      Node fromNode = port.getFromNode();
      if (fromNode instanceof InputNode) {
        value = PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')";
      } else {
        Port fromPort = port.getFromPort();
        value =
            ""
                + fromNode.getID()
                + INVOKER_SUFFIX
                + "."
                + GET_OUTPUT_METHOD
                + "('"
                + fromPort.getName()
                + "')";

        // This might try to remove a node that has been removed
        // already, but it's OK.
        this.executingNodes.remove(fromNode);
      }
      pw.println(TAB + TAB + portName + VALUE_SUFFIX + " = " + value);
      pw.println(
          TAB
              + TAB
              + id
              + INVOKER_SUFFIX
              + "."
              + SET_INPUT_METHOD
              + "('"
              + portName
              + "', "
              + portName
              + VALUE_SUFFIX
              + ")");
    }

    pw.println(TAB + TAB + "print 'Invoking " + id + ".'");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + INVOKE_METHOD + "()");

    if (thread) {
      pw.println(TAB + "thread.start_new_thread(" + INVOKE_METHOD + id + ", ())");
    } else {
      pw.println(TAB + INVOKE_METHOD + id + "()");
    }

    pw.println();

    this.executingNodes.add(node);
  }
  private void initSchema(File rootDir, File srcDir, File classesDir) {

    List<DataPort> inputPorts = node.getInputPorts();
    for (DataPort inPort : inputPorts) {
      Port fromPort = inPort.getFromPort();
      Node fromNode = inPort.getFromNode();
      if (fromNode instanceof WSNode) {
        WSNode fromWsNode = (WSNode) fromNode;
        if (null != fromPort && fromPort instanceof DataPort) {
          DataPort fromDataPort = (DataPort) fromPort;
          WsdlDefinitions wsdl =
              engine.getGUI().getWorkflow().getWSDLs().get(fromWsNode.getWSDLID());
          Iterator<XmlNamespace> itr = wsdl.xml().namespaces().iterator();
          try {
            XmlElement schema = wsdl.getTypes().element("schema").clone();
            // do not change the following ordering of setting
            // namespaces.
            schema.setNamespace(
                xsul5.XmlConstants.BUILDER.newNamespace("http://www.w3.org/2001/XMLSchema"));
            while (itr.hasNext()) {
              XmlNamespace next = itr.next();
              if (!"".equals(next.getPrefix()) && null != next.getPrefix()) {
                schema.setAttributeValue("xmlns:" + next.getPrefix(), next.getName());
              }
            }

            try {
              xsul5.XmlConstants.BUILDER.serializeToOutputStream(
                  schema,
                  new FileOutputStream(
                      rootDir.getCanonicalPath() + File.separatorChar + "types.xsd"));
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }

            typesPath = rootDir.getCanonicalPath() + File.separatorChar + "mytype.jar";
            String[] args =
                new String[] {
                  "-d",
                  classesDir.getCanonicalPath(),
                  "-src",
                  srcDir.getCanonicalPath(),
                  "-out",
                  typesPath,
                  rootDir.getCanonicalPath() + File.separatorChar + "types.xsd"
                };
            SchemaCompilerUtil.compile(args);

          } catch (XmlBuilderException e) {
            this.engine.getGUI().getErrorWindow().error(e);
          } catch (CloneNotSupportedException e) {
            this.engine.getGUI().getErrorWindow().error(e);
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }

        } else {
          throw new WorkflowRuntimeException("Unknown port for code generation" + fromPort);
        }
      } else {
        throw new WorkflowRuntimeException("Unknown from node for code generation" + fromNode);
      }
    }
  }