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);
}
}
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);
}
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);
}
}
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);
}
}
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;
}
}
}
Aggregations