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 JsonOutputMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<String> jsonFields = new ArrayList<String>();
List<String> jsonElements = new ArrayList<String>();
//
for (StepInjectionMetaEntry lookFields : all) {
Entry fieldsEntry = Entry.findEntry(lookFields.getKey());
if (fieldsEntry == null) {
continue;
}
String lookValue = (String) lookFields.getValue();
switch(fieldsEntry) {
case JSON_FIELDS:
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry == Entry.JSON_FIELD) {
String jsonFieldname = null;
String jsonElement = null;
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 JSON_FIELDNAME:
jsonFieldname = value;
break;
case JSON_ELEMENTNAME:
jsonElement = value;
break;
default:
break;
}
}
}
jsonFields.add(jsonFieldname);
jsonElements.add(jsonElement);
}
}
break;
case OPERATION:
meta.setOperationType(JsonOutputMeta.getOperationTypeByDesc(lookValue));
break;
case JSON_BLOC_NAME:
meta.setJsonBloc(lookValue);
break;
case NR_ROWS_IN_BLOC:
meta.setNrRowsInBloc(lookValue);
break;
case OUTPUT_VALUE:
meta.setOutputValue(lookValue);
break;
case COMPATIBILITY_MODE:
meta.setCompatibilityMode("Y".equalsIgnoreCase(lookValue));
break;
case FILE_NAME:
meta.setFileName(lookValue);
break;
case APPEND:
meta.setFileAppended("Y".equalsIgnoreCase(lookValue));
break;
case CREATE_PARENT_FOLDER:
meta.setCreateParentFolder("Y".equalsIgnoreCase(lookValue));
break;
case DONT_CREATE_AT_START:
meta.setDoNotOpenNewFileInit("Y".equalsIgnoreCase(lookValue));
break;
case EXTENSION:
meta.setExtension(lookValue);
break;
case ENCODING:
meta.setEncoding(lookValue);
break;
case PASS_TO_SERVLET:
meta.setServletOutput("Y".equalsIgnoreCase(lookValue));
break;
case INC_DATE_IN_FILENAME:
meta.setDateInFilename("Y".equalsIgnoreCase(lookValue));
break;
case INC_TIME_IN_FILENAME:
meta.setTimeInFilename("Y".equalsIgnoreCase(lookValue));
break;
case ADD_TO_RESULT:
meta.setAddToResult("Y".equalsIgnoreCase(lookValue));
break;
default:
break;
}
}
//
if (jsonFields.size() > 0) {
JsonOutputField[] jof = new JsonOutputField[jsonFields.size()];
Iterator<String> iJsonFields = jsonFields.iterator();
Iterator<String> iJsonElements = jsonElements.iterator();
int i = 0;
while (iJsonFields.hasNext()) {
JsonOutputField field = new JsonOutputField();
field.setFieldName(iJsonFields.next());
field.setElementName(iJsonElements.next());
jof[i] = field;
i++;
}
meta.setOutputFields(jof);
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class TextFileInputMetaInjectionTest method extractingAll.
@Test
public void extractingAll() throws Exception {
TextFileInputMetaInjection injection = new TextFileInputMetaInjection(new TextFileInputMeta());
List<StepInjectionMetaEntry> metadata = injection.getStepInjectionMetadataEntries();
List<StepInjectionMetaEntry> extracted = injection.extractStepMetadataEntries();
assertEquals(metadata.size(), extracted.size());
for (StepInjectionMetaEntry metaEntry : metadata) {
assertNotNull(metaEntry.getKey(), StepInjectionUtil.findEntry(extracted, metaEntry.getKey()));
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class TextFileInputMetaInjectionTest method assertInjected.
private static void assertInjected(List<StepInjectionMetaEntry> fields, List<StepInjectionMetaEntry> toBeInjected) {
Map<String, StepInjectionMetaEntry> map = new HashMap<String, StepInjectionMetaEntry>(fields.size());
for (StepInjectionMetaEntry field : fields) {
map.put(field.getKey(), field);
}
for (StepInjectionMetaEntry entry : toBeInjected) {
StepInjectionMetaEntry field = map.get(entry.getKey());
assertNotNull(entry.getKey(), field);
Object value = field.getValue();
if (value == null) {
assertNull(entry.getKey(), entry.getValue());
} else {
assertEquals(entry.getKey(), entry.getValue(), value);
}
}
}
Aggregations