use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class ExcelWriterStepTest method testTopLevelMetadataEntries.
@Test
public void testTopLevelMetadataEntries() {
try {
List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries();
String masterKeys = "FIELDS";
for (StepInjectionMetaEntry entry : entries) {
String key = entry.getKey();
assertTrue(masterKeys.contains(key));
masterKeys = masterKeys.replace(key, "");
}
assertTrue(masterKeys.trim().length() == 0);
} catch (KettleException e) {
fail(e.getMessage());
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class ExcelWriterStepTest method testChildLevelMetadataEntries.
@Test
public void testChildLevelMetadataEntries() {
try {
List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries();
String childKeys = "NAME TYPE FORMAT STYLECELL FIELDTITLE TITLESTYLE " + "FORMULA HYPERLINKFIELD CELLCOMMENT COMMENTAUTHOR";
StepInjectionMetaEntry mappingEntry = null;
for (StepInjectionMetaEntry entry : entries) {
String key = entry.getKey();
if (key.equals("FIELDS")) {
mappingEntry = entry;
break;
}
}
assertNotNull(mappingEntry);
List<StepInjectionMetaEntry> fieldAttributes = mappingEntry.getDetails().get(0).getDetails();
for (StepInjectionMetaEntry attribute : fieldAttributes) {
String key = attribute.getKey();
assertTrue(childKeys.contains(key));
childKeys = childKeys.replace(key, "");
}
assertTrue(childKeys.trim().length() == 0);
} catch (KettleException e) {
fail(e.getMessage());
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class MetaInjectTest method setEntryValue_boolean.
@Test
public void setEntryValue_boolean() throws KettleValueException {
StepInjectionMetaEntry entry = mock(StepInjectionMetaEntry.class);
doReturn(ValueMetaInterface.TYPE_BOOLEAN).when(entry).getValueType();
RowMetaAndData row = createRowMetaAndData(new ValueMetaBoolean(TEST_FIELD), true);
SourceStepField sourceField = new SourceStepField(TEST_SOURCE_STEP_NAME, TEST_FIELD);
MetaInject.setEntryValue(entry, row, sourceField);
verify(entry).setValue(true);
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class MetaInjectTest method setEntryValue_integer.
@Test
public void setEntryValue_integer() throws KettleValueException {
StepInjectionMetaEntry entry = mock(StepInjectionMetaEntry.class);
doReturn(ValueMetaInterface.TYPE_INTEGER).when(entry).getValueType();
RowMetaAndData row = createRowMetaAndData(new ValueMetaInteger(TEST_FIELD), new Long(1));
SourceStepField sourceField = new SourceStepField(TEST_SOURCE_STEP_NAME, TEST_FIELD);
MetaInject.setEntryValue(entry, row, sourceField);
verify(entry).setValue(1L);
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class AccessInputMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<AccessInputField> fields = new ArrayList<AccessInputField>();
List<FileLine> fileLines = new ArrayList<FileLine>();
//
for (StepInjectionMetaEntry lookFields : all) {
Entry fieldsEntry = Entry.findEntry(lookFields.getKey());
if (fieldsEntry == null) {
continue;
}
String lookValue = (String) lookFields.getValue();
switch(fieldsEntry) {
case FILENAME_LINES:
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry == Entry.FILENAME_LINE) {
FileLine fileLine = new FileLine();
List<StepInjectionMetaEntry> entries = lookField.getDetails();
for (StepInjectionMetaEntry entry : entries) {
Entry metaEntry = Entry.findEntry(entry.getKey());
if (metaEntry != null) {
String value = (String) entry.getValue();
switch(metaEntry) {
case FILENAME:
fileLine.filename = value;
break;
case FILEMASK:
fileLine.includeMask = value;
break;
case EXCLUDE_FILEMASK:
fileLine.excludeMask = value;
break;
case FILE_REQUIRED:
fileLine.required = value;
break;
case INCLUDE_SUBFOLDERS:
fileLine.includeSubfolders = value;
break;
default:
break;
}
}
}
fileLines.add(fileLine);
}
}
break;
case FIELDS:
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry == Entry.FIELD) {
AccessInputField field = new AccessInputField();
List<StepInjectionMetaEntry> entries = lookField.getDetails();
for (StepInjectionMetaEntry entry : entries) {
Entry metaEntry = Entry.findEntry(entry.getKey());
if (metaEntry != null) {
String value = (String) entry.getValue();
switch(metaEntry) {
case FIELD_NAME:
field.setName(value);
break;
case FIELD_COLUMN:
field.setColumn(value);
break;
case FIELD_LENGTH:
field.setLength(Const.toInt(value, -1));
break;
case FIELD_TYPE:
field.setType(ValueMetaFactory.getIdForValueMeta(value));
break;
case FIELD_FORMAT:
field.setFormat(value);
break;
case FIELD_TRIM_TYPE:
field.setTrimType(ValueMetaBase.getTrimTypeByCode(value));
break;
case FIELD_PRECISION:
field.setPrecision(Const.toInt(value, -1));
break;
case FIELD_DECIMAL:
field.setDecimalSymbol(value);
break;
case FIELD_GROUP:
field.setGroupSymbol(value);
break;
case FIELD_CURRENCY:
field.setCurrencySymbol(value);
break;
case FIELD_REPEAT:
field.setRepeated("Y".equalsIgnoreCase(value));
break;
default:
break;
}
}
}
fields.add(field);
}
}
break;
case INCLUDE_FILENAME:
meta.setIncludeFilename("Y".equalsIgnoreCase(lookValue));
break;
case FILENAME_FIELD:
meta.setFilenameField(lookValue);
break;
case INCLUDE_ROW_NUMBER:
meta.setIncludeRowNumber("Y".equalsIgnoreCase(lookValue));
break;
case ROW_NUMBER_BY_FILE:
meta.setResetRowNumber("Y".equalsIgnoreCase(lookValue));
break;
case ROW_NUMBER_FIELD:
meta.setRowNumberField(lookValue);
break;
case ROW_LIMIT:
meta.setRowLimit(Const.toInt(lookValue, -1));
break;
case ACCEPT_FILE_NAMES:
meta.setFileField("Y".equalsIgnoreCase(lookValue));
break;
case ACCEPT_FILE_FIELD:
meta.setDynamicFilenameField(lookValue);
break;
case ADD_FILES_TO_RESULT:
meta.setAddResultFile("Y".equalsIgnoreCase(lookValue));
break;
case FILE_SHORT_FILE_FIELDNAME:
meta.setShortFileNameField(lookValue);
break;
case FILE_PATH_FIELDNAME:
meta.setPathField(lookValue);
break;
case FILE_HIDDEN_FIELDNAME:
meta.setIsHiddenField(lookValue);
break;
case FILE_LAST_MODIFICATION_FIELDNAME:
meta.setLastModificationDateField(lookValue);
break;
case FILE_URI_FIELDNAME:
meta.setUriField(lookValue);
break;
case FILE_EXTENSION_FIELDNAME:
meta.setExtensionField(lookValue);
break;
case FILE_SIZE_FIELDNAME:
meta.setSizeField(lookValue);
break;
case TABLENAME:
meta.setTableName(lookValue);
break;
case INCLUDE_TABLENAME:
meta.setIncludeTablename("Y".equalsIgnoreCase(lookValue));
break;
case TABLENAME_FIELD:
meta.setTableName(lookValue);
break;
default:
break;
}
}
//
if (fields.size() > 0) {
meta.setInputFields(fields.toArray(new AccessInputField[fields.size()]));
}
if (fileLines.size() > 0) {
meta.allocateFiles(fileLines.size());
for (int i = 0; i < fileLines.size(); i++) {
FileLine fileLine = fileLines.get(i);
(meta.getFileName())[i] = fileLine.filename;
(meta.getFileMask())[i] = fileLine.includeMask;
(meta.getExludeFileMask())[i] = fileLine.excludeMask;
(meta.getExludeFileMask())[i] = fileLine.excludeMask;
(meta.getFileRequired())[i] = fileLine.required;
(meta.getIncludeSubFolders())[i] = fileLine.includeSubfolders;
}
}
}
Aggregations