示例#1
0
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    int i;
    logDebug(BaseMessages.getString(PKG, "DBProcDialog.Log.GettingKeyInfo")); // $NON-NLS-1$

    if (input.getArgument() != null)
      for (i = 0; i < input.getArgument().length; i++) {
        TableItem item = wFields.table.getItem(i);
        if (input.getArgument()[i] != null) item.setText(1, input.getArgument()[i]);
        if (input.getArgumentDirection()[i] != null)
          item.setText(2, input.getArgumentDirection()[i]);
        item.setText(3, ValueMeta.getTypeDesc(input.getArgumentType()[i]));
      }

    if (input.getDatabase() != null) wConnection.setText(input.getDatabase().getName());
    else if (transMeta.nrDatabases() == 1) {
      wConnection.setText(transMeta.getDatabase(0).getName());
    }
    if (input.getProcedure() != null) wProcName.setText(input.getProcedure());
    if (input.getResultName() != null) wResult.setText(input.getResultName());
    wResultType.setText(ValueMeta.getTypeDesc(input.getResultType()));

    wAutoCommit.setSelection(input.isAutoCommit());

    wFields.setRowNums();
    wFields.optWidth(true);
    wStepname.selectAll();
  }
  public void getInfo(SasInputMeta meta) throws KettleStepException {
    // copy info to Meta class (input)
    meta.setAcceptingField(wAccField.getText());

    int nrNonEmptyFields = wFields.nrNonEmpty();
    meta.getOutputFields().clear();

    for (int i = 0; i < nrNonEmptyFields; i++) {
      TableItem item = wFields.getNonEmpty(i);

      int colnr = 1;
      SasInputField field = new SasInputField();
      field.setName(item.getText(colnr++));
      field.setRename(item.getText(colnr++));
      if (Const.isEmpty(field.getRename())) {
        field.setRename(field.getName());
      }
      field.setType(ValueMeta.getType(item.getText(colnr++)));
      field.setConversionMask(item.getText(colnr++));
      field.setLength(Const.toInt(item.getText(colnr++), -1));
      field.setPrecision(Const.toInt(item.getText(colnr++), -1));
      field.setDecimalSymbol(item.getText(colnr++));
      field.setGroupingSymbol(item.getText(colnr++));
      field.setTrimType(ValueMeta.getTrimTypeByDesc(item.getText(colnr++)));

      meta.getOutputFields().add(field);
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
  }
示例#3
0
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    try {
      databaseMeta =
          DatabaseMeta.findDatabase(databases, XMLHandler.getTagValue(stepnode, "connection"));

      String functionName = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "name");
      String functionDescription =
          XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "description");
      String functionGroup = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "group");
      String functionApplication =
          XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "application");
      String functionHost = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "host");

      if (!Const.isEmpty(functionName)) {
        function =
            new SAPFunction(
                functionName,
                functionDescription,
                functionGroup,
                functionApplication,
                functionHost);
      } else {
        function = null;
      }

      Node paramsNode = XMLHandler.getSubNode(stepnode, XML_TAG_PARAMETERS);
      int nrParameters = XMLHandler.countNodes(paramsNode, XML_TAG_PARAMETER);
      for (int i = 0; i < nrParameters; i++) {
        Node paramNode = XMLHandler.getSubNodeByNr(paramsNode, XML_TAG_PARAMETER, i);
        String fieldName = XMLHandler.getTagValue(paramNode, "field_name");
        SapType sapType = SapType.findTypeForCode(XMLHandler.getTagValue(paramNode, "sap_type"));
        String tableName = XMLHandler.getTagValue(paramNode, "table_name");
        int targetType = ValueMeta.getType(XMLHandler.getTagValue(paramNode, "target_type"));
        String parameterName = XMLHandler.getTagValue(paramNode, "parameter_name");
        parameters.add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType));
      }

      Node fieldsNode = XMLHandler.getSubNode(stepnode, XML_TAG_FIELDS);
      int nrFields = XMLHandler.countNodes(fieldsNode, XML_TAG_FIELD);
      for (int i = 0; i < nrFields; i++) {
        Node fieldNode = XMLHandler.getSubNodeByNr(fieldsNode, XML_TAG_FIELD, i);
        String sapFieldName = XMLHandler.getTagValue(fieldNode, "field_name");
        SapType sapType = SapType.findTypeForCode(XMLHandler.getTagValue(fieldNode, "sap_type"));
        String tableName = XMLHandler.getTagValue(fieldNode, "table_name");
        int targetType = ValueMeta.getType(XMLHandler.getTagValue(fieldNode, "target_type"));
        String newName = XMLHandler.getTagValue(fieldNode, "new_name");
        outputFields.add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType));
      }

    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
示例#4
0
  public void readRep(
      Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters)
      throws KettleException {
    try {
      databaseMeta =
          rep.loadDatabaseMetaFromStepAttribute(id_step, "id_connection", databases); // $NON-NLS-1$

      String functionName = rep.getStepAttributeString(id_step, "function_name");
      String functionDescription = rep.getStepAttributeString(id_step, "function_description");
      String functionGroup = rep.getStepAttributeString(id_step, "function_group");
      String functionApplication = rep.getStepAttributeString(id_step, "function_application");
      String functionHost = rep.getStepAttributeString(id_step, "function_host");

      if (!Const.isEmpty(functionName)) {
        function =
            new SAPFunction(
                functionName,
                functionDescription,
                functionGroup,
                functionApplication,
                functionHost);
      } else {
        function = null;
      }

      int nrParameters = rep.countNrStepAttributes(id_step, "parameter_field_name");
      for (int i = 0; i < nrParameters; i++) {
        String fieldName = rep.getStepAttributeString(id_step, i, "parameter_field_name");
        SapType sapType =
            SapType.findTypeForCode(rep.getStepAttributeString(id_step, i, "parameter_sap_type"));
        String tableName = rep.getStepAttributeString(id_step, i, "parameter_table_name");
        int targetType =
            ValueMeta.getType(rep.getStepAttributeString(id_step, i, "parameter_target_type"));
        String parameterName = rep.getStepAttributeString(id_step, i, "parameter_name");
        parameters.add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType));
      }

      int nrFields = rep.countNrStepAttributes(id_step, "field_sap_field_name");
      for (int i = 0; i < nrFields; i++) {
        String sapFieldName = rep.getStepAttributeString(id_step, i, "field_sap_field_name");
        SapType sapType =
            SapType.findTypeForCode(rep.getStepAttributeString(id_step, i, "field_sap_type"));
        String tableName = rep.getStepAttributeString(id_step, i, "field_table_name");
        int targetType =
            ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_target_type"));
        String newName = rep.getStepAttributeString(id_step, i, "field_new_name");
        outputFields.add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType));
      }
    } catch (Exception e) {
      throw new KettleException("Unexpected error reading step information from the repository", e);
    }
  }
示例#5
0
  public String getXML() {
    StringBuffer retval = new StringBuffer();

    retval.append(
        "    "
            + XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));

    retval.append("    ").append(XMLHandler.openTag(XML_TAG_FUNCTION)).append(Const.CR);
    if (function != null && !Const.isEmpty(function.getName())) {
      retval.append("    " + XMLHandler.addTagValue("name", function.getName()));
      retval.append("    " + XMLHandler.addTagValue("description", function.getDescription()));
      retval.append("    " + XMLHandler.addTagValue("group", function.getGroup()));
      retval.append("    " + XMLHandler.addTagValue("application", function.getApplication()));
      retval.append("    " + XMLHandler.addTagValue("host", function.getHost()));
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_FUNCTION)).append(Const.CR);

    retval.append("    ").append(XMLHandler.openTag(XML_TAG_PARAMETERS)).append(Const.CR);
    for (SapParameter parameter : parameters) {
      retval.append("    ").append(XMLHandler.openTag(XML_TAG_PARAMETER));
      retval.append(XMLHandler.addTagValue("field_name", parameter.getFieldName(), false));
      retval.append(XMLHandler.addTagValue("sap_type", parameter.getSapType().getCode(), false));
      retval.append(XMLHandler.addTagValue("table_name", parameter.getTableName(), false));
      retval.append(XMLHandler.addTagValue("parameter_name", parameter.getParameterName(), false));
      retval.append(
          XMLHandler.addTagValue(
              "target_type", ValueMeta.getTypeDesc(parameter.getTargetType()), false));
      retval.append("    ").append(XMLHandler.closeTag(XML_TAG_PARAMETER)).append(Const.CR);
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_PARAMETERS)).append(Const.CR);

    retval.append("    ").append(XMLHandler.openTag(XML_TAG_FIELDS)).append(Const.CR);
    for (SapOutputField parameter : outputFields) {
      retval.append("    ").append(XMLHandler.openTag(XML_TAG_FIELD));
      retval.append(XMLHandler.addTagValue("field_name", parameter.getSapFieldName(), false));
      retval.append(XMLHandler.addTagValue("sap_type", parameter.getSapType().getCode(), false));
      retval.append(XMLHandler.addTagValue("table_name", parameter.getTableName(), false));
      retval.append(XMLHandler.addTagValue("new_name", parameter.getNewName(), false));
      retval.append(
          XMLHandler.addTagValue(
              "target_type", ValueMeta.getTypeDesc(parameter.getTargetType()), false));
      retval.append("    ").append(XMLHandler.closeTag(XML_TAG_FIELD)).append(Const.CR);
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_FIELDS)).append(Const.CR);

    return retval.toString();
  }
示例#6
0
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    logDebug(BaseMessages.getString(PKG, "SapInputDialog.Log.GettingKeyInfo"));

    // The database connection name...
    //
    if (input.getDatabaseMeta() != null) {
      wConnection.setText(input.getDatabaseMeta().getName());
    } else if (transMeta.nrDatabases() == 1) {
      wConnection.setText(transMeta.getDatabase(0).getName());
    }

    // The name of the function to use
    //
    function = input.getFunction();
    if (input.getFunction() != null) {
      wFunction.setText(Const.NVL(input.getFunction().getName(), ""));
    }

    // The parameters...
    //
    for (int i = 0; i < input.getParameters().size(); i++) {
      SapParameter parameter = input.getParameters().get(i);
      TableItem item = wInput.table.getItem(i);
      int colnr = 1;
      item.setText(colnr++, Const.NVL(parameter.getFieldName(), ""));
      item.setText(colnr++, parameter.getSapType().getDescription());
      item.setText(colnr++, Const.NVL(parameter.getTableName(), ""));
      item.setText(colnr++, Const.NVL(parameter.getParameterName(), ""));
      item.setText(colnr++, ValueMeta.getTypeDesc(parameter.getTargetType()));
    }
    wInput.setRowNums();
    wInput.optWidth(true);

    // The parameters...
    //
    for (int i = 0; i < input.getOutputFields().size(); i++) {
      SapOutputField outputField = input.getOutputFields().get(i);
      TableItem item = wOutput.table.getItem(i);
      int colnr = 1;
      item.setText(colnr++, Const.NVL(outputField.getSapFieldName(), ""));
      item.setText(colnr++, outputField.getSapType().getDescription());
      item.setText(colnr++, Const.NVL(outputField.getTableName(), ""));
      item.setText(colnr++, Const.NVL(outputField.getNewName(), ""));
      item.setText(colnr++, ValueMeta.getTypeDesc(outputField.getTargetType()));
    }
    wOutput.setRowNums();
    wOutput.optWidth(true);
  }
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    wAccField.setText(Const.NVL(input.getAcceptingField(), ""));

    for (int i = 0; i < input.getOutputFields().size(); i++) {
      SasInputField field = input.getOutputFields().get(i);

      TableItem item = new TableItem(wFields.table, SWT.NONE);
      int colnr = 1;
      item.setText(colnr++, Const.NVL(field.getName(), ""));
      item.setText(colnr++, Const.NVL(field.getRename(), ""));
      item.setText(colnr++, ValueMeta.getTypeDesc(field.getType()));
      item.setText(colnr++, Const.NVL(field.getConversionMask(), ""));
      item.setText(colnr++, field.getLength() >= 0 ? Integer.toString(field.getLength()) : "");
      item.setText(
          colnr++, field.getPrecision() >= 0 ? Integer.toString(field.getPrecision()) : "");
      item.setText(colnr++, Const.NVL(field.getDecimalSymbol(), ""));
      item.setText(colnr++, Const.NVL(field.getGroupingSymbol(), ""));
      item.setText(colnr++, Const.NVL(field.getTrimTypeDesc(), ""));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);

    wStepname.selectAll();
    wStepname.setFocus();
  }
  public void saveRep(Repository rep, ObjectId id_transformation, ObjectId id_step)
      throws KettleException {
    try {
      for (int i = 0; i < fieldName.length; i++) {
        if (fieldName[i] != null && fieldName[i].length() != 0) {
          rep.saveStepAttribute(
              id_transformation, id_step, i, "field_name", fieldName[i]); // $NON-NLS-1$
          rep.saveStepAttribute(
              id_transformation,
              id_step,
              i,
              "field_type",
              ValueMeta.getTypeDesc(fieldType[i])); // $NON-NLS-1$
          rep.saveStepAttribute(
              id_transformation, id_step, i, "field_length", fieldLength[i]); // $NON-NLS-1$
          rep.saveStepAttribute(
              id_transformation, id_step, i, "field_precision", fieldPrecision[i]); // $NON-NLS-1$
        }
      }

      rep.saveStepAttribute(
          id_transformation,
          id_step,
          "select_unspecified",
          selectingAndSortingUnspecifiedFields); //$NON-NLS-1$
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(PKG, "MappingInputMeta.Exception.UnableToSaveStepInfo") + id_step,
          e); //$NON-NLS-1$
    }
  }
  /**
   * Load step attributes.
   *
   * @throws KettleException the kettle exception
   */
  protected void loadStepAttributes() throws KettleException {
    try {
      InputStream inputStream = getClass().getResourceAsStream(STEP_ATTRIBUTES_FILE);
      if (inputStream != null) {
        Document document = XMLHandler.loadXMLFile(inputStream);
        Node attrsNode = XMLHandler.getSubNode(document, "attributes");
        List<Node> nodes = XMLHandler.getNodes(attrsNode, "attribute");
        attributes = new ArrayList<KettleAttributeInterface>();
        for (Node node : nodes) {
          String key = XMLHandler.getTagAttribute(node, "id");
          String xmlCode = XMLHandler.getTagValue(node, "xmlcode");
          String repCode = XMLHandler.getTagValue(node, "repcode");
          String description = XMLHandler.getTagValue(node, "description");
          String tooltip = XMLHandler.getTagValue(node, "tooltip");
          int valueType = ValueMeta.getType(XMLHandler.getTagValue(node, "valuetype"));
          String parentId = XMLHandler.getTagValue(node, "parentid");

          KettleAttribute attribute =
              new KettleAttribute(
                  key,
                  xmlCode,
                  repCode,
                  description,
                  tooltip,
                  valueType,
                  findParent(attributes, parentId));
          attributes.add(attribute);
        }
      }
    } catch (Exception e) {
      throw new KettleException("Unable to load file " + STEP_ATTRIBUTES_FILE, e);
    }
  }
  public CalculatorMetaFunction(Repository rep, long id_step, int nr) throws KettleException {
    fieldName = rep.getStepAttributeString(id_step, nr, "field_name");
    calcType = getCalcFunctionType(rep.getStepAttributeString(id_step, nr, "calc_type"));
    fieldA = rep.getStepAttributeString(id_step, nr, "field_a");
    fieldB = rep.getStepAttributeString(id_step, nr, "field_b");
    fieldC = rep.getStepAttributeString(id_step, nr, "field_c");
    fieldD = rep.getStepAttributeString(id_step, nr, "field_d");
    fieldE = rep.getStepAttributeString(id_step, nr, "field_e");
    valueType = ValueMeta.getType(rep.getStepAttributeString(id_step, nr, "value_type"));
    valueLength = (int) rep.getStepAttributeInteger(id_step, nr, "value_length");
    valuePrecision = (int) rep.getStepAttributeInteger(id_step, nr, "value_precision");
    removedFromResult = rep.getStepAttributeBoolean(id_step, nr, "remove");
    conversionMask = rep.getStepAttributeString(id_step, nr, "conversion_mask");
    decimalSymbol = rep.getStepAttributeString(id_step, nr, "decimal_symbol");
    groupingSymbol = rep.getStepAttributeString(id_step, nr, "grouping_symbol");
    currencySymbol = rep.getStepAttributeString(id_step, nr, "currency_symbol");

    // Fix 2.x backward compatibility
    // The conversion mask was added in a certain revision.
    // Anything that we load from before then should get masks set to retain backward compatibility
    //
    if (rep.findStepAttributeID(id_step, nr, "conversion_mask") < 0) {
      fixBackwardCompatibility();
    }
  }
  public CalculatorMetaFunction(Node calcnode) {
    fieldName = XMLHandler.getTagValue(calcnode, "field_name");
    calcType = getCalcFunctionType(XMLHandler.getTagValue(calcnode, "calc_type"));
    fieldA = XMLHandler.getTagValue(calcnode, "field_a");
    fieldB = XMLHandler.getTagValue(calcnode, "field_b");
    fieldC = XMLHandler.getTagValue(calcnode, "field_c");
    fieldD = XMLHandler.getTagValue(calcnode, "field_d");
    fieldE = XMLHandler.getTagValue(calcnode, "field_e");
    valueType = ValueMeta.getType(XMLHandler.getTagValue(calcnode, "value_type"));
    valueLength = Const.toInt(XMLHandler.getTagValue(calcnode, "value_length"), -1);
    valuePrecision = Const.toInt(XMLHandler.getTagValue(calcnode, "value_precision"), -1);
    removedFromResult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "remove"));
    conversionMask = XMLHandler.getTagValue(calcnode, "conversion_mask");
    decimalSymbol = XMLHandler.getTagValue(calcnode, "decimal_symbol");
    groupingSymbol = XMLHandler.getTagValue(calcnode, "grouping_symbol");
    currencySymbol = XMLHandler.getTagValue(calcnode, "currency_symbol");

    // Fix 2.x backward compatibility
    // The conversion mask was added in a certain revision.
    // Anything that we load from before then should get masks set to retain backward compatibility
    //
    if (XMLHandler.getSubNode(calcnode, "conversion_mask") == null) {
      fixBackwardCompatibility();
    }
  }
  public String getXML() {
    String xml = "";

    xml += "<" + XML_TAG + ">";

    xml += XMLHandler.addTagValue("field_name", fieldName);
    xml += XMLHandler.addTagValue("calc_type", getCalcTypeDesc());
    xml += XMLHandler.addTagValue("field_a", fieldA);
    xml += XMLHandler.addTagValue("field_b", fieldB);
    xml += XMLHandler.addTagValue("field_c", fieldC);
    xml += XMLHandler.addTagValue("field_d", fieldD);
    xml += XMLHandler.addTagValue("field_e", fieldE);
    xml += XMLHandler.addTagValue("value_type", ValueMeta.getTypeDesc(valueType));
    xml += XMLHandler.addTagValue("value_length", valueLength);
    xml += XMLHandler.addTagValue("value_precision", valuePrecision);
    xml += XMLHandler.addTagValue("remove", removedFromResult);
    xml += XMLHandler.addTagValue("conversion_mask", conversionMask);
    xml += XMLHandler.addTagValue("decimal_symbol", decimalSymbol);
    xml += XMLHandler.addTagValue("grouping_symbol", groupingSymbol);
    xml += XMLHandler.addTagValue("currency_symbol", currencySymbol);

    xml += "</" + XML_TAG + ">";

    return xml;
  }
  public void readRep(
      Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters)
      throws KettleException {
    try {
      int nrfields = rep.countNrStepAttributes(id_step, "field_name"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        fieldName[i] = rep.getStepAttributeString(id_step, i, "field_name"); // $NON-NLS-1$
        fieldType[i] =
            ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type")); // $NON-NLS-1$
        fieldLength[i] =
            (int) rep.getStepAttributeInteger(id_step, i, "field_length"); // $NON-NLS-1$
        fieldPrecision[i] =
            (int) rep.getStepAttributeInteger(id_step, i, "field_precision"); // $NON-NLS-1$
      }

      selectingAndSortingUnspecifiedFields =
          rep.getStepAttributeBoolean(id_step, "select_unspecified");
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(
              PKG, "MappingInputMeta.Exception.UnexpectedErrorInReadingStepInfo"),
          e); //$NON-NLS-1$
    }
  }
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$

        fieldName[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$
        fieldType[i] = ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")); // $NON-NLS-1$
        String slength = XMLHandler.getTagValue(fnode, "length"); // $NON-NLS-1$
        String sprecision = XMLHandler.getTagValue(fnode, "precision"); // $NON-NLS-1$

        fieldLength[i] = Const.toInt(slength, -1);
        fieldPrecision[i] = Const.toInt(sprecision, -1);
      }

      selectingAndSortingUnspecifiedFields =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(fields, "select_unspecified"));
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "MappingInputMeta.Exception.UnableToLoadStepInfoFromXML"),
          e); //$NON-NLS-1$
    }
  }
示例#15
0
  public void saveRep(Repository rep, ObjectId id_transformation, ObjectId id_step)
      throws KettleException {
    try {
      rep.saveStepAttribute(id_transformation, id_step, "splitfield", splitField); // $NON-NLS-1$
      rep.saveStepAttribute(id_transformation, id_step, "delimiter", delimiter); // $NON-NLS-1$

      for (int i = 0; i < fieldName.length; i++) {
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_name", fieldName[i]); // $NON-NLS-1$
        rep.saveStepAttribute(id_transformation, id_step, i, "field_id", fieldID[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_idrem", fieldRemoveID[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation,
            id_step,
            i,
            "field_type",
            ValueMeta.getTypeDesc(fieldType[i])); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_format", fieldFormat[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_group", fieldGroup[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_decimal", fieldDecimal[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_length", fieldLength[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_precision", fieldPrecision[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_nullif", fieldNullIf[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_ifnull", fieldIfNull[i]); // $NON-NLS-1$
        rep.saveStepAttribute(
            id_transformation,
            id_step,
            i,
            "field_trimtype",
            ValueMeta.getTrimTypeCode(fieldTrimType[i])); // $NON-NLS-1$
      }
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(
                  PKG, "FieldSplitterMeta.Exception.UnalbeToSaveStepInfoToRepository")
              + id_step,
          e); //$NON-NLS-1$
    }
  }
 public boolean getBooleanValueOfVariable(String variableName, boolean defaultValue) {
   if (!Const.isEmpty(variableName)) {
     String value = environmentSubstitute(variableName);
     if (!Const.isEmpty(value)) {
       return ValueMeta.convertStringToBoolean(value);
     }
   }
   return defaultValue;
 }
  public Validation(Repository rep, ObjectId id_step, int i) throws KettleException {
    fieldName = rep.getStepAttributeString(id_step, i, "validator_field_name");
    name = rep.getStepAttributeString(id_step, i, "validator_field_validation_name");
    if (Const.isEmpty(name)) {
      name = fieldName; // remain backward compatible
    }

    maximumLength = rep.getStepAttributeString(id_step, i, "validator_field_max_length");
    minimumLength = rep.getStepAttributeString(id_step, i, "validator_field_min_length");

    nullAllowed = rep.getStepAttributeBoolean(id_step, i, "validator_field_null_allowed");
    onlyNullAllowed = rep.getStepAttributeBoolean(id_step, i, "validator_field_only_null_allowed");
    onlyNumericAllowed =
        rep.getStepAttributeBoolean(id_step, i, "validator_field_only_numeric_allowed");

    dataType =
        ValueMeta.getType(rep.getStepAttributeString(id_step, i, "validator_field_data_type"));
    dataTypeVerified =
        rep.getStepAttributeBoolean(id_step, i, "validator_field_data_type_verified");
    conversionMask = rep.getStepAttributeString(id_step, i, "validator_field_conversion_mask");
    decimalSymbol = rep.getStepAttributeString(id_step, i, "validator_field_decimal_symbol");
    groupingSymbol = rep.getStepAttributeString(id_step, i, "validator_field_grouping_symbol");

    minimumValue = rep.getStepAttributeString(id_step, i, "validator_field_min_value");
    maximumValue = rep.getStepAttributeString(id_step, i, "validator_field_max_value");

    startString = rep.getStepAttributeString(id_step, i, "validator_field_start_string");
    endString = rep.getStepAttributeString(id_step, i, "validator_field_end_string");
    startStringNotAllowed =
        rep.getStepAttributeString(id_step, i, "validator_field_start_string_not_allowed");
    endStringNotAllowed =
        rep.getStepAttributeString(id_step, i, "validator_field_end_string_not_allowed");

    regularExpression =
        rep.getStepAttributeString(id_step, i, "validator_field_regular_expression");
    regularExpressionNotAllowed =
        rep.getStepAttributeString(id_step, i, "validator_field_regular_expression_not_allowed");

    errorCode = rep.getStepAttributeString(id_step, i, "validator_field_error_code");
    errorDescription = rep.getStepAttributeString(id_step, i, "validator_field_error_description");

    sourcingValues = rep.getStepAttributeBoolean(id_step, i, "validator_field_is_sourcing_values");
    sourcingStepName = rep.getStepAttributeString(id_step, i, "validator_field_sourcing_step");
    sourcingField = rep.getStepAttributeString(id_step, i, "validator_field_sourcing_field");

    List<String> allowed = new ArrayList<String>();

    int nr = 1;
    String value = rep.getStepAttributeString(id_step, i, "validator_field_value_" + nr);
    while (value != null) {
      allowed.add(value);
      nr++;
      value = rep.getStepAttributeString(id_step, i, "validator_field_value_" + nr);
    }
    allowedValues = allowed.toArray(new String[allowed.size()]);
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(500);

    retval.append("    ").append(XMLHandler.addTagValue("filename", filename));
    retval.append("    ").append(XMLHandler.addTagValue("filename_field", filenameField));
    retval.append("    ").append(XMLHandler.addTagValue("rownum_field", rowNumField));
    retval.append("    ").append(XMLHandler.addTagValue("include_filename", includingFilename));
    retval.append("    ").append(XMLHandler.addTagValue("separator", delimiter));
    retval.append("    ").append(XMLHandler.addTagValue("enclosure", enclosure));
    retval.append("    ").append(XMLHandler.addTagValue("header", headerPresent));
    retval.append("    ").append(XMLHandler.addTagValue("buffer_size", bufferSize));
    retval.append("    ").append(XMLHandler.addTagValue("lazy_conversion", lazyConversionActive));
    retval.append("    ").append(XMLHandler.addTagValue("add_filename_result", isaddresult));
    retval.append("    ").append(XMLHandler.addTagValue("parallel", runningInParallel));
    retval.append("    ").append(XMLHandler.addTagValue("encoding", encoding));

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

      retval.append("      <field>").append(Const.CR);
      retval.append("        ").append(XMLHandler.addTagValue("name", field.getName()));
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("type", ValueMeta.getTypeDesc(field.getType())));
      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.getGroupSymbol()));
      retval.append("        ").append(XMLHandler.addTagValue("length", field.getLength()));
      retval.append("        ").append(XMLHandler.addTagValue("precision", field.getPrecision()));
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue("trim_type", ValueMeta.getTrimTypeCode(field.getTrimType())));
      retval.append("      </field>").append(Const.CR);
    }
    retval.append("    </fields>").append(Const.CR);

    return retval.toString();
  }
  public void saveRep(Repository rep, long id_transformation, long id_step) throws KettleException {
    try {
      rep.saveStepAttribute(id_transformation, id_step, "filename", filename);
      rep.saveStepAttribute(id_transformation, id_step, "filename_field", filenameField);
      rep.saveStepAttribute(id_transformation, id_step, "rownum_field", rowNumField);
      rep.saveStepAttribute(id_transformation, id_step, "include_filename", includingFilename);
      rep.saveStepAttribute(id_transformation, id_step, "separator", delimiter);
      rep.saveStepAttribute(id_transformation, id_step, "enclosure", enclosure);
      rep.saveStepAttribute(id_transformation, id_step, "buffer_size", bufferSize);
      rep.saveStepAttribute(id_transformation, id_step, "header", headerPresent);
      rep.saveStepAttribute(id_transformation, id_step, "lazy_conversion", lazyConversionActive);
      rep.saveStepAttribute(id_transformation, id_step, "add_filename_result", isaddresult);
      rep.saveStepAttribute(id_transformation, id_step, "parallel", runningInParallel);
      rep.saveStepAttribute(id_transformation, id_step, "encoding", encoding);

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

        rep.saveStepAttribute(id_transformation, id_step, i, "field_name", field.getName());
        rep.saveStepAttribute(
            id_transformation, id_step, i, "field_type", ValueMeta.getTypeDesc(field.getType()));
        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",
            ValueMeta.getTrimTypeCode(field.getTrimType()));
      }
    } catch (Exception e) {
      throw new KettleException(
          "Unable to save step information to the repository for id_step=" + id_step, e);
    }
  }
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      filename = XMLHandler.getTagValue(stepnode, "filename");
      filenameField = XMLHandler.getTagValue(stepnode, "filename_field");
      rowNumField = XMLHandler.getTagValue(stepnode, "rownum_field");
      includingFilename =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "include_filename"));
      delimiter = XMLHandler.getTagValue(stepnode, "separator");
      enclosure = XMLHandler.getTagValue(stepnode, "enclosure");
      bufferSize = XMLHandler.getTagValue(stepnode, "buffer_size");
      headerPresent = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "header"));
      lazyConversionActive =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "lazy_conversion"));
      isaddresult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "add_filename_result"));
      runningInParallel = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "parallel"));
      encoding = XMLHandler.getTagValue(stepnode, "encoding");

      Node fields = XMLHandler.getSubNode(stepnode, "fields");
      int nrfields = XMLHandler.countNodes(fields, "field");

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        inputFields[i] = new TextFileInputField();

        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);

        inputFields[i].setName(XMLHandler.getTagValue(fnode, "name"));
        inputFields[i].setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")));
        inputFields[i].setFormat(XMLHandler.getTagValue(fnode, "format"));
        inputFields[i].setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
        inputFields[i].setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
        inputFields[i].setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
        inputFields[i].setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
        inputFields[i].setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
        inputFields[i].setTrimType(
            ValueMeta.getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type")));
      }
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
  public String getXML() {
    StringBuilder xml = new StringBuilder();

    xml.append(XMLHandler.openTag(XML_TAG));

    xml.append(XMLHandler.addTagValue("name", fieldName));
    xml.append(XMLHandler.addTagValue("validation_name", name));
    xml.append(XMLHandler.addTagValue("max_length", maximumLength));
    xml.append(XMLHandler.addTagValue("min_length", minimumLength));

    xml.append(XMLHandler.addTagValue("null_allowed", nullAllowed));
    xml.append(XMLHandler.addTagValue("only_null_allowed", onlyNullAllowed));
    xml.append(XMLHandler.addTagValue("only_numeric_allowed", onlyNumericAllowed));

    xml.append(XMLHandler.addTagValue("data_type", ValueMeta.getTypeDesc(dataType)));
    xml.append(XMLHandler.addTagValue("data_type_verified", dataTypeVerified));
    xml.append(XMLHandler.addTagValue("conversion_mask", conversionMask));
    xml.append(XMLHandler.addTagValue("decimal_symbol", decimalSymbol));
    xml.append(XMLHandler.addTagValue("grouping_symbol", groupingSymbol));

    xml.append(XMLHandler.addTagValue("max_value", maximumValue));
    xml.append(XMLHandler.addTagValue("min_value", minimumValue));

    xml.append(XMLHandler.addTagValue("start_string", startString));
    xml.append(XMLHandler.addTagValue("end_string", endString));
    xml.append(XMLHandler.addTagValue("start_string_not_allowed", startStringNotAllowed));
    xml.append(XMLHandler.addTagValue("end_string_not_allowed", endStringNotAllowed));

    xml.append(XMLHandler.addTagValue("regular_expression", regularExpression));
    xml.append(
        XMLHandler.addTagValue("regular_expression_not_allowed", regularExpressionNotAllowed));

    xml.append(XMLHandler.addTagValue("error_code", errorCode));
    xml.append(XMLHandler.addTagValue("error_description", errorDescription));

    xml.append(XMLHandler.addTagValue("is_sourcing_values", sourcingValues));
    xml.append(
        XMLHandler.addTagValue(
            "sourcing_step", sourcingStep == null ? sourcingStepName : sourcingStep.getName()));
    xml.append(XMLHandler.addTagValue("sourcing_field", sourcingField));

    xml.append(XMLHandler.openTag(XML_TAG_ALLOWED));
    if (allowedValues != null) {

      for (String allowedValue : allowedValues) {
        xml.append(XMLHandler.addTagValue("value", allowedValue));
      }
    }
    xml.append(XMLHandler.closeTag(XML_TAG_ALLOWED));

    xml.append(XMLHandler.closeTag(XML_TAG));

    return xml.toString();
  }
  public void readRep(
      Repository rep, long id_step, List<DatabaseMeta> databases, Map<String, Counter> counters)
      throws KettleException {
    try {
      filename = rep.getStepAttributeString(id_step, "filename");
      filenameField = rep.getStepAttributeString(id_step, "filename_field");
      rowNumField = rep.getStepAttributeString(id_step, "rownum_field");
      includingFilename = rep.getStepAttributeBoolean(id_step, "include_filename");
      delimiter = rep.getStepAttributeString(id_step, "separator");
      enclosure = rep.getStepAttributeString(id_step, "enclosure");
      headerPresent = rep.getStepAttributeBoolean(id_step, "header");
      bufferSize = rep.getStepAttributeString(id_step, "buffer_size");
      lazyConversionActive = rep.getStepAttributeBoolean(id_step, "lazy_conversion");
      isaddresult = rep.getStepAttributeBoolean(id_step, "add_filename_result");
      runningInParallel = rep.getStepAttributeBoolean(id_step, "parallel");
      encoding = rep.getStepAttributeString(id_step, "encoding");

      int nrfields = rep.countNrStepAttributes(id_step, "field_name");

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        inputFields[i] = new TextFileInputField();

        inputFields[i].setName(rep.getStepAttributeString(id_step, i, "field_name"));
        inputFields[i].setType(
            ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type")));
        inputFields[i].setFormat(rep.getStepAttributeString(id_step, i, "field_format"));
        inputFields[i].setCurrencySymbol(rep.getStepAttributeString(id_step, i, "field_currency"));
        inputFields[i].setDecimalSymbol(rep.getStepAttributeString(id_step, i, "field_decimal"));
        inputFields[i].setGroupSymbol(rep.getStepAttributeString(id_step, i, "field_group"));
        inputFields[i].setLength((int) rep.getStepAttributeInteger(id_step, i, "field_length"));
        inputFields[i].setPrecision(
            (int) rep.getStepAttributeInteger(id_step, i, "field_precision"));
        inputFields[i].setTrimType(
            ValueMeta.getTrimTypeByCode(rep.getStepAttributeString(id_step, i, "field_trim_type")));
      }
    } catch (Exception e) {
      throw new KettleException("Unexpected error reading step information from the repository", e);
    }
  }
示例#23
0
  private void ok() {
    if (Const.isEmpty(wStepname.getText())) return;

    int i;

    int nrargs = wFields.nrNonEmpty();

    input.allocate(nrargs);

    logDebug(
        BaseMessages.getString(
            PKG,
            "DBProcDialog.Log.FoundArguments",
            String.valueOf(nrargs))); // $NON-NLS-1$ //$NON-NLS-2$
    for (i = 0; i < nrargs; i++) {
      TableItem item = wFields.getNonEmpty(i);
      input.getArgument()[i] = item.getText(1);
      input.getArgumentDirection()[i] = item.getText(2);
      input.getArgumentType()[i] = ValueMeta.getType(item.getText(3));
    }

    input.setDatabase(transMeta.findDatabase(wConnection.getText()));
    input.setProcedure(wProcName.getText());
    input.setResultName(wResult.getText());
    input.setResultType(ValueMeta.getType(wResultType.getText()));
    input.setAutoCommit(wAutoCommit.getSelection());

    stepname = wStepname.getText(); // return value

    if (input.getDatabase() == null) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      mb.setMessage(
          BaseMessages.getString(
              PKG, "DBProcDialog.InvalidConnection.DialogMessage")); // $NON-NLS-1$
      mb.setText(
          BaseMessages.getString(PKG, "DBProcDialog.InvalidConnection.DialogTitle")); // $NON-NLS-1$
      mb.open();
    }

    dispose();
  }
示例#24
0
 public YamlInputField(Node fnode) throws KettleValueException {
   setName(XMLHandler.getTagValue(fnode, "name"));
   setPath(XMLHandler.getTagValue(fnode, "path"));
   setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")));
   setFormat(XMLHandler.getTagValue(fnode, "format"));
   setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
   setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
   setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
   setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
   setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
   setTrimType(getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type")));
 }
  public void readRep(
      Repository rep, long id_step, List<DatabaseMeta> databases, Map<String, Counter> counters)
      throws KettleException {
    try {
      long id_connection = rep.getStepAttributeInteger(id_step, "id_connection"); // $NON-NLS-1$
      databaseMeta = DatabaseMeta.findDatabase(databases, id_connection);

      cached = rep.getStepAttributeBoolean(id_step, "cache"); // $NON-NLS-1$
      loadingAllDataInCache = rep.getStepAttributeBoolean(id_step, "cache_load_all"); // $NON-NLS-1$
      cacheSize = (int) rep.getStepAttributeInteger(id_step, "cache_size"); // $NON-NLS-1$
      schemaName = rep.getStepAttributeString(id_step, "lookup_schema"); // $NON-NLS-1$
      tablename = rep.getStepAttributeString(id_step, "lookup_table"); // $NON-NLS-1$
      orderByClause = rep.getStepAttributeString(id_step, "lookup_orderby"); // $NON-NLS-1$
      failingOnMultipleResults =
          rep.getStepAttributeBoolean(id_step, "fail_on_multiple"); // $NON-NLS-1$
      eatingRowOnLookupFailure =
          rep.getStepAttributeBoolean(id_step, "eat_row_on_failure"); // $NON-NLS-1$

      int nrkeys = rep.countNrStepAttributes(id_step, "lookup_key_name"); // $NON-NLS-1$
      int nrvalues = rep.countNrStepAttributes(id_step, "return_value_name"); // $NON-NLS-1$

      allocate(nrkeys, nrvalues);

      for (int i = 0; i < nrkeys; i++) {
        streamKeyField1[i] =
            rep.getStepAttributeString(id_step, i, "lookup_key_name"); // $NON-NLS-1$
        tableKeyField[i] =
            rep.getStepAttributeString(id_step, i, "lookup_key_field"); // $NON-NLS-1$
        keyCondition[i] =
            rep.getStepAttributeString(id_step, i, "lookup_key_condition"); // $NON-NLS-1$
        streamKeyField2[i] =
            rep.getStepAttributeString(id_step, i, "lookup_key_name2"); // $NON-NLS-1$
      }

      for (int i = 0; i < nrvalues; i++) {
        returnValueField[i] =
            rep.getStepAttributeString(id_step, i, "return_value_name"); // $NON-NLS-1$
        returnValueNewName[i] =
            rep.getStepAttributeString(id_step, i, "return_value_rename"); // $NON-NLS-1$
        returnValueDefault[i] =
            rep.getStepAttributeString(id_step, i, "return_value_default"); // $NON-NLS-1$
        returnValueDefaultType[i] =
            ValueMeta.getType(
                rep.getStepAttributeString(id_step, i, "return_value_type")); // $NON-NLS-1$
      }
    } catch (Exception e) {
      throw new KettleException(
          Messages.getString(
              "DatabaseLookupMeta.ERROR0002.UnexpectedErrorReadingFromTheRepository"),
          e); //$NON-NLS-1$
    }
  }
示例#26
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      splitField = XMLHandler.getTagValue(stepnode, "splitfield"); // $NON-NLS-1$
      delimiter = XMLHandler.getTagValue(stepnode, "delimiter"); // $NON-NLS-1$

      final Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      final int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        final Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$

        fieldName[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$
        fieldID[i] = XMLHandler.getTagValue(fnode, "id"); // $NON-NLS-1$
        final String sidrem = XMLHandler.getTagValue(fnode, "idrem"); // $NON-NLS-1$
        final String stype = XMLHandler.getTagValue(fnode, "type"); // $NON-NLS-1$
        fieldFormat[i] = XMLHandler.getTagValue(fnode, "format"); // $NON-NLS-1$
        fieldGroup[i] = XMLHandler.getTagValue(fnode, "group"); // $NON-NLS-1$
        fieldDecimal[i] = XMLHandler.getTagValue(fnode, "decimal"); // $NON-NLS-1$
        fieldCurrency[i] = XMLHandler.getTagValue(fnode, "currency"); // $NON-NLS-1$
        final String slen = XMLHandler.getTagValue(fnode, "length"); // $NON-NLS-1$
        final String sprc = XMLHandler.getTagValue(fnode, "precision"); // $NON-NLS-1$
        fieldNullIf[i] = XMLHandler.getTagValue(fnode, "nullif"); // $NON-NLS-1$
        fieldIfNull[i] = XMLHandler.getTagValue(fnode, "ifnull"); // $NON-NLS-1$
        final String trim = XMLHandler.getTagValue(fnode, "trimtype"); // $NON-NLS-1$

        fieldRemoveID[i] = "Y".equalsIgnoreCase(sidrem); // $NON-NLS-1$
        fieldType[i] = ValueMeta.getType(stype);
        fieldLength[i] = Const.toInt(slen, -1);
        fieldPrecision[i] = Const.toInt(sprc, -1);
        fieldTrimType[i] = ValueMeta.getTrimTypeByCode(trim);
      }
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "FieldSplitterMeta.Exception.UnableToLoadStepInfoFromXML"),
          e); //$NON-NLS-1$
    }
  }
  public Validation(Node calcnode) throws KettleXMLException {
    this();

    fieldName = XMLHandler.getTagValue(calcnode, "name");
    name = XMLHandler.getTagValue(calcnode, "validation_name");
    if (Const.isEmpty(name)) {
      name = fieldName; // remain backward compatible
    }

    maximumLength = XMLHandler.getTagValue(calcnode, "max_length");
    minimumLength = XMLHandler.getTagValue(calcnode, "min_length");

    nullAllowed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "null_allowed"));
    onlyNullAllowed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "only_null_allowed"));
    onlyNumericAllowed =
        "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "only_numeric_allowed"));

    dataType = ValueMeta.getType(XMLHandler.getTagValue(calcnode, "data_type"));
    dataTypeVerified = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "data_type_verified"));
    conversionMask = XMLHandler.getTagValue(calcnode, "conversion_mask");
    decimalSymbol = XMLHandler.getTagValue(calcnode, "decimal_symbol");
    groupingSymbol = XMLHandler.getTagValue(calcnode, "grouping_symbol");

    minimumValue = XMLHandler.getTagValue(calcnode, "min_value");
    maximumValue = XMLHandler.getTagValue(calcnode, "max_value");

    startString = XMLHandler.getTagValue(calcnode, "start_string");
    endString = XMLHandler.getTagValue(calcnode, "end_string");
    startStringNotAllowed = XMLHandler.getTagValue(calcnode, "start_string_not_allowed");
    endStringNotAllowed = XMLHandler.getTagValue(calcnode, "end_string_not_allowed");

    regularExpression = XMLHandler.getTagValue(calcnode, "regular_expression");
    regularExpressionNotAllowed =
        XMLHandler.getTagValue(calcnode, "regular_expression_not_allowed");

    errorCode = XMLHandler.getTagValue(calcnode, "error_code");
    errorDescription = XMLHandler.getTagValue(calcnode, "error_description");

    sourcingValues = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "is_sourcing_values"));
    sourcingStepName = XMLHandler.getTagValue(calcnode, "sourcing_step");
    sourcingField = XMLHandler.getTagValue(calcnode, "sourcing_field");

    Node allowedValuesNode = XMLHandler.getSubNode(calcnode, XML_TAG_ALLOWED);
    int nrValues = XMLHandler.countNodes(allowedValuesNode, "value");
    allowedValues = new String[nrValues];
    for (int i = 0; i < nrValues; i++) {
      Node allowedNode = XMLHandler.getSubNodeByNr(allowedValuesNode, "value", i);
      allowedValues[i] = XMLHandler.getNodeValue(allowedNode);
    }
  }
示例#28
0
  public void readRep(
      Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters)
      throws KettleException {
    try {
      splitField = rep.getStepAttributeString(id_step, "splitfield"); // $NON-NLS-1$
      delimiter = rep.getStepAttributeString(id_step, "delimiter"); // $NON-NLS-1$

      int nrfields = rep.countNrStepAttributes(id_step, "field_name"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        fieldName[i] = rep.getStepAttributeString(id_step, i, "field_name"); // $NON-NLS-1$
        fieldID[i] = rep.getStepAttributeString(id_step, i, "field_id"); // $NON-NLS-1$
        fieldRemoveID[i] = rep.getStepAttributeBoolean(id_step, i, "field_idrem"); // $NON-NLS-1$
        fieldType[i] =
            ValueMeta.getType(rep.getStepAttributeString(id_step, i, "field_type")); // $NON-NLS-1$
        fieldFormat[i] = rep.getStepAttributeString(id_step, i, "field_format"); // $NON-NLS-1$
        fieldGroup[i] = rep.getStepAttributeString(id_step, i, "field_group"); // $NON-NLS-1$
        fieldDecimal[i] = rep.getStepAttributeString(id_step, i, "field_decimal"); // $NON-NLS-1$
        fieldLength[i] =
            (int) rep.getStepAttributeInteger(id_step, i, "field_length"); // $NON-NLS-1$
        fieldPrecision[i] =
            (int) rep.getStepAttributeInteger(id_step, i, "field_precision"); // $NON-NLS-1$
        fieldNullIf[i] = rep.getStepAttributeString(id_step, i, "field_nullif"); // $NON-NLS-1$
        fieldIfNull[i] = rep.getStepAttributeString(id_step, i, "field_ifnull"); // $NON-NLS-1$
        fieldTrimType[i] =
            ValueMeta.getTrimTypeByCode(
                rep.getStepAttributeString(id_step, i, "field_trimtype")); // $NON-NLS-1$
      }
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(
              PKG, "FieldSplitterMeta.Exception.UnexpectedErrorInReadingStepInfo"),
          e); //$NON-NLS-1$
    }
  }
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    int i;

    for (i = 0; i < input.size(); i++) {
      TableItem item = wFields.table.getItem(i);
      ValueMetaInterface v = input.getValueMeta(i);
      int idx = 1;
      if (v.getName() != null) {
        item.setText(idx++, v.getName());
      }
      item.setText(idx++, v.getTypeDesc());
      item.setText(idx++, v.getLength() < 0 ? "-" : "" + v.getLength());
      item.setText(idx++, v.getPrecision() < 0 ? "-" : "" + v.getPrecision());
      item.setText(idx++, Const.NVL(v.getOrigin(), ""));
      item.setText(idx++, ValueMeta.getStorageTypeCode(v.getStorageType()));
      item.setText(idx++, Const.NVL(v.getConversionMask(), ""));
      item.setText(idx++, Const.NVL(v.getCurrencySymbol(), ""));
      item.setText(idx++, Const.NVL(v.getDecimalSymbol(), ""));
      item.setText(idx++, Const.NVL(v.getGroupingSymbol(), ""));
      item.setText(idx++, ValueMeta.getTrimTypeDesc(v.getTrimType()));
      item.setText(idx++, Const.NVL(v.getComments(), ""));
    }
    wFields.optWidth(true);
  }
示例#30
0
  private void getInfo(SapInputMeta meta) {
    meta.setDatabaseMeta(transMeta.findDatabase(wConnection.getText()));
    meta.setFunction(function);

    // Grab the parameters...
    //
    meta.getParameters().clear();
    int nrParameters = wInput.nrNonEmpty();
    for (int i = 0; i < nrParameters; i++) {
      TableItem item = wInput.getNonEmpty(i);
      int colnr = 1;
      String fieldName = item.getText(colnr++);
      SapType sapType = SapType.findTypeForDescription(item.getText(colnr++));
      String tableName = item.getText(colnr++);
      String parameterName = item.getText(colnr++);
      int targetType = ValueMeta.getType(item.getText(colnr++));
      meta.getParameters()
          .add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType));
    }

    // and the output fields.
    //
    meta.getOutputFields().clear();
    int nrFields = wOutput.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
      TableItem item = wOutput.getNonEmpty(i);
      int colnr = 1;
      String sapFieldName = item.getText(colnr++);
      SapType sapType = SapType.findTypeForDescription(item.getText(colnr++));
      String tableName = item.getText(colnr++);
      String newName = item.getText(colnr++);
      int targetType = ValueMeta.getType(item.getText(colnr++));
      meta.getOutputFields()
          .add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType));
    }
  }