示例#1
0
 /**
  * @param inputNode
  * @param pw
  */
 private void writeParameter(InputNode inputNode, PrintWriter pw) {
   String id = inputNode.getID();
   Object value = inputNode.getDefaultValue();
   String valueString = "";
   if (value instanceof String) {
     valueString = (String) value;
   }
   writeSetProperty(id, valueString, pw);
 }
示例#2
0
  /**
   * @param warnings returns the warning messages.
   * @return true if the workflow is valid; false otherwise.
   */
  public boolean validate(List<String> warnings) {
    // Empty
    if (this.graph.getNodes().size() == 0) {
      String message = "The workflow is empty.";
      warnings.add(message);
    }

    // Input ports need to be connected.
    Collection<Port> inputPorts = GraphUtil.getPorts(this.graph, Port.Kind.DATA_IN);
    for (Port inputPort : inputPorts) {
      Collection<Port> fromPorts = inputPort.getFromPorts();
      if (fromPorts.size() == 0) {
        Node node = inputPort.getNode();
        String message = node.getID() + " has an unconnected input " + inputPort.getName();
        warnings.add(message);
      }
    }

    // Input nodes need to be connected.
    for (InputNode inputNode : this.inputNodes) {
      if (inputNode.getPort().getToPorts().size() == 0) {
        String message = inputNode.getID() + " is not connected to any service.";
        warnings.add(message);
      }
    }

    // Cycle
    if (GraphUtil.containsCycle(this.graph)) {
      String message = "There is a cycle in the workflow, only acyclic workflows are supported";
      warnings.add(message);
    }

    // Constants are not supported.
    List<ConstantNode> constantNodes = GraphUtil.getNodes(this.graph, ConstantNode.class);
    if (constantNodes.size() > 0) {
      String message = "Constants are not supported for Jython scripts.";
      warnings.add(message);
    }

    // If/endif are not supported.
    List<IfNode> ifNodes = GraphUtil.getNodes(this.graph, IfNode.class);
    List<EndifNode> endifNodes = GraphUtil.getNodes(this.graph, EndifNode.class);
    if (ifNodes.size() > 0 || endifNodes.size() > 0) {
      String message = "If/endif are not supported for Jython scripts.";
      warnings.add(message);
    }

    if (warnings.size() > 0) {
      return false;
    } else {
      // No error.
      return true;
    }
  }
示例#3
0
  /** @param pw */
  private void writeSetup(PrintWriter pw) {
    // Initialize some variables.
    pw.println(
        GFAC_VARIABLE
            + " = "
            + PROPERTIES_VARIABLE
            + "."
            + GET_PROPERTY_METHOD
            + "('"
            + GFAC_VARIABLE
            + "')");
    pw.println(
        TOPIC_VARIABLE
            + " = "
            + PROPERTIES_VARIABLE
            + "."
            + GET_PROPERTY_METHOD
            + "('"
            + TOPIC_VARIABLE
            + "')");
    pw.println(
        BROKER_URL_VARIABLE
            + " = "
            + PROPERTIES_VARIABLE
            + "."
            + GET_PROPERTY_METHOD
            + "('"
            + BROKER_URL_VARIABLE
            + "')");
    pw.println(
        MESSAGE_BOX_URL_VARIABLE
            + " = "
            + PROPERTIES_VARIABLE
            + "."
            + GET_PROPERTY_METHOD
            + "('"
            + MESSAGE_BOX_URL_VARIABLE
            + "')");

    // Initialize a notification sender.
    //        pw.println(NOTIFICATION_VARIABLE + " = " + NOTIFICATION_CLASS + "(" +
    // BROKER_URL_VARIABLE + ", "
    //                + TOPIC_VARIABLE + ")");

    // Send a START_WORKFLOW notification.
    pw.println(NOTIFICATION_VARIABLE + "." + WORKFLOW_STARTED_METHOD + "(");
    boolean first = true;
    for (InputNode inputNode : this.inputNodes) {
      String id = inputNode.getID();
      if (first) {
        first = false;
      } else {
        pw.println(",");
      }
      pw.print(TAB + id + "=" + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + id + "')");
    }
    pw.println(")");

    pw.println();

    // The biggining of try
    pw.println("try:");
  }