Search in sources :

Example 76 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class CheckSumMeta method getFields.

@Override
public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // Output field (String)
    if (!Utils.isEmpty(resultfieldName)) {
        ValueMetaInterface v = null;
        if (checksumtype.equals(TYPE_CRC32) || checksumtype.equals(TYPE_ADLER32)) {
            v = new ValueMetaInteger(space.environmentSubstitute(resultfieldName));
        } else {
            switch(resultType) {
                case result_TYPE_BINARY:
                    v = new ValueMetaBinary(space.environmentSubstitute(resultfieldName));
                    break;
                default:
                    v = new ValueMetaString(space.environmentSubstitute(resultfieldName));
                    break;
            }
        }
        v.setOrigin(name);
        inputRowMeta.addValueMeta(v);
    }
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 77 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class ConcatFieldsMeta method getFields.

@Override
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // remove selected fields from the stream when true
    if (removeSelectedFields) {
        if (getOutputFields().length > 0) {
            for (int i = 0; i < getOutputFields().length; i++) {
                TextFileField field = getOutputFields()[i];
                try {
                    row.removeValueMeta(field.getName());
                } catch (KettleValueException e) {
                // just ignore exceptions since missing fields are handled in the ConcatFields class
                }
            }
        } else {
            // no output fields selected, take them all, remove them all
            row.clear();
        }
    }
    // Check Target Field Name
    if (Utils.isEmpty(targetFieldName)) {
        throw new KettleStepException(BaseMessages.getString(PKG, "ConcatFieldsMeta.CheckResult.TargetFieldNameMissing"));
    }
    // add targetFieldName
    ValueMetaInterface vValue = new ValueMetaString(targetFieldName);
    vValue.setLength(targetFieldLength, 0);
    vValue.setOrigin(name);
    if (!Utils.isEmpty(getEncoding())) {
        vValue.setStringEncoding(getEncoding());
    }
    row.addValueMeta(vValue);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleStepException(org.pentaho.di.core.exception.KettleStepException) TextFileField(org.pentaho.di.trans.steps.textfileoutput.TextFileField) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 78 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class CreditCardValidatorMeta method getFields.

public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    String realresultfieldname = space.environmentSubstitute(resultfieldname);
    if (!Utils.isEmpty(realresultfieldname)) {
        ValueMetaInterface v = new ValueMetaBoolean(realresultfieldname);
        v.setOrigin(name);
        inputRowMeta.addValueMeta(v);
    }
    String realcardtype = space.environmentSubstitute(cardtype);
    if (!Utils.isEmpty(realcardtype)) {
        ValueMetaInterface v = new ValueMetaString(realcardtype);
        v.setOrigin(name);
        inputRowMeta.addValueMeta(v);
    }
    String realnotvalidmsg = space.environmentSubstitute(notvalidmsg);
    if (!Utils.isEmpty(notvalidmsg)) {
        ValueMetaInterface v = new ValueMetaString(realnotvalidmsg);
        v.setOrigin(name);
        inputRowMeta.addValueMeta(v);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 79 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class CsvInputMeta method getFields.

@Override
public void getFields(RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    try {
        // Start with a clean slate, eats the input
        rowMeta.clear();
        for (int i = 0; i < inputFields.length; i++) {
            TextFileInputField field = inputFields[i];
            ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta(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 = ValueMetaFactory.cloneValueMeta(valueMeta, ValueMetaInterface.TYPE_STRING);
            storageMetadata.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
            // we don't really know the lengths of the strings read in advance.
            storageMetadata.setLength(-1, -1);
            valueMeta.setStorageMetadata(storageMetadata);
            valueMeta.setOrigin(origin);
            rowMeta.addValueMeta(valueMeta);
        }
        if (!Utils.isEmpty(filenameField) && includingFilename) {
            ValueMetaInterface filenameMeta = new ValueMetaString(filenameField);
            filenameMeta.setOrigin(origin);
            if (lazyConversionActive) {
                filenameMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
                filenameMeta.setStorageMetadata(new ValueMetaString(filenameField));
            }
            rowMeta.addValueMeta(filenameMeta);
        }
        if (!Utils.isEmpty(rowNumField)) {
            ValueMetaInterface rowNumMeta = new ValueMetaInteger(rowNumField);
            rowNumMeta.setLength(10);
            rowNumMeta.setOrigin(origin);
            rowMeta.addValueMeta(rowNumMeta);
        }
    } catch (Exception e) {
        throw new KettleStepException(e);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleStepException(org.pentaho.di.core.exception.KettleStepException) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 80 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class DatabaseLookup method initNullIf.

private void initNullIf() throws KettleException {
    final String[] returnFields = meta.getReturnValueField();
    data.nullif = new Object[returnFields.length];
    for (int i = 0; i < returnFields.length; i++) {
        if (!Utils.isEmpty(meta.getReturnValueDefault()[i])) {
            ValueMetaInterface stringMeta = new ValueMetaString("string");
            ValueMetaInterface returnMeta = data.outputRowMeta.getValueMeta(i + getInputRowMeta().size());
            data.nullif[i] = returnMeta.convertData(stringMeta, meta.getReturnValueDefault()[i]);
        } else {
            data.nullif[i] = null;
        }
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)447 RowMeta (org.pentaho.di.core.row.RowMeta)219 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)181 Test (org.junit.Test)179 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)176 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)141 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)86 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)67 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)66 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)57 KettleException (org.pentaho.di.core.exception.KettleException)40 ArrayList (java.util.ArrayList)33 LongObjectId (org.pentaho.di.repository.LongObjectId)29 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)27 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)26 ObjectId (org.pentaho.di.repository.ObjectId)26 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 RowSet (org.pentaho.di.core.RowSet)18 Date (java.util.Date)17 ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)16