Esempio n. 1
0
 /*
  * Creates the variables element
  */
 private Element createVariablesElement(Document doc, Map<String, String> variables) {
   if (variables == null) {
     return null;
   }
   Element variablesE =
       doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.VARIABLES.getXMLName());
   for (String name : variables.keySet()) {
     Element variableE =
         createElement(
             doc,
             XMLTags.VARIABLE.getXMLName(),
             null,
             new Attribute(XMLAttributes.COMMON_NAME.getXMLName(), name),
             new Attribute(XMLAttributes.COMMON_VALUE.getXMLName(), variables.get(name)));
     variablesE.appendChild(variableE);
   }
   return variablesE;
 }
Esempio n. 2
0
 /** Creates the task variables element */
 private Element createTaskVariablesElement(Document doc, Map<String, TaskVariable> variables) {
   if (variables == null) {
     return null;
   }
   Element variablesE =
       doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.VARIABLES.getXMLName());
   for (TaskVariable variable : variables.values()) {
     Element variableE =
         createElement(
             doc,
             XMLTags.VARIABLE.getXMLName(),
             null,
             new Attribute(XMLAttributes.VARIABLE_NAME.getXMLName(), variable.getName()),
             new Attribute(XMLAttributes.VARIABLE_VALUE.getXMLName(), variable.getValue()),
             new Attribute(XMLAttributes.VARIABLE_MODEL.getXMLName(), variable.getModel()),
             new Attribute(
                 XMLAttributes.VARIABLE_JOB_INHERITED.getXMLName(),
                 String.valueOf(variable.isJobInherited())));
     variablesE.appendChild(variableE);
   }
   return variablesE;
 }
Esempio n. 3
0
  /** Corresponds to <element name="forkEnvironment"> */
  private Element createForkEnvironmentElement(Document doc, ForkEnvironment fe) {
    Element forkEnvE =
        doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.FORK_ENVIRONMENT.getXMLName());
    // attributes
    setAttribute(forkEnvE, XMLAttributes.TASK_WORKDING_DIR, fe.getWorkingDir(), true);
    setAttribute(forkEnvE, XMLAttributes.FORK_JAVA_HOME, fe.getJavaHome(), true);

    // <ref name="sysProps"/>
    if ((fe.getSystemEnvironment() != null) && (fe.getSystemEnvironment().keySet().size() > 0)) {
      // <element name="SystemEnvironment">
      Element sysEnvE =
          doc.createElementNS(
              Schemas.SCHEMA_LATEST.namespace, XMLTags.FORK_SYSTEM_PROPERTIES.getXMLName());
      if (fe.getSystemEnvironment() != null) {

        // <oneOrMore>
        // <ref name="sysProp"/>
        // </oneOrMore>
        for (Map.Entry<String, String> entry : fe.getSystemEnvironment().entrySet()) {
          Element variableE =
              doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.VARIABLE.getXMLName());
          setAttribute(variableE, XMLAttributes.COMMON_NAME, entry.getKey());
          setAttribute(variableE, XMLAttributes.COMMON_VALUE, entry.getValue());

          sysEnvE.appendChild(variableE);
        }
      }
      forkEnvE.appendChild(sysEnvE);
    }

    // <ref name="jvmArgs"/>
    List<String> args = fe.getJVMArguments();
    if (args != null && (args.size() > 0)) {
      Element jvmArgsE =
          doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.FORK_JVM_ARGS.getXMLName());
      for (String arg : args) {
        Element argE =
            doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.FORK_JVM_ARG.getXMLName());
        setAttribute(argE, XMLAttributes.COMMON_VALUE, arg, true);
        jvmArgsE.appendChild(argE);
      }
      forkEnvE.appendChild(jvmArgsE);
    }

    // <ref name="additionalClasspath"/>
    List<String> additionalCP = fe.getAdditionalClasspath();
    if ((additionalCP != null) && (additionalCP.size() > 0)) {
      Element additionalCPE =
          doc.createElementNS(
              Schemas.SCHEMA_LATEST.namespace, XMLTags.FORK_ADDITIONAL_CLASSPATH.getXMLName());
      for (String pathElement : additionalCP) {
        Element pathE =
            doc.createElementNS(
                Schemas.SCHEMA_LATEST.namespace, XMLTags.FORK_PATH_ELEMENT.getXMLName());
        setAttribute(pathE, XMLAttributes.PATH, pathElement, true);
        additionalCPE.appendChild(pathE);
      }

      forkEnvE.appendChild(additionalCPE);
    }

    // <ref name="envScript"/>
    if (fe.getEnvScript() != null) {
      Element envScriptE =
          doc.createElementNS(Schemas.SCHEMA_LATEST.namespace, XMLTags.SCRIPT_ENV.getXMLName());
      Element scriptElement = createScriptElement(doc, fe.getEnvScript());
      envScriptE.appendChild(scriptElement);
      forkEnvE.appendChild(envScriptE);
    }
    return forkEnvE;
  }