use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class JaninoMetaInjection method getStepInjectionMetadataEntries.
@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
// The fields
//
StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry(Entry.EXPRESSION_FIELDS.name(), ValueMetaInterface.TYPE_NONE, Entry.EXPRESSION_FIELDS.description);
all.add(fieldsEntry);
StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry(Entry.EXPRESSION_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.EXPRESSION_FIELD.description);
fieldsEntry.getDetails().add(fieldEntry);
Entry[] fieldsEntries = new Entry[] { Entry.NEW_FIELDNAME, Entry.JAVA_EXPRESSION, Entry.VALUE_TYPE, Entry.LENGTH, Entry.PRECISION, Entry.REPLACE_VALUE };
for (Entry entry : fieldsEntries) {
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 JaninoMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<String> fieldNames = new ArrayList<String>();
List<String> javaExpressions = new ArrayList<String>();
List<String> valueTypes = new ArrayList<String>();
List<String> lengths = new ArrayList<String>();
List<String> precisions = new ArrayList<String>();
List<String> replaceValues = new ArrayList<String>();
//
for (StepInjectionMetaEntry lookFields : all) {
Entry fieldsEntry = Entry.findEntry(lookFields.getKey());
if (fieldsEntry == null) {
continue;
}
switch(fieldsEntry) {
case EXPRESSION_FIELDS:
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry == Entry.EXPRESSION_FIELD) {
String newFieldname = null;
String javaExpression = null;
String valueType = null;
String length = null;
String precision = null;
String replaceValue = 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 NEW_FIELDNAME:
newFieldname = value;
break;
case JAVA_EXPRESSION:
javaExpression = value;
break;
case VALUE_TYPE:
valueType = value;
break;
case LENGTH:
length = value;
break;
case PRECISION:
precision = value;
break;
case REPLACE_VALUE:
replaceValue = value;
break;
default:
break;
}
}
}
fieldNames.add(newFieldname);
javaExpressions.add(javaExpression);
valueTypes.add(valueType);
lengths.add(length);
precisions.add(precision);
replaceValues.add(replaceValue);
}
}
break;
default:
break;
}
}
//
if (fieldNames.size() > 0) {
JaninoMetaFunction[] fields = new JaninoMetaFunction[fieldNames.size()];
Iterator<String> iFieldNames = fieldNames.iterator();
Iterator<String> iJavaExpressions = javaExpressions.iterator();
Iterator<String> iValueTypes = valueTypes.iterator();
Iterator<String> iLengths = lengths.iterator();
Iterator<String> iPrecisions = precisions.iterator();
Iterator<String> iReplaceValues = replaceValues.iterator();
int i = 0;
while (iFieldNames.hasNext()) {
fields[i] = new JaninoMetaFunction(iFieldNames.next(), iJavaExpressions.next(), ValueMetaFactory.getIdForValueMeta(iValueTypes.next()), Const.toInt(iLengths.next(), -1), Const.toInt(iPrecisions.next(), -1), iReplaceValues.next());
i++;
}
meta.setFormula(fields);
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class JaninoMetaInjection method extractStepMetadataEntries.
public List<StepInjectionMetaEntry> extractStepMetadataEntries() throws KettleException {
List<StepInjectionMetaEntry> list = new ArrayList<StepInjectionMetaEntry>();
StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry(Entry.EXPRESSION_FIELDS);
list.add(fieldsEntry);
for (int i = 0; i < meta.getFormula().length; i++) {
StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry(Entry.EXPRESSION_FIELD);
List<StepInjectionMetaEntry> details = fieldEntry.getDetails();
details.add(StepInjectionUtil.getEntry(Entry.NEW_FIELDNAME, meta.getFormula()[i].getFieldName()));
details.add(StepInjectionUtil.getEntry(Entry.JAVA_EXPRESSION, meta.getFormula()[i].getFormula()));
details.add(StepInjectionUtil.getEntry(Entry.VALUE_TYPE, ValueMetaFactory.getValueMetaName(meta.getFormula()[i].getValueType())));
details.add(StepInjectionUtil.getEntry(Entry.LENGTH, meta.getFormula()[i].getValueLength()));
details.add(StepInjectionUtil.getEntry(Entry.PRECISION, meta.getFormula()[i].getValuePrecision()));
details.add(StepInjectionUtil.getEntry(Entry.REPLACE_VALUE, meta.getFormula()[i].getReplaceField()));
fieldsEntry.getDetails().add(fieldEntry);
}
return list;
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class TextFileInputMetaInjectionTest method createInjectionValues.
private static List<StepInjectionMetaEntry> createInjectionValues(TextFileInputMetaInjection.Entry[] entries) {
Map<TextFileInputMetaInjection.Entry, Generator<?>> generators = createGeneratorsMapping();
List<StepInjectionMetaEntry> result = new ArrayList<StepInjectionMetaEntry>(entries.length);
for (TextFileInputMetaInjection.Entry entry : entries) {
StepInjectionMetaEntry injectionEntry = StepInjectionUtil.getEntry(entry);
if (entry.getValueType() != ValueMetaInterface.TYPE_NONE) {
injectionEntry.setValue(generators.get(entry).generateValue());
}
result.add(injectionEntry);
}
return result;
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class DenormaliserMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<DenormaliserTargetField> denormaliserTargetFields = new ArrayList<DenormaliserTargetField>();
//
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) {
DenormaliserTargetField inputField = new DenormaliserTargetField();
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 NAME:
inputField.setFieldName(value);
break;
case KEY_VALUE:
inputField.setKeyValue(value);
break;
case TARGET_NAME:
inputField.setTargetName(value);
break;
case TARGET_TYPE:
inputField.setTargetType(ValueMetaFactory.getIdForValueMeta(value));
break;
case TARGET_LENGTH:
inputField.setTargetLength(Const.toInt(value, -1));
break;
case TARGET_PRECISION:
inputField.setTargetPrecision(Const.toInt(value, -1));
break;
case TARGET_CURRENCY:
inputField.setTargetCurrencySymbol(value);
break;
case TARGET_GROUP:
inputField.setTargetGroupingSymbol(value);
break;
case TARGET_DECIMAL:
inputField.setTargetDecimalSymbol(value);
break;
case TARGET_FORMAT:
inputField.setTargetFormat(value);
break;
case TARGET_AGGREGATION:
inputField.setTargetAggregationType(DenormaliserTargetField.getAggregationType(value));
break;
default:
break;
}
}
}
denormaliserTargetFields.add(inputField);
}
}
}
}
}
}
if (!denormaliserTargetFields.isEmpty()) {
// Pass the grid to the step metadata
//
meta.setDenormaliserTargetField(denormaliserTargetFields.toArray(new DenormaliserTargetField[denormaliserTargetFields.size()]));
}
}
Aggregations