use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class AccessInputMetaInjection method getStepInjectionMetadataEntries.
@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
for (Entry entry : Entry.values()) {
if (entry.getParent() == null && entry.getValueType() != ValueMetaInterface.TYPE_NONE) {
all.add(new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription()));
}
}
// The file name lines
//
StepInjectionMetaEntry filesEntry = new StepInjectionMetaEntry(Entry.FILENAME_LINES.name(), ValueMetaInterface.TYPE_NONE, Entry.FILENAME_LINES.description);
all.add(filesEntry);
StepInjectionMetaEntry fileEntry = new StepInjectionMetaEntry(Entry.FILENAME_LINE.name(), ValueMetaInterface.TYPE_NONE, Entry.FILENAME_LINE.description);
filesEntry.getDetails().add(fileEntry);
for (Entry entry : Entry.values()) {
if (entry.getParent() == Entry.FILENAME_LINE) {
StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
fileEntry.getDetails().add(metaEntry);
}
}
// Add the fields...
//
StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry(Entry.FIELDS.name(), Entry.FIELDS.getValueType(), Entry.FIELDS.getDescription());
all.add(fieldsEntry);
StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry(Entry.FIELD.name(), Entry.FIELD.getValueType(), Entry.FIELD.getDescription());
fieldsEntry.getDetails().add(fieldEntry);
for (Entry entry : Entry.values()) {
if (entry.getParent() == Entry.FIELD) {
StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
fieldEntry.getDetails().add(metaEntry);
}
}
return all;
}
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;
}
}
}
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 ExcelWriterMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<ExcelWriterStepField> excelOutputFields = new ArrayList<ExcelWriterStepField>();
for (StepInjectionMetaEntry lookFields : all) {
Entry fieldsEntry = Entry.findEntry(lookFields.getKey());
if (fieldsEntry != null) {
if (fieldsEntry == Entry.FIELDS) {
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry != null) {
if (fieldEntry == Entry.FIELD) {
ExcelWriterStepField excelOutputField = new ExcelWriterStepField();
List<StepInjectionMetaEntry> entries = lookField.getDetails();
for (StepInjectionMetaEntry entry : entries) {
Entry metaEntry = Entry.findEntry(entry.getKey());
if (metaEntry != null) {
Object value = entry.getValue();
if (value != null) {
switch(metaEntry) {
case NAME:
excelOutputField.setName((String) value);
break;
case TYPE:
excelOutputField.setType((String) value);
break;
case FORMAT:
excelOutputField.setFormat((String) value);
break;
case STYLECELL:
excelOutputField.setStyleCell((String) value);
break;
case FIELDTITLE:
excelOutputField.setTitle((String) value);
break;
case TITLESTYLE:
excelOutputField.setTitleStyleCell((String) value);
break;
case FORMULA:
excelOutputField.setFormula((Boolean) value);
break;
case HYPERLINKFIELD:
excelOutputField.setHyperlinkField((String) value);
break;
case CELLCOMMENT:
excelOutputField.setCommentField((String) value);
break;
case COMMENTAUTHOR:
excelOutputField.setCommentAuthorField((String) value);
break;
default:
break;
}
}
}
}
excelOutputFields.add(excelOutputField);
}
}
}
}
}
}
meta.setOutputFields(excelOutputFields.toArray(new ExcelWriterStepField[excelOutputFields.size()]));
}
Aggregations