コード例 #1
0
  public String getXML() {
    StringBuffer retval = new StringBuffer(800);

    retval.append("    ").append(XMLHandler.addTagValue("separator", separator));
    retval.append("    ").append(XMLHandler.addTagValue("enclosure", enclosure));
    retval.append("    ").append(XMLHandler.addTagValue("enclosure_forced", enclosureForced));
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("enclosure_fix_disabled", disableEnclosureFix));
    retval.append("    ").append(XMLHandler.addTagValue("header", headerEnabled));
    retval.append("    ").append(XMLHandler.addTagValue("footer", footerEnabled));
    retval.append("    ").append(XMLHandler.addTagValue("format", fileFormat));
    retval.append("    ").append(XMLHandler.addTagValue("compression", fileCompression));
    retval.append("    ").append(XMLHandler.addTagValue("encoding", encoding));
    retval.append("    ").append(XMLHandler.addTagValue("endedLine", endedLine));
    retval.append("    " + XMLHandler.addTagValue("fileNameInField", fileNameInField));
    retval.append("    " + XMLHandler.addTagValue("fileNameField", fileNameField));
    retval.append("    " + XMLHandler.addTagValue("create_parent_folder", createparentfolder));
    retval.append("    <file>").append(Const.CR);
    saveSource(retval, fileName);
    retval.append("      ").append(XMLHandler.addTagValue("is_command", fileAsCommand));
    retval.append("      ").append(XMLHandler.addTagValue("servlet_output", servletOutput));
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("do_not_open_new_file_init", doNotOpenNewFileInit));
    retval.append("      ").append(XMLHandler.addTagValue("extention", extension));
    retval.append("      ").append(XMLHandler.addTagValue("append", fileAppended));
    retval.append("      ").append(XMLHandler.addTagValue("split", stepNrInFilename));
    retval.append("      ").append(XMLHandler.addTagValue("haspartno", partNrInFilename));
    retval.append("      ").append(XMLHandler.addTagValue("add_date", dateInFilename));
    retval.append("      ").append(XMLHandler.addTagValue("add_time", timeInFilename));
    retval.append("      ").append(XMLHandler.addTagValue("SpecifyFormat", specifyingFormat));
    retval.append("      ").append(XMLHandler.addTagValue("date_time_format", dateTimeFormat));

    retval
        .append("      ")
        .append(XMLHandler.addTagValue("add_to_result_filenames", addToResultFilenames));
    retval.append("      ").append(XMLHandler.addTagValue("pad", padded));
    retval.append("      ").append(XMLHandler.addTagValue("fast_dump", fastDump));
    retval.append("      ").append(XMLHandler.addTagValue("splitevery", splitEvery));
    retval.append("    </file>").append(Const.CR);

    retval.append("    <fields>").append(Const.CR);
    for (int i = 0; i < outputFields.length; i++) {
      TextFileField field = outputFields[i];

      if (field.getName() != null && field.getName().length() != 0) {
        retval.append("      <field>").append(Const.CR);
        retval.append("        ").append(XMLHandler.addTagValue("name", field.getName()));
        retval.append("        ").append(XMLHandler.addTagValue("type", field.getTypeDesc()));
        retval.append("        ").append(XMLHandler.addTagValue("format", field.getFormat()));
        retval
            .append("        ")
            .append(XMLHandler.addTagValue("currency", field.getCurrencySymbol()));
        retval
            .append("        ")
            .append(XMLHandler.addTagValue("decimal", field.getDecimalSymbol()));
        retval
            .append("        ")
            .append(XMLHandler.addTagValue("group", field.getGroupingSymbol()));
        retval.append("        ").append(XMLHandler.addTagValue("nullif", field.getNullString()));
        retval
            .append("        ")
            .append(XMLHandler.addTagValue("trim_type", field.getTrimTypeCode()));
        retval.append("        ").append(XMLHandler.addTagValue("length", field.getLength()));
        retval.append("        ").append(XMLHandler.addTagValue("precision", field.getPrecision()));
        retval.append("      </field>").append(Const.CR);
      }
    }
    retval.append("    </fields>").append(Const.CR);

    return retval.toString();
  }
コード例 #2
0
  public void saveRep(
      Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step)
      throws KettleException {
    try {
      rep.saveStepAttribute(id_transformation, id_step, "separator", separator);
      rep.saveStepAttribute(id_transformation, id_step, "enclosure", enclosure);
      rep.saveStepAttribute(id_transformation, id_step, "enclosure_forced", enclosureForced);
      rep.saveStepAttribute(
          id_transformation, id_step, 0, "enclosure_fix_disabled", disableEnclosureFix);
      rep.saveStepAttribute(id_transformation, id_step, "header", headerEnabled);
      rep.saveStepAttribute(id_transformation, id_step, "footer", footerEnabled);
      rep.saveStepAttribute(id_transformation, id_step, "format", fileFormat);
      rep.saveStepAttribute(id_transformation, id_step, "compression", fileCompression);
      rep.saveStepAttribute(id_transformation, id_step, "encoding", encoding);
      saveSourceRep(rep, id_transformation, id_step, fileName);
      rep.saveStepAttribute(id_transformation, id_step, "file_is_command", fileAsCommand);
      rep.saveStepAttribute(id_transformation, id_step, "file_servlet_output", servletOutput);
      rep.saveStepAttribute(
          id_transformation, id_step, "do_not_open_new_file_init", doNotOpenNewFileInit);
      rep.saveStepAttribute(id_transformation, id_step, "file_extention", extension);
      rep.saveStepAttribute(id_transformation, id_step, "file_append", fileAppended);
      rep.saveStepAttribute(id_transformation, id_step, "file_split", splitEvery);
      rep.saveStepAttribute(id_transformation, id_step, "file_add_stepnr", stepNrInFilename);
      rep.saveStepAttribute(id_transformation, id_step, "file_add_partnr", partNrInFilename);
      rep.saveStepAttribute(id_transformation, id_step, "file_add_date", dateInFilename);
      rep.saveStepAttribute(id_transformation, id_step, "date_time_format", dateTimeFormat);
      rep.saveStepAttribute(id_transformation, id_step, "create_parent_folder", createparentfolder);
      rep.saveStepAttribute(id_transformation, id_step, "SpecifyFormat", specifyingFormat);

      rep.saveStepAttribute(
          id_transformation, id_step, "add_to_result_filenames", addToResultFilenames);
      rep.saveStepAttribute(id_transformation, id_step, "file_add_time", timeInFilename);
      rep.saveStepAttribute(id_transformation, id_step, "file_pad", padded);
      rep.saveStepAttribute(id_transformation, id_step, "file_fast_dump", fastDump);
      rep.saveStepAttribute(id_transformation, id_step, "fileNameInField", fileNameInField);
      rep.saveStepAttribute(id_transformation, id_step, "fileNameField", fileNameField);

      for (int i = 0; i < outputFields.length; i++) {
        TextFileField field = outputFields[i];

        rep.saveStepAttribute(id_transformation, id_step, i, "field_name", field.getName());
        rep.saveStepAttribute(id_transformation, id_step, i, "field_type", field.getTypeDesc());
        rep.saveStepAttribute(id_transformation, id_step, i, "field_format", field.getFormat());
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_currency", field.getCurrencySymbol());
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_decimal", field.getDecimalSymbol());
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_group", field.getGroupingSymbol());
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_trim_type", field.getTrimTypeCode());
        rep.saveStepAttribute(id_transformation, id_step, i, "field_nullif", field.getNullString());
        rep.saveStepAttribute(id_transformation, id_step, i, "field_length", field.getLength());
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_precision", field.getPrecision());
      }
      rep.saveStepAttribute(id_transformation, id_step, "endedLine", endedLine);
    } catch (Exception e) {
      throw new KettleException(
          "Unable to save step information to the repository for id_step=" + id_step, e);
    }
  }