use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class YamlInputMeta method getFields.
@Override
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++) {
YamlInputField field = inputFields[i];
int type = field.getType();
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_STRING;
}
String valueName = space.environmentSubstitute(field.getName());
ValueMetaInterface v;
try {
v = ValueMetaFactory.createValueMeta(valueName, type);
} catch (KettlePluginException e) {
v = new ValueMetaString(valueName);
}
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);
}
if (includeFilename) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(filenameField));
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
r.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class JsonInputMeta method getFields.
@Override
public void getFields(RowMetaInterface rowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
if (inFields && removeSourceField && !Utils.isEmpty(valueField)) {
int index = rowMeta.indexOfValue(valueField);
if (index != -1) {
rowMeta.removeValueMeta(index);
}
}
for (JsonInputField field : getInputFields()) {
try {
rowMeta.addValueMeta(field.toValueMeta(name, space));
} catch (Exception e) {
throw new KettleStepException(e);
}
}
if (includeFilename) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(filenameField));
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
rowMeta.addValueMeta(v);
}
if (includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
rowMeta.addValueMeta(v);
}
// Add additional fields
additionalOutputFields.normalize();
additionalOutputFields.getFields(rowMeta, name, info, space, repository, metaStore);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class RowMetaTest method testInsertValueMetaDup.
@Test
public void testInsertValueMetaDup() {
rowMeta.addValueMeta(1, new ValueMetaInteger(integer.getName()));
assertEquals("inserted", 4, rowMeta.size());
assertEquals("rename new", "integer_1", rowMeta.getValueMeta(1).getName());
rowMeta.addValueMeta(new ValueMetaInteger(integer.getName()));
assertEquals("rename after", "integer_2", rowMeta.getValueMeta(4).getName());
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class TextFileInputMeta method getFields.
@Override
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
if (!isPassingThruFields()) {
// all incoming fields are not transmitted !
row.clear();
} else {
if (info != null) {
boolean found = false;
for (int i = 0; i < info.length && !found; i++) {
if (info[i] != null) {
row.mergeRowMeta(info[i]);
found = true;
}
}
}
}
for (int i = 0; i < inputFields.length; i++) {
TextFileInputField field = inputFields[i];
int type = field.getType();
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_STRING;
}
try {
ValueMetaInterface v = ValueMetaFactory.createValueMeta(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());
v.setDateFormatLenient(dateFormatLenient);
v.setDateFormatLocale(dateFormatLocale);
v.setTrimType(field.getTrimType());
row.addValueMeta(v);
} catch (Exception e) {
throw new KettleStepException(e);
}
}
if (errorIgnored) {
if (errorCountField != null && errorCountField.length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(errorCountField);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
if (errorFieldsField != null && errorFieldsField.length() > 0) {
ValueMetaInterface v = new ValueMetaString(errorFieldsField);
v.setOrigin(name);
row.addValueMeta(v);
}
if (errorTextField != null && errorTextField.length() > 0) {
ValueMetaInterface v = new ValueMetaString(errorTextField);
v.setOrigin(name);
row.addValueMeta(v);
}
}
if (includeFilename) {
ValueMetaInterface v = new ValueMetaString(filenameField);
v.setLength(100);
v.setOrigin(name);
row.addValueMeta(v);
}
if (includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(rowNumberField);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getShortFileNameField() != null && getShortFileNameField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getShortFileNameField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getExtensionField() != null && getExtensionField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getExtensionField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getPathField() != null && getPathField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getPathField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getSizeField() != null && getSizeField().length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(getSizeField()));
v.setOrigin(name);
v.setLength(9);
row.addValueMeta(v);
}
if (isHiddenField() != null && isHiddenField().length() > 0) {
ValueMetaInterface v = new ValueMetaBoolean(space.environmentSubstitute(isHiddenField()));
v.setOrigin(name);
row.addValueMeta(v);
}
if (getLastModificationDateField() != null && getLastModificationDateField().length() > 0) {
ValueMetaInterface v = new ValueMetaDate(space.environmentSubstitute(getLastModificationDateField()));
v.setOrigin(name);
row.addValueMeta(v);
}
if (getUriField() != null && getUriField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getUriField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getRootUriField() != null && getRootUriField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(getRootUriField());
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class TableOutputMeta method getFields.
public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// Just add the returning key field...
if (returningGeneratedKeys && generatedKeyField != null && generatedKeyField.length() > 0) {
ValueMetaInterface key = new ValueMetaInteger(space.environmentSubstitute(generatedKeyField));
key.setOrigin(origin);
row.addValueMeta(key);
}
}
Aggregations