@Override
  public void getFields(
      RowMetaInterface row,
      String name,
      RowMetaInterface[] info,
      StepMeta nextStep,
      VariableSpace space,
      Repository repository,
      IMetaStore metaStore)
      throws KettleStepException {

    for (SasInputField field : outputFields) {
      try {
        ValueMetaInterface valueMeta =
            ValueMetaFactory.createValueMeta(field.getRename(), field.getType());
        valueMeta.setLength(field.getLength(), field.getPrecision());
        valueMeta.setDecimalSymbol(field.getDecimalSymbol());
        valueMeta.setGroupingSymbol(field.getGroupingSymbol());
        valueMeta.setConversionMask(field.getConversionMask());
        valueMeta.setTrimType(field.getTrimType());
        valueMeta.setOrigin(name);

        row.addValueMeta(valueMeta);
      } catch (Exception e) {
        throw new KettleStepException(e);
      }
    }
  }
  public void getFields(
      RowMetaInterface row,
      String name,
      RowMetaInterface[] info,
      StepMeta nextStep,
      VariableSpace space,
      Repository repository,
      IMetaStore metaStore)
      throws KettleStepException {
    // No values are added to the row in this type of step
    // However, in case of Fixed length records,
    // the field precisions and lengths are altered!

    for (int i = 0; i < outputFields.length; i++) {
      TextFileField field = outputFields[i];
      ValueMetaInterface v = row.searchValueMeta(field.getName());
      if (v != null) {
        v.setLength(field.getLength());
        v.setPrecision(field.getPrecision());
        v.setConversionMask(field.getFormat());
        v.setDecimalSymbol(field.getDecimalSymbol());
        v.setGroupingSymbol(field.getGroupingSymbol());
        v.setCurrencySymbol(field.getCurrencySymbol());
        v.setOutputPaddingEnabled(isPadded());
        v.setTrimType(field.getTrimType());
        if (!Const.isEmpty(getEncoding())) {
          v.setStringEncoding(getEncoding());
        }

        // enable output padding by default to be compatible with v2.5.x
        //
        v.setOutputPaddingEnabled(true);
      }
    }
  }
  public static ValueMetaInterface cloneValueMeta(ValueMetaInterface source, int targetType)
      throws KettlePluginException {
    ValueMetaInterface target = null;

    // If we're Cloneable and not changing types, call clone()
    if (source instanceof Cloneable && source.getType() == targetType) {
      target = source.clone();
    } else {
      target =
          createValueMeta(source.getName(), targetType, source.getLength(), source.getPrecision());
    }
    target.setConversionMask(source.getConversionMask());
    target.setDecimalSymbol(source.getDecimalSymbol());
    target.setGroupingSymbol(source.getGroupingSymbol());
    target.setStorageType(source.getStorageType());
    if (source.getStorageMetadata() != null) {
      target.setStorageMetadata(
          cloneValueMeta(source.getStorageMetadata(), source.getStorageMetadata().getType()));
    }
    target.setStringEncoding(source.getStringEncoding());
    target.setTrimType(source.getTrimType());
    target.setDateFormatLenient(source.isDateFormatLenient());
    target.setDateFormatLocale(source.getDateFormatLocale());
    target.setDateFormatTimeZone(source.getDateFormatTimeZone());
    target.setLenientStringToNumber(source.isLenientStringToNumber());
    target.setLargeTextField(source.isLargeTextField());
    target.setComments(source.getComments());
    target.setCaseInsensitive(source.isCaseInsensitive());
    target.setIndex(source.getIndex());

    target.setOrigin(source.getOrigin());

    target.setOriginalAutoIncrement(source.isOriginalAutoIncrement());
    target.setOriginalColumnType(source.getOriginalColumnType());
    target.setOriginalColumnTypeName(source.getOriginalColumnTypeName());
    target.setOriginalNullable(source.isOriginalNullable());
    target.setOriginalPrecision(source.getOriginalPrecision());
    target.setOriginalScale(source.getOriginalScale());
    target.setOriginalSigned(source.isOriginalSigned());

    return target;
  }
  public void getFields(
      RowMetaInterface r,
      String name,
      RowMetaInterface[] info,
      StepMeta nextStep,
      VariableSpace space) {
    // Remove the field to split
    int idx = r.indexOfValue(splitField);
    if (idx < 0) // not found
    {
      throw new RuntimeException(
          BaseMessages.getString(
              PKG,
              "FieldSplitter.Log.CouldNotFindFieldToSplit",
              splitField)); //$NON-NLS-1$ //$NON-NLS-2$
    }

    // Add the new fields at the place of the index --> replace!
    for (int i = 0; i < fieldName.length; i++) {
      final ValueMetaInterface v = new ValueMeta(fieldName[i], fieldType[i]);
      v.setLength(fieldLength[i], fieldPrecision[i]);
      v.setOrigin(name);
      v.setConversionMask(fieldFormat[i]);
      v.setDecimalSymbol(fieldDecimal[i]);
      v.setGroupingSymbol(fieldGroup[i]);
      v.setCurrencySymbol(fieldCurrency[i]);
      v.setTrimType(fieldTrimType[i]);
      // TODO when implemented in UI
      // v.setDateFormatLenient(dateFormatLenient);
      // TODO when implemented in UI
      // v.setDateFormatLocale(dateFormatLocale);
      if (i == 0 && idx >= 0) {
        // the first valueMeta (splitField) will be replaced
        r.setValueMeta(idx, v);
      } else {
        // other valueMeta will be added
        if (idx >= r.size()) r.addValueMeta(v);
        r.addValueMeta(idx + i, v);
      }
    }
  }
  /**
   * Generates row meta structure from a fields array.
   *
   * @param fields the fields array
   * @param origin the data origin
   * @param rowMeta the row meta to generate
   */
  public static void fieldsToRowMeta(
      final CobFileInputField[] fields, final String origin, final RowMetaInterface rowMeta) {

    rowMeta.clear(); // Start with a clean slate, eats the input

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

      ValueMetaInterface valueMeta = new ValueMeta(field.getName(), field.getType());
      valueMeta.setConversionMask(field.getFormat());
      valueMeta.setLength(field.getLength());
      valueMeta.setPrecision(field.getPrecision());
      valueMeta.setConversionMask(field.getFormat());
      valueMeta.setDecimalSymbol(field.getDecimalSymbol());
      valueMeta.setGroupingSymbol(field.getGroupSymbol());
      valueMeta.setCurrencySymbol(field.getCurrencySymbol());
      valueMeta.setTrimType(field.getTrimType());
      valueMeta.setOrigin(origin);

      rowMeta.addValueMeta(valueMeta);
    }
  }
  public static final RowMetaAndData buildRow(
      RowGeneratorMeta meta, List<CheckResultInterface> remarks, String origin) {
    RowMetaInterface rowMeta = new RowMeta();
    Object[] rowData = RowDataUtil.allocateRowData(meta.getFieldName().length);

    for (int i = 0; i < meta.getFieldName().length; i++) {
      int valtype = ValueMeta.getType(meta.getFieldType()[i]);
      if (meta.getFieldName()[i] != null) {
        ValueMetaInterface valueMeta =
            new ValueMeta(meta.getFieldName()[i], valtype); // build a value!
        valueMeta.setLength(meta.getFieldLength()[i]);
        valueMeta.setPrecision(meta.getFieldPrecision()[i]);
        valueMeta.setConversionMask(meta.getFieldFormat()[i]);
        valueMeta.setGroupingSymbol(meta.getGroup()[i]);
        valueMeta.setDecimalSymbol(meta.getDecimal()[i]);
        valueMeta.setOrigin(origin);

        ValueMetaInterface stringMeta = valueMeta.clone();
        stringMeta.setType(ValueMetaInterface.TYPE_STRING);

        String stringValue = meta.getValue()[i];

        // If the value is empty: consider it to be NULL.
        if (Const.isEmpty(stringValue)) {
          rowData[i] = null;

          if (valueMeta.getType() == ValueMetaInterface.TYPE_NONE) {
            String message =
                BaseMessages.getString(
                    PKG,
                    "RowGenerator.CheckResult.SpecifyTypeError",
                    valueMeta.getName(),
                    stringValue);
            remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null));
          }
        } else {
          // Convert the data from String to the specified type ...
          //
          try {
            rowData[i] = valueMeta.convertData(stringMeta, stringValue);
          } catch (KettleValueException e) {
            switch (valueMeta.getType()) {
              case ValueMetaInterface.TYPE_NUMBER:
                {
                  String message =
                      BaseMessages.getString(
                          PKG,
                          "RowGenerator.BuildRow.Error.Parsing.Number",
                          valueMeta.getName(),
                          stringValue,
                          e.toString());
                  remarks.add(
                      new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null));
                }
                break;
              case ValueMetaInterface.TYPE_DATE:
                {
                  String message =
                      BaseMessages.getString(
                          PKG,
                          "RowGenerator.BuildRow.Error.Parsing.Date",
                          valueMeta.getName(),
                          stringValue,
                          e.toString());
                  remarks.add(
                      new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null));
                }
                break;
              case ValueMetaInterface.TYPE_INTEGER:
                {
                  String message =
                      BaseMessages.getString(
                          PKG,
                          "RowGenerator.BuildRow.Error.Parsing.Integer",
                          valueMeta.getName(),
                          stringValue,
                          e.toString());
                  remarks.add(
                      new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null));
                }
                break;
              case ValueMetaInterface.TYPE_BIGNUMBER:
                {
                  String message =
                      BaseMessages.getString(
                          PKG,
                          "RowGenerator.BuildRow.Error.Parsing.BigNumber",
                          valueMeta.getName(),
                          stringValue,
                          e.toString());
                  remarks.add(
                      new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null));
                }
                break;
              default:
                // Boolean and binary don't throw errors normally, so it's probably an unspecified
                // error problem...
                {
                  String message =
                      BaseMessages.getString(
                          PKG,
                          "RowGenerator.CheckResult.SpecifyTypeError",
                          valueMeta.getName(),
                          stringValue);
                  remarks.add(
                      new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, message, null));
                }
                break;
            }
          }
        }
        // Now add value to the row!
        // This is in fact a copy from the fields row, but now with data.
        rowMeta.addValueMeta(valueMeta);
      }
    }

    return new RowMetaAndData(rowMeta, rowData);
  }
  public void getFields(
      RowMetaInterface rowMeta,
      String origin,
      RowMetaInterface[] info,
      StepMeta nextStep,
      VariableSpace space)
      throws KettleStepException {
    rowMeta.clear(); // Start with a clean slate, eats the input

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

      ValueMetaInterface valueMeta = new ValueMeta(field.getName(), field.getType());
      valueMeta.setConversionMask(field.getFormat());
      valueMeta.setLength(field.getLength());
      valueMeta.setPrecision(field.getPrecision());
      valueMeta.setConversionMask(field.getFormat());
      valueMeta.setDecimalSymbol(field.getDecimalSymbol());
      valueMeta.setGroupingSymbol(field.getGroupSymbol());
      valueMeta.setCurrencySymbol(field.getCurrencySymbol());
      valueMeta.setTrimType(field.getTrimType());
      if (lazyConversionActive)
        valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
      valueMeta.setStringEncoding(space.environmentSubstitute(encoding));

      // In case we want to convert Strings...
      // Using a copy of the valueMeta object means that the inner and outer representation format
      // is the same.
      // Preview will show the data the same way as we read it.
      // This layout is then taken further down the road by the metadata through the transformation.
      //
      ValueMetaInterface storageMetadata = valueMeta.clone();
      storageMetadata.setType(ValueMetaInterface.TYPE_STRING);
      storageMetadata.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
      storageMetadata.setLength(
          -1, -1); // we don't really know the lengths of the strings read in advance.
      valueMeta.setStorageMetadata(storageMetadata);

      valueMeta.setOrigin(origin);

      rowMeta.addValueMeta(valueMeta);
    }

    if (!Const.isEmpty(filenameField) && includingFilename) {
      ValueMetaInterface filenameMeta =
          new ValueMeta(filenameField, ValueMetaInterface.TYPE_STRING);
      filenameMeta.setOrigin(origin);
      if (lazyConversionActive) {
        filenameMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
        filenameMeta.setStorageMetadata(
            new ValueMeta(filenameField, ValueMetaInterface.TYPE_STRING));
      }
      rowMeta.addValueMeta(filenameMeta);
    }

    if (!Const.isEmpty(rowNumField)) {
      ValueMetaInterface rowNumMeta = new ValueMeta(rowNumField, ValueMetaInterface.TYPE_INTEGER);
      rowNumMeta.setLength(10);
      rowNumMeta.setOrigin(origin);
      rowMeta.addValueMeta(rowNumMeta);
    }
  }
  public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {

    meta = (GaInputStepMeta) smi;
    data = (GaInputStepData) sdi;

    if (first) {

      first = false;

      data.outputRowMeta = new RowMeta();
      meta.getFields(data.outputRowMeta, getStepname(), null, null, this, repository, metaStore);

      // stores the indices where to look for the key fields in the input rows
      data.conversionMeta = new ValueMetaInterface[meta.getFieldsCount()];

      for (int i = 0; i < meta.getFieldsCount(); i++) {

        // get output and from-string conversion format for each field
        ValueMetaInterface returnMeta = data.outputRowMeta.getValueMeta(i);

        ValueMetaInterface conversionMeta;

        conversionMeta =
            ValueMetaFactory.cloneValueMeta(returnMeta, ValueMetaInterface.TYPE_STRING);
        conversionMeta.setConversionMask(meta.getConversionMask()[i]);
        conversionMeta.setDecimalSymbol("."); // google analytics is en-US
        conversionMeta.setGroupingSymbol(null); // google analytics uses no grouping symbol

        data.conversionMeta[i] = conversionMeta;
      }
    }

    // generate output row, make it correct size
    Object[] outputRow = RowDataUtil.allocateRowData(data.outputRowMeta.size());

    List<String> entry = getNextDataEntry();

    if (entry != null
        && (meta.getRowLimit() <= 0
            || getLinesWritten() < meta.getRowLimit())) { // another record to
      // fill the output fields with look up data
      for (int i = 0, j = 0; i < meta.getFieldsCount(); i++) {
        String fieldName = environmentSubstitute(meta.getFeedField()[i]);
        Object dataObject;
        String type = environmentSubstitute(meta.getFeedFieldType()[i]);

        // We handle fields differently depending on whether its a Dimension/Metric, Data Source
        // Property, or
        // Data Source Field. Also the API doesn't exactly match the concepts anymore (see
        // individual comments below),
        // so there is quite a bit of special processing.
        if (GaInputStepMeta.FIELD_TYPE_DATA_SOURCE_PROPERTY.equals(type)) {
          // Account name has to be handled differently, it's in the Accounts API not Profiles API
          if (GaInputStepMeta.PROPERTY_DATA_SOURCE_ACCOUNT_NAME.equals(fieldName)) {
            // We expect a single account name, and already fetched it during init
            dataObject = accountName;
          } else {
            dataObject = data.feed.getProfileInfo().get(removeClassifier(fieldName));
          }
        } else if (GaInputStepMeta.FIELD_TYPE_DATA_SOURCE_FIELD.equals(type)) {
          // Get tableId or tableName
          if (GaInputStepMeta.FIELD_DATA_SOURCE_TABLE_ID.equals(fieldName)) {
            dataObject = data.feed.getProfileInfo().get(removeClassifier(fieldName));
          } else {
            // We only have two Data Source Fields and they're hard-coded, so we handle tableName in
            // this else-clause
            // since tableId was done in the if-clause. We have to handle the two differently
            // because tableName is
            // actually the profile name in this version (v3) of the Google Analytics API.
            dataObject = data.feed.getProfileInfo().getProfileName();
          }
        } else if (GaInputStepMeta.DEPRECATED_FIELD_TYPE_CONFIDENCE_INTERVAL.equals(type)) {
          dataObject = null;
          if (log.isRowLevel()) {
            logRowlevel(
                BaseMessages.getString(
                    PKG,
                    "GoogleAnalytics.Warn.FieldTypeNotSupported",
                    GaInputStepMeta.DEPRECATED_FIELD_TYPE_CONFIDENCE_INTERVAL));
          }
        } else {
          // Assume it's a Dimension or Metric, we've covered the rest of the cases above.
          dataObject = entry.get(j++);
        }
        outputRow[i] =
            data.outputRowMeta.getValueMeta(i).convertData(data.conversionMeta[i], dataObject);
      }

      // copy row to possible alternate rowset(s)
      putRow(data.outputRowMeta, outputRow);

      // Some basic logging
      if (checkFeedback(getLinesWritten())) {
        if (log.isBasic()) {
          logBasic("Linenr " + getLinesWritten());
        }
      }
      return true;

    } else {
      setOutputDone();
      return false;
    }
  }
  private ValueMetaInterface getValueMeta(CalculatorMetaFunction fn, String origin) {
    ValueMetaInterface v = new ValueMeta(fn.getFieldName(), fn.getValueType());
    v.setLength(fn.getValueLength());
    v.setPrecision(fn.getValuePrecision());
    v.setOrigin(origin);
    v.setComments(fn.getCalcTypeDesc());
    v.setConversionMask(fn.getConversionMask());
    v.setDecimalSymbol(fn.getDecimalSymbol());
    v.setGroupingSymbol(fn.getGroupingSymbol());
    v.setCurrencySymbol(fn.getCurrencySymbol());

    // What if the user didn't specify a data type?
    // In that case we look for the default data type
    //
    if (fn.getValueType() == ValueMetaInterface.TYPE_NONE) {
      int defaultResultType = ValueMetaInterface.TYPE_NONE;

      switch (fn.getCalcType()) {
        case CalculatorMetaFunction.CALC_NONE:
          break;
        case CalculatorMetaFunction.CALC_ADD: // A + B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SUBTRACT: // A - B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_MULTIPLY: // A * B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_DIVIDE: // A / B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SQUARE: // A * A
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SQUARE_ROOT: // SQRT( A )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_PERCENT_1: // 100 * A / B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_PERCENT_2: // A - ( A * B / 100 )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_PERCENT_3: // A + ( A * B / 100 )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_COMBINATION_1: // A + B * C
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_COMBINATION_2: // SQRT( A*A + B*B )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_ROUND_1: // ROUND( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ROUND_2: //  ROUND( A , B )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_CONSTANT: // Set field to constant value...
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_NVL: // Replace null values with another value
          break;
        case CalculatorMetaFunction.CALC_ADD_DAYS: // Add B days to date field A
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction.CALC_YEAR_OF_DATE: // What is the year (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_MONTH_OF_DATE: // What is the month (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_DAY_OF_YEAR: // What is the day of year (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_DAY_OF_MONTH: // What is the day of month (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_DAY_OF_WEEK: // What is the day of week (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_WEEK_OF_YEAR: // What is the week of year (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_WEEK_OF_YEAR_ISO8601: // What is the week of year (Integer) of a date ISO8601
          // style?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_YEAR_OF_DATE_ISO8601: // What is the year (Integer) of a date ISO8601 style?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_BYTE_TO_HEX_ENCODE: // Byte to Hex encode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_HEX_TO_BYTE_DECODE: // Hex to Byte decode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_CHAR_TO_HEX_ENCODE: // Char to Hex encode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_HEX_TO_CHAR_DECODE: // Hex to Char decode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_CRC32: // CRC32 of a file A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ADLER32: // ADLER32 of a file A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_MD5: // MD5 of a file A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_SHA1: // SHA1 of a file Al
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction
            .CALC_LEVENSHTEIN_DISTANCE: // LEVENSHTEIN_DISTANCE of string A and string B
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_METAPHONE: // METAPHONE of string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_DOUBLE_METAPHONE: // Double METAPHONE of string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_ABS: // ABS( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_TIME_FROM_DATE: // Remove time from field A
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction.CALC_DATE_DIFF: // DateA - DateB
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ADD3: // A + B +C
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_INITCAP: // InitCap(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_UPPER_CASE: // UpperCase(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_LOWER_CASE: // LowerCase(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_MASK_XML: // MaskXML(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_USE_CDATA: // CDATA(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_CR: // REMOVE CR FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_LF: // REMOVE LF FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_CRLF: // REMOVE CRLF FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_TAB: // REMOVE TAB FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_GET_ONLY_DIGITS: // GET ONLY DIGITS FROM string A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_DIGITS: // REMOVE DIGITS FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_STRING_LEN: // LENGTH OF string A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_LOAD_FILE_CONTENT_BINARY: // LOAD FILE CONTENT IN BLOB
          defaultResultType = ValueMetaInterface.TYPE_BINARY;
          break;
        case CalculatorMetaFunction.CALC_ADD_TIME_TO_DATE: // ADD TIME TO A DATE
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction.CALC_GEOM_UNION: // Calculate geometry union
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_INTERSECTION: // Calculate geometry intersection
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_DIFFERENCE: // Calculate geometry difference
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction
            .CALC_GEOM_SYMETRIC_DIFFERENCE: // Calculate geometry symetric difference
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_AREA: // Calculate area
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_GEOM_LENGTH: // Calculate length
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_GEOM_CENTROID: // Calculate centroid
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_POINT_ON_SURFACE: // Calculate random point on surface
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_REVERSE: // Reverse geometry
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_BOUNDARY: // Calculate geometry boundary
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_ENVELOPE: // Calculate geometry envelope
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_CONVEX_HULL: // Calculate geometry convex hull
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_BUFFER: // Calculate geometry buffer
          defaultResultType = ValueMetaInterface.TYPE_GEOMETRY;
          break;
        case CalculatorMetaFunction.CALC_GEOM_DISTANCE: // Calculate distance between geometries
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        default:
          break;
      }

      v.setType(defaultResultType);
    }

    return v;
  }
Exemple #10
0
  private ValueMetaInterface getValueMeta(CalculatorMetaFunction fn, String origin) {
    ValueMetaInterface v = new ValueMeta(fn.getFieldName(), fn.getValueType());

    // What if the user didn't specify a data type?
    // In that case we look for the default data type
    //
    if (fn.getValueType() == ValueMetaInterface.TYPE_NONE) {
      int defaultResultType = ValueMetaInterface.TYPE_NONE;

      switch (fn.getCalcType()) {
        case CalculatorMetaFunction.CALC_NONE:
          break;
        case CalculatorMetaFunction.CALC_ADD: // A + B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SUBTRACT: // A - B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_MULTIPLY: // A * B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_DIVIDE: // A / B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SQUARE: // A * A
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SQUARE_ROOT: // SQRT( A )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_PERCENT_1: // 100 * A / B
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_PERCENT_2: // A - ( A * B / 100 )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_PERCENT_3: // A + ( A * B / 100 )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_COMBINATION_1: // A + B * C
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_COMBINATION_2: // SQRT( A*A + B*B )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_ROUND_1: // ROUND( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ROUND_2: //  ROUND( A , B )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_ROUND_STD_1: // STDROUND( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ROUND_STD_2: //  STDROUND( A , B )
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_CONSTANT: // Set field to constant value...
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_NVL: // Replace null values with another value
          break;
        case CalculatorMetaFunction.CALC_ADD_DAYS: // Add B days to date field A
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction.CALC_YEAR_OF_DATE: // What is the year (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_MONTH_OF_DATE: // What is the month (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_DAY_OF_YEAR: // What is the day of year (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_DAY_OF_MONTH: // What is the day of month (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_DAY_OF_WEEK: // What is the day of week (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_WEEK_OF_YEAR: // What is the week of year (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_WEEK_OF_YEAR_ISO8601: // What is the week of year (Integer) of a date ISO8601
          // style?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction
            .CALC_YEAR_OF_DATE_ISO8601: // What is the year (Integer) of a date ISO8601 style?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_BYTE_TO_HEX_ENCODE: // Byte to Hex encode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_HEX_TO_BYTE_DECODE: // Hex to Byte decode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_CHAR_TO_HEX_ENCODE: // Char to Hex encode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_HEX_TO_CHAR_DECODE: // Hex to Char decode string field A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_CRC32: // CRC32 of a file A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ADLER32: // ADLER32 of a file A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_MD5: // MD5 of a file A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_SHA1: // SHA1 of a file Al
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction
            .CALC_LEVENSHTEIN_DISTANCE: // LEVENSHTEIN_DISTANCE of string A and string B
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_METAPHONE: // METAPHONE of string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_DOUBLE_METAPHONE: // Double METAPHONE of string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_ABS: // ABS( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_TIME_FROM_DATE: // Remove time from field A
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction.CALC_DATE_DIFF: // DateA - DateB
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ADD3: // A + B +C
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_INITCAP: // InitCap(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_UPPER_CASE: // UpperCase(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_LOWER_CASE: // LowerCase(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_MASK_XML: // MaskXML(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_USE_CDATA: // CDATA(A)
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_CR: // REMOVE CR FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_LF: // REMOVE LF FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_CRLF: // REMOVE CRLF FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_TAB: // REMOVE TAB FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_GET_ONLY_DIGITS: // GET ONLY DIGITS FROM string A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_REMOVE_DIGITS: // REMOVE DIGITS FROM string A
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_STRING_LEN: // LENGTH OF string A
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_LOAD_FILE_CONTENT_BINARY: // LOAD FILE CONTENT IN BLOB
          defaultResultType = ValueMetaInterface.TYPE_BINARY;
          break;
        case CalculatorMetaFunction.CALC_ADD_TIME_TO_DATE: // ADD TIME TO A DATE
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction
            .CALC_QUARTER_OF_DATE: // What is the quarter (Integer) of a date?
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_SUBSTITUTE_VARIABLE: // variable substitution in string
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_ESCAPE_HTML: // escape HTML
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_ESCAPE_SQL: // escape SQL
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_UNESCAPE_HTML: // unEscape HTML
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_UNESCAPE_XML: // unEscape XML
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_DATE_WORKING_DIFF: // Date A - Date B
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_ADD_MONTHS: // Date A - B Months
          defaultResultType = ValueMetaInterface.TYPE_DATE;
          break;
        case CalculatorMetaFunction.CALC_CHECK_XML_FILE_WELL_FORMED: // XML file A well formed
          defaultResultType = ValueMetaInterface.TYPE_BOOLEAN;
          break;
        case CalculatorMetaFunction.CALC_CHECK_XML_WELL_FORMED: // XML string A well formed
          defaultResultType = ValueMetaInterface.TYPE_BOOLEAN;
          break;
        case CalculatorMetaFunction.CALC_GET_FILE_ENCODING: // get file encoding
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_DAMERAU_LEVENSHTEIN:
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_NEEDLEMAN_WUNSH:
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_JARO:
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_JARO_WINKLER:
          defaultResultType = ValueMetaInterface.TYPE_NUMBER;
          break;
        case CalculatorMetaFunction.CALC_SOUNDEX:
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_REFINED_SOUNDEX:
          defaultResultType = ValueMetaInterface.TYPE_STRING;
          break;
        case CalculatorMetaFunction.CALC_CEIL: // CEIL( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_FLOOR: // FLOOR( A )
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_HOUR_OF_DAY:
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_MINUTE_OF_HOUR:
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        case CalculatorMetaFunction.CALC_SECOND_OF_MINUTE:
          defaultResultType = ValueMetaInterface.TYPE_INTEGER;
          break;
        default:
          break;
      }

      v = new ValueMeta(fn.getFieldName(), defaultResultType);
    }

    v.setLength(fn.getValueLength());
    v.setPrecision(fn.getValuePrecision());
    v.setOrigin(origin);
    v.setComments(fn.getCalcTypeDesc());
    v.setConversionMask(fn.getConversionMask());
    v.setDecimalSymbol(fn.getDecimalSymbol());
    v.setGroupingSymbol(fn.getGroupingSymbol());
    v.setCurrencySymbol(fn.getCurrencySymbol());

    return v;
  }
Exemple #11
0
  private void writeRowToFile(RowMetaInterface rowMeta, Object[] r) throws KettleException {
    try {
      if (first) {
        data.formatRowMeta = rowMeta.clone();

        first = false;

        data.fieldnrs = new int[meta.getOutputFields().length];
        for (int i = 0; i < meta.getOutputFields().length; i++) {
          data.fieldnrs[i] =
              data.formatRowMeta.indexOfValue(meta.getOutputFields()[i].getFieldName());
          if (data.fieldnrs[i] < 0) {
            throw new KettleException(
                "Field ["
                    + meta.getOutputFields()[i].getFieldName()
                    + "] couldn't be found in the input stream!"); //$NON-NLS-1$ //$NON-NLS-2$
          }

          // Apply the formatting settings to the valueMeta object...
          //
          ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta(data.fieldnrs[i]);
          XMLField field = meta.getOutputFields()[i];
          valueMeta.setConversionMask(field.getFormat());
          valueMeta.setLength(field.getLength(), field.getPrecision());
          valueMeta.setDecimalSymbol(field.getDecimalSymbol());
          valueMeta.setGroupingSymbol(field.getGroupingSymbol());
          valueMeta.setCurrencySymbol(field.getCurrencySymbol());
        }
      }

      if (meta.getOutputFields() == null || meta.getOutputFields().length == 0) {
        /*
         * Write all values in stream to text file.
         */

        // OK, write a new row to the XML file:
        data.writer.write(
            (" <" + meta.getRepeatElement() + ">").toCharArray()); // $NON-NLS-1$ //$NON-NLS-2$

        for (int i = 0; i < data.formatRowMeta.size(); i++) {
          // Put a space between the XML elements of the row
          //
          if (i > 0) data.writer.write(' ');

          ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta(i);
          Object valueData = r[i];

          writeField(valueMeta, valueData, valueMeta.getName());
        }
      } else {
        /*
         * Only write the fields specified!
         */

        // Write a new row to the XML file:
        data.writer.write(
            (" <" + meta.getRepeatElement() + ">").toCharArray()); // $NON-NLS-1$ //$NON-NLS-2$

        for (int i = 0; i < meta.getOutputFields().length; i++) {
          XMLField outputField = meta.getOutputFields()[i];

          if (i > 0) data.writer.write(' '); // a space between
          // elements

          ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta(data.fieldnrs[i]);
          Object valueData = r[data.fieldnrs[i]];

          String elementName = outputField.getElementName();
          if (Const.isEmpty(elementName)) {
            elementName = outputField.getFieldName();
          }

          if (!(valueMeta.isNull(valueData) && meta.isOmitNullValues())) {
            writeField(valueMeta, valueData, elementName);
          }
        }
      }

      data.writer.write(
          (" </" + meta.getRepeatElement() + ">").toCharArray()); // $NON-NLS-1$ //$NON-NLS-2$
      data.writer.write(Const.CR.toCharArray());
    } catch (Exception e) {
      throw new KettleException(
          "Error writing XML row :"
              + e.toString()
              + Const.CR
              + "Row: "
              + getInputRowMeta().getString(r),
          e); //$NON-NLS-1$ //$NON-NLS-2$
    }

    incrementLinesOutput();
  }
  public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
    meta = (IngresVectorwiseLoaderMeta) smi;
    data = (IngresVectorwiseLoaderData) sdi;

    try {
      Object[] r = getRow(); // Get row from input rowset & set row busy!
      if (r == null) // no more input to be expected...
      {
        setOutputDone();
        // only close output after the first row was processed
        // to prevent error (NPE) on empty rows set
        if (!first) {
          closeOutput();
        }

        return false;
      }

      if (first) {
        first = false;

        // Cache field indexes.
        //
        data.keynrs = new int[meta.getFieldStream().length];
        for (int i = 0; i < data.keynrs.length; i++) {
          data.keynrs[i] = getInputRowMeta().indexOfValue(meta.getFieldStream()[i]);
        }
        data.bulkRowMeta = getInputRowMeta().clone();
        if (meta.isUseStandardConversion()) {
          for (int i = 0; i < data.bulkRowMeta.size(); i++) {
            ValueMetaInterface valueMeta = data.bulkRowMeta.getValueMeta(i);
            if (valueMeta.isStorageNormal()) {
              if (valueMeta.isDate()) {
                valueMeta.setConversionMask("yyyy-MM-dd HH:mm:ss");
              } else if (valueMeta.isNumeric()) {
                valueMeta.setDecimalSymbol(".");
                valueMeta.setGroupingSymbol("");
              }
            }
          }
        }

        // execute the client statement...
        //
        execute(meta);

        // Allocate a buffer
        //
        data.fileChannel = data.fifoOpener.getFileChannel();
        data.byteBuffer = ByteBuffer.allocate(data.bufferSize);
      }

      // check if SQL process is still running before processing row
      if (!checkSqlProcessRunning(data.sqlProcess)) {
        throw new Exception("Ingres SQL process has stopped");
      }

      writeRowToBulk(data.bulkRowMeta, r);
      putRow(getInputRowMeta(), r);
      incrementLinesOutput();

      if (checkFeedback(getLinesOutput()))
        logBasic(
            BaseMessages.getString(PKG, "IngresVectorwiseLoader.Log.LineNumber")
                + getLinesOutput()); //$NON-NLS-1$

      return true;

    } catch (Exception e) {
      logError(
          BaseMessages.getString(PKG, "IngresVectorwiseLoader.Log.ErrorInStep"), e); // $NON-NLS-1$
      setErrors(1);
      stopAll();
      setOutputDone(); // signal end to receiver(s)
      return false;
    }
  }
  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);
    }
  }