use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class LDIFInputMeta method getFields.
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++) {
LDIFInputField 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(), field.getPrecision());
v.setOrigin(name);
r.addValueMeta(v);
} catch (Exception e) {
throw new KettleStepException(e);
}
}
if (includeFilename) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(filenameField));
v.setLength(100, -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);
}
if (includeContentType) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(contentTypeField));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (includeDN) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(DNField));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
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);
}
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class LoadFileInputMeta method getFields.
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
if (!getIsInFields()) {
r.clear();
}
int i;
for (i = 0; i < inputFields.length; i++) {
LoadFileInputField field = inputFields[i];
int type = field.getType();
switch(field.getElementType()) {
case LoadFileInputField.ELEMENT_TYPE_FILECONTENT:
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_STRING;
}
break;
case LoadFileInputField.ELEMENT_TYPE_FILESIZE:
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_INTEGER;
}
break;
default:
break;
}
try {
ValueMetaInterface v = ValueMetaFactory.createValueMeta(space.environmentSubstitute(field.getName()), type);
v.setLength(field.getLength());
v.setPrecision(field.getPrecision());
v.setConversionMask(field.getFormat());
v.setCurrencySymbol(field.getCurrencySymbol());
v.setDecimalSymbol(field.getDecimalSymbol());
v.setGroupingSymbol(field.getGroupSymbol());
v.setTrimType(field.getTrimType());
v.setOrigin(name);
r.addValueMeta(v);
} 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);
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);
}
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 (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);
}
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class MetaInjectTest method setEntryValue_date.
@Test
public void setEntryValue_date() throws KettleValueException {
StepInjectionMetaEntry entry = mock(StepInjectionMetaEntry.class);
doReturn(ValueMetaInterface.TYPE_DATE).when(entry).getValueType();
RowMetaAndData row = createRowMetaAndData(new ValueMetaDate(TEST_FIELD), null);
SourceStepField sourceField = new SourceStepField(TEST_SOURCE_STEP_NAME, TEST_FIELD);
MetaInject.setEntryValue(entry, row, sourceField);
verify(entry).setValue(null);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class SelectValues_LocaleHandling_Test method executeAndCheck.
private void executeAndCheck(String locale, String expectedWeekNumber) throws Exception {
RowMeta inputRowMeta = new RowMeta();
inputRowMeta.addValueMeta(new ValueMetaDate("field"));
step.setInputRowMeta(inputRowMeta);
SelectValuesMeta stepMeta = new SelectValuesMeta();
stepMeta.allocate(1, 0, 1);
stepMeta.getSelectFields()[0] = new SelectField();
stepMeta.getSelectFields()[0].setName("field");
stepMeta.getMeta()[0] = new SelectMetadataChange(stepMeta, "field", null, ValueMetaInterface.TYPE_STRING, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, "ww", false, locale, null, false, null, null, null);
SelectValuesData stepData = new SelectValuesData();
stepData.select = true;
stepData.metadata = true;
stepData.firstselect = true;
stepData.firstmetadata = true;
List<Object[]> execute = TransTestingUtil.execute(step, stepMeta, stepData, 1, true);
TransTestingUtil.assertResult(execute, Collections.singletonList(new Object[] { expectedWeekNumber }));
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class MemoryGroupByMetaGetFieldsTest method getFieldsWithSubject_NoFormat.
@Test
public void getFieldsWithSubject_NoFormat() {
ValueMetaDate valueMeta = new ValueMetaDate();
valueMeta.setName("date");
doReturn(valueMeta).when(rowMeta).searchValueMeta("date");
memoryGroupByMeta.setSubjectField(new String[] { "date" });
memoryGroupByMeta.setGroupField(new String[] {});
memoryGroupByMeta.setAggregateField(new String[] { "minDate" });
memoryGroupByMeta.setAggregateType(new int[] { TYPE_GROUP_MIN });
memoryGroupByMeta.getFields(rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore);
verify(rowMeta, times(1)).clear();
verify(rowMeta, times(1)).addRowMeta(any());
assertEquals(null, rowMeta.searchValueMeta("minDate").getConversionMask());
}
Aggregations