Esempio n. 1
0
  private void writeOutput(OutputNode node, PrintWriter pw) throws GraphException {
    String id = node.getID();
    Port port = node.getPort();

    Node fromNode = port.getFromNode();
    if (fromNode == null) {
      throw new GraphException("Output parameter has to be connected to some node.");
    }
    Port fromPort = port.getFromPort();
    if (fromNode instanceof InputNode) {
      // The OutputNode is directly connected to an InputNode.
      pw.println(
          TAB
              + id
              + VALUE_SUFFIX
              + " = "
              + PROPERTIES_VARIABLE
              + "."
              + GET_PROPERTY_METHOD
              + "('"
              + fromNode.getID()
              + "')");
    } else {
      pw.println(TAB + "# Wait output " + id);
      pw.println(
          TAB
              + id
              + VALUE_SUFFIX
              + " = "
              + fromNode.getID()
              + INVOKER_SUFFIX
              + "."
              + GET_OUTPUT_METHOD
              + "('"
              + fromPort.getName()
              + "')");
    }
    pw.println(TAB + "print '" + id + " = ', " + id + VALUE_SUFFIX);

    // This might try to remove a node that has been removed
    // already, but it's OK.
    this.executingNodes.remove(fromNode);

    pw.println();
  }
Esempio n. 2
0
  /** @param pw */
  private void writeFooter(PrintWriter pw) {
    // Send a COMPLETE_WORKFLOW notification.
    pw.println(TAB + NOTIFICATION_VARIABLE + "." + WORKFLOW_COMPLETED_METHOD + "(");
    boolean first = true;
    for (OutputNode node : this.outputNodes) {
      if (first) {
        first = false;
      } else {
        pw.println(",");
      }
      String id = node.getID();
      pw.print(TAB + TAB + id + "=" + id + VALUE_SUFFIX);
    }
    pw.println(")");

    pw.println(TAB + "print 'Everything is done successfully.'");

    pw.println();
    pw.println("except Throwable, e:");
    pw.println(TAB + "print 'Error: ', e");
    pw.println(TAB + NOTIFICATION_VARIABLE + "." + WORKFLOW_INCOMPLETED_METHOD + "(e)");
  }