コード例 #1
0
  // Save the attributes of this job entry
  //
  public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_job)
      throws KettleException {
    try {
      rep.saveJobEntryAttribute(id_job, getObjectId(), "file_name", filename);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "work_directory", workDirectory);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "arg_from_previous", argFromPrevious);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "exec_per_row", execPerRow);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "set_logfile", setLogfile);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "set_append_logfile", setAppendLogfile);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "add_date", addDate);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "add_time", addTime);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "logfile", logfile);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "logext", logext);
      rep.saveJobEntryAttribute(
          id_job,
          getObjectId(),
          "loglevel",
          logFileLevel == null ? LogLevel.NOTHING.getCode() : logFileLevel.getCode());
      rep.saveJobEntryAttribute(id_job, getObjectId(), "insertScript", insertScript);
      rep.saveJobEntryAttribute(id_job, getObjectId(), "script", script);

      // save the arguments...
      if (arguments != null) {
        for (int i = 0; i < arguments.length; i++) {
          rep.saveJobEntryAttribute(id_job, getObjectId(), i, "argument", arguments[i]);
        }
      }
    } catch (KettleDatabaseException dbe) {
      throw new KettleException("Unable to save job entry of type 'shell' to the repository", dbe);
    }
  }
コード例 #2
0
  public String getXML() {
    StringBuffer retval = new StringBuffer(300);

    retval.append(super.getXML());

    retval.append("      ").append(XMLHandler.addTagValue("filename", filename));
    retval.append("      ").append(XMLHandler.addTagValue("work_directory", workDirectory));
    retval.append("      ").append(XMLHandler.addTagValue("arg_from_previous", argFromPrevious));
    retval.append("      ").append(XMLHandler.addTagValue("exec_per_row", execPerRow));
    retval.append("      ").append(XMLHandler.addTagValue("set_logfile", setLogfile));
    retval.append("      ").append(XMLHandler.addTagValue("logfile", logfile));
    retval.append("      ").append(XMLHandler.addTagValue("set_append_logfile", setAppendLogfile));
    retval.append("      ").append(XMLHandler.addTagValue("logext", logext));
    retval.append("      ").append(XMLHandler.addTagValue("add_date", addDate));
    retval.append("      ").append(XMLHandler.addTagValue("add_time", addTime));
    retval.append("      ").append(XMLHandler.addTagValue("insertScript", insertScript));
    retval.append("      ").append(XMLHandler.addTagValue("script", script));

    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue(
                "loglevel", (logFileLevel == null) ? null : logFileLevel.getCode()));

    if (arguments != null) {
      for (int i = 0; i < arguments.length; i++) {
        // THIS IS A VERY BAD WAY OF READING/SAVING AS IT MAKES
        // THE XML "DUBIOUS". DON'T REUSE IT. (Sven B)
        retval.append("      ").append(XMLHandler.addTagValue("argument" + i, arguments[i]));
      }
    }

    return retval.toString();
  }
コード例 #3
0
  public String getXML() throws IOException {
    StringBuilder xml = new StringBuilder(160);

    xml.append("  <" + XML_TAG + ">").append(Const.CR);

    xml.append("    ").append(XMLHandler.addTagValue("exec_local", executingLocally));

    xml.append("    ").append(XMLHandler.addTagValue("exec_remote", executingRemotely));
    if (remoteServer != null) {
      xml.append("    ").append(remoteServer.getXML()).append(Const.CR);
    }
    xml.append("    ").append(XMLHandler.addTagValue("pass_export", passingExport));

    // Serialize the parameters...
    //
    xml.append("    <parameters>").append(Const.CR);
    List<String> paramNames = new ArrayList<String>(params.keySet());
    Collections.sort(paramNames);
    for (String name : paramNames) {
      String value = params.get(name);
      xml.append("    <parameter>");
      xml.append(XMLHandler.addTagValue("name", name, false));
      xml.append(XMLHandler.addTagValue("value", value, false));
      xml.append("</parameter>").append(Const.CR);
    }
    xml.append("    </parameters>").append(Const.CR);

    // Serialize the variables...
    //
    xml.append("    <variables>").append(Const.CR);
    List<String> variableNames = new ArrayList<String>(variables.keySet());
    Collections.sort(variableNames);
    for (String name : variableNames) {
      String value = variables.get(name);
      xml.append("    <variable>");
      xml.append(XMLHandler.addTagValue("name", name, false));
      xml.append(XMLHandler.addTagValue("value", value, false));
      xml.append("</variable>").append(Const.CR);
    }
    xml.append("    </variables>").append(Const.CR);

    // Serialize the variables...
    //
    xml.append("    <arguments>").append(Const.CR);
    List<String> argumentNames = new ArrayList<String>(arguments.keySet());
    Collections.sort(argumentNames);
    for (String name : argumentNames) {
      String value = arguments.get(name);
      xml.append("    <argument>");
      xml.append(XMLHandler.addTagValue("name", name, false));
      xml.append(XMLHandler.addTagValue("value", value, false));
      xml.append("</argument>").append(Const.CR);
    }
    xml.append("    </arguments>").append(Const.CR);

    xml.append("    ").append(XMLHandler.addTagValue("replay_date", replayDate));
    xml.append("    ").append(XMLHandler.addTagValue("safe_mode", safeModeEnabled));
    xml.append("    ").append(XMLHandler.addTagValue("log_level", logLevel.getCode()));
    xml.append("    ").append(XMLHandler.addTagValue("clear_log", clearingLog));

    xml.append("    ").append(XMLHandler.addTagValue("start_copy_name", startCopyName));
    xml.append("    ").append(XMLHandler.addTagValue("start_copy_nr", startCopyNr));

    xml.append("    ").append(XMLHandler.addTagValue("gather_metrics", gatheringMetrics));
    xml.append("    ").append(XMLHandler.addTagValue("expand_remote_job", expandingRemoteJob));
    if (passedBatchId != null) {
      xml.append("    ").append(XMLHandler.addTagValue("passedBatchId", passedBatchId));
    }

    // The source rows...
    //
    if (previousResult != null) {
      xml.append(previousResult.getXML());
    }

    // Send the repository name and user to the remote site...
    //
    if (repository != null) {
      xml.append(XMLHandler.openTag("repository"));
      xml.append(XMLHandler.addTagValue("name", repository.getName()));
      // File base repositories doesn't have user info
      if (repository.getUserInfo() != null) {
        xml.append(XMLHandler.addTagValue("login", repository.getUserInfo().getLogin()));
        xml.append(
            XMLHandler.addTagValue(
                "password", Encr.encryptPassword(repository.getUserInfo().getPassword())));
      }
      xml.append(XMLHandler.closeTag("repository"));
    }

    xml.append("</" + XML_TAG + ">").append(Const.CR);
    return xml.toString();
  }