コード例 #1
0
  public void saveRep(
      Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step)
      throws KettleException {
    try {
      rep.saveStepAttribute(id_transformation, id_step, "file_type", fileType);
      rep.saveStepAttribute(id_transformation, id_step, "section", section);
      rep.saveStepAttribute(id_transformation, id_step, "encoding", encoding);
      rep.saveStepAttribute(id_transformation, id_step, "ini_section", includeIniSection);
      rep.saveStepAttribute(id_transformation, id_step, "ini_section_field", iniSectionField);
      rep.saveStepAttribute(id_transformation, id_step, "include", includeFilename);
      rep.saveStepAttribute(id_transformation, id_step, "include_field", filenameField);
      rep.saveStepAttribute(id_transformation, id_step, "rownum", includeRowNumber);
      rep.saveStepAttribute(id_transformation, id_step, "isaddresult", isaddresult);
      rep.saveStepAttribute(id_transformation, id_step, "filefield", filefield);
      rep.saveStepAttribute(id_transformation, id_step, "filename_Field", dynamicFilenameField);
      rep.saveStepAttribute(id_transformation, id_step, "rownum_field", rowNumberField);
      rep.saveStepAttribute(id_transformation, id_step, "limit", rowLimit);
      rep.saveStepAttribute(id_transformation, id_step, "reset_rownumber", resetRowNumber);
      rep.saveStepAttribute(
          id_transformation, id_step, "resolve_value_variable", resolvevaluevariable);
      rep.saveStepAttribute(id_transformation, id_step, "sizeFieldName", sizeFieldName);

      for (int i = 0; i < fileName.length; i++) {
        rep.saveStepAttribute(id_transformation, id_step, i, "file_name", fileName[i]);
        rep.saveStepAttribute(id_transformation, id_step, i, "file_mask", fileMask[i]);
        rep.saveStepAttribute(
            id_transformation, id_step, i, "exclude_file_mask", excludeFileMask[i]);
        rep.saveStepAttribute(id_transformation, id_step, i, "file_required", fileRequired[i]);
        rep.saveStepAttribute(
            id_transformation, id_step, i, "include_subfolders", includeSubFolders[i]);
      }

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

        rep.saveStepAttribute(id_transformation, id_step, i, "field_name", field.getName());
        rep.saveStepAttribute(id_transformation, id_step, i, "field_column", field.getColumnCode());
        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.getGroupSymbol());
        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, i, "field_trim_type", field.getTrimTypeCode());
        rep.saveStepAttribute(id_transformation, id_step, i, "field_repeat", field.isRepeated());
      }
      rep.saveStepAttribute(id_transformation, id_step, "shortFileFieldName", shortFileFieldName);
      rep.saveStepAttribute(id_transformation, id_step, "pathFieldName", pathFieldName);
      rep.saveStepAttribute(id_transformation, id_step, "hiddenFieldName", hiddenFieldName);
      rep.saveStepAttribute(
          id_transformation,
          id_step,
          "lastModificationTimeFieldName",
          lastModificationTimeFieldName);
      rep.saveStepAttribute(id_transformation, id_step, "uriNameFieldName", uriNameFieldName);
      rep.saveStepAttribute(
          id_transformation, id_step, "rootUriNameFieldName", rootUriNameFieldName);
      rep.saveStepAttribute(id_transformation, id_step, "extensionFieldName", extensionFieldName);
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(
              PKG, "PropertyInputMeta.Exception.ErrorSavingToRepository", "" + id_step),
          e);
    }
  }
コード例 #2
0
  public void getFields(
      RowMetaInterface r,
      String name,
      RowMetaInterface[] info,
      StepMeta nextStep,
      VariableSpace space,
      Repository repository,
      IMetaStore metaStore)
      throws KettleStepException {

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

      int type = field.getType();
      if (type == ValueMetaInterface.TYPE_NONE) {
        type = ValueMetaInterface.TYPE_STRING;
      }
      try {
        ValueMetaInterface v =
            ValueMetaFactory.createValueMeta(space.environmentSubstitute(field.getName()), type);
        v.setLength(field.getLength());
        v.setPrecision(field.getPrecision());
        v.setOrigin(name);
        v.setConversionMask(field.getFormat());
        v.setDecimalSymbol(field.getDecimalSymbol());
        v.setGroupingSymbol(field.getGroupSymbol());
        v.setCurrencySymbol(field.getCurrencySymbol());
        r.addValueMeta(v);
      } catch (Exception e) {
        throw new KettleStepException(e);
      }
    }
    String realFilenameField = space.environmentSubstitute(filenameField);
    if (includeFilename && !Utils.isEmpty(realFilenameField)) {
      ValueMetaInterface v = new ValueMetaString(realFilenameField);
      v.setLength(500);
      v.setPrecision(-1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }

    String realRowNumberField = space.environmentSubstitute(rowNumberField);
    if (includeRowNumber && !Utils.isEmpty(realRowNumberField)) {
      ValueMetaInterface v = new ValueMetaInteger(realRowNumberField);
      v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
      v.setOrigin(name);
      r.addValueMeta(v);
    }
    String realSectionField = space.environmentSubstitute(iniSectionField);
    if (includeIniSection && !Utils.isEmpty(realSectionField)) {
      ValueMetaInterface v = new ValueMetaString(realSectionField);
      v.setLength(500);
      v.setPrecision(-1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }
    // Add additional fields

    if (getShortFileNameField() != null && getShortFileNameField().length() > 0) {
      ValueMetaInterface v =
          new ValueMetaString(space.environmentSubstitute(getShortFileNameField()));
      v.setLength(100, -1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }
    if (getExtensionField() != null && getExtensionField().length() > 0) {
      ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getExtensionField()));
      v.setLength(100, -1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }
    if (getPathField() != null && getPathField().length() > 0) {
      ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getPathField()));
      v.setLength(100, -1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }
    if (getSizeField() != null && getSizeField().length() > 0) {
      ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(getSizeField()));
      v.setOrigin(name);
      v.setLength(9);
      r.addValueMeta(v);
    }
    if (isHiddenField() != null && isHiddenField().length() > 0) {
      ValueMetaInterface v = new ValueMetaBoolean(space.environmentSubstitute(isHiddenField()));
      v.setOrigin(name);
      r.addValueMeta(v);
    }

    if (getLastModificationDateField() != null && getLastModificationDateField().length() > 0) {
      ValueMetaInterface v =
          new ValueMetaDate(space.environmentSubstitute(getLastModificationDateField()));
      v.setOrigin(name);
      r.addValueMeta(v);
    }
    if (getUriField() != null && getUriField().length() > 0) {
      ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getUriField()));
      v.setLength(100, -1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }

    if (getRootUriField() != null && getRootUriField().length() > 0) {
      ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getRootUriField()));
      v.setLength(100, -1);
      v.setOrigin(name);
      r.addValueMeta(v);
    }
  }