use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class FixedInputMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<FixedFileInputField> fixedInputFields = new ArrayList<FixedFileInputField>();
//
for (StepInjectionMetaEntry lookFields : all) {
String lookValue = (String) lookFields.getValue();
Entry fieldsEntry = Entry.findEntry(lookFields.getKey());
if (fieldsEntry != null) {
switch(fieldsEntry) {
case FIELDS:
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry != null) {
if (fieldEntry == Entry.FIELD) {
FixedFileInputField inputField = new FixedFileInputField();
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.setName(value);
break;
case TYPE:
inputField.setType(ValueMetaFactory.getIdForValueMeta(value));
break;
case WIDTH:
inputField.setWidth(Const.toInt(value, -1));
break;
case LENGTH:
inputField.setLength(Const.toInt(value, -1));
break;
case PRECISION:
inputField.setPrecision(Const.toInt(value, -1));
break;
case CURRENCY:
inputField.setCurrency(value);
break;
case GROUP:
inputField.setGrouping(value);
break;
case DECIMAL:
inputField.setDecimal(value);
break;
case FORMAT:
inputField.setFormat(value);
break;
case TRIM_TYPE:
inputField.setTrimType(ValueMetaString.getTrimTypeByCode(value));
break;
default:
break;
}
}
}
fixedInputFields.add(inputField);
}
}
}
break;
case FILENAME:
meta.setFilename(lookValue);
break;
case HEADER_PRESENT:
meta.setHeaderPresent("Y".equalsIgnoreCase(lookValue));
break;
case LINE_WIDTH:
meta.setLineWidth(lookValue);
break;
case BUFFER_SIZE:
meta.setBufferSize(lookValue);
break;
case LAZY_CONVERSION_ACTIVE:
meta.setLazyConversionActive("Y".equalsIgnoreCase(lookValue));
break;
case LINE_FEED_PRESENT:
meta.setLineFeedPresent("Y".equalsIgnoreCase(lookValue));
break;
case RUNNING_IN_PARALLEL:
meta.setRunningInParallel("Y".equalsIgnoreCase(lookValue));
break;
case FILE_TYPE_CODE:
meta.setFileType(FixedInputMeta.getFileType(lookValue));
break;
case ADD_TO_RESULT:
meta.setAddResultFile("Y".equalsIgnoreCase(lookValue));
break;
default:
break;
}
}
}
// Pass the grid to the step metadata
//
meta.setFieldDefinition(fixedInputFields.toArray(new FixedFileInputField[fixedInputFields.size()]));
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class FixedInputMetaInjection method getStepInjectionMetadataEntries.
@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
// 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);
} else {
if (entry.getParent() == null && entry != Entry.FIELDS && entry != Entry.FIELD) {
StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
all.add(metaEntry);
}
}
}
return all;
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class TableOutputMetaInjection method injectStepMetadataEntries.
@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
List<String> databaseFields = new ArrayList<String>();
List<String> streamFields = 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 DATABASE_FIELDS:
for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
Entry fieldEntry = Entry.findEntry(lookField.getKey());
if (fieldEntry == Entry.DATABASE_FIELD) {
String databaseFieldname = null;
String streamFieldname = 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 DATABASE_FIELDNAME:
databaseFieldname = value;
break;
case STREAM_FIELDNAME:
streamFieldname = value;
break;
default:
break;
}
}
}
databaseFields.add(databaseFieldname);
streamFields.add(streamFieldname);
}
}
break;
case TARGET_SCHEMA:
meta.setSchemaName(lookValue);
break;
case TARGET_TABLE:
meta.setTableName(lookValue);
break;
case COMMIT_SIZE:
meta.setCommitSize(lookValue);
break;
case TRUNCATE_TABLE:
meta.setTruncateTable("Y".equalsIgnoreCase(lookValue));
break;
case SPECIFY_DATABASE_FIELDS:
meta.setSpecifyFields("Y".equalsIgnoreCase(lookValue));
break;
case IGNORE_INSERT_ERRORS:
meta.setIgnoreErrors("Y".equalsIgnoreCase(lookValue));
break;
case USE_BATCH_UPDATE:
meta.setUseBatchUpdate("Y".equalsIgnoreCase(lookValue));
break;
case PARTITION_OVER_TABLES:
meta.setPartitioningEnabled("Y".equalsIgnoreCase(lookValue));
break;
case PARTITIONING_FIELD:
meta.setPartitioningField(lookValue);
break;
case PARTITION_DATA_PER:
meta.setPartitioningDaily("DAY".equalsIgnoreCase(lookValue));
meta.setPartitioningMonthly("MONTH".equalsIgnoreCase(lookValue));
break;
case TABLE_NAME_DEFINED_IN_FIELD:
meta.setTableNameInField("Y".equalsIgnoreCase(lookValue));
break;
case TABLE_NAME_FIELD:
meta.setTableNameField(lookValue);
break;
case STORE_TABLE_NAME:
meta.setTableNameInTable("Y".equalsIgnoreCase(lookValue));
break;
case RETURN_AUTO_GENERATED_KEY:
meta.setReturningGeneratedKeys("Y".equalsIgnoreCase(lookValue));
break;
case AUTO_GENERATED_KEY_FIELD:
meta.setGeneratedKeyField(lookValue);
break;
default:
break;
}
}
//
if (databaseFields.size() > 0) {
meta.setFieldDatabase(databaseFields.toArray(new String[databaseFields.size()]));
meta.setFieldStream(streamFields.toArray(new String[streamFields.size()]));
}
}
use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.
the class PGBulkLoaderMetaTest method testTopLevelMetadataEntries.
@Test
public void testTopLevelMetadataEntries() {
try {
List<StepInjectionMetaEntry> entries = loader.getStepMeta().getStepMetaInterface().getStepMetaInjectionInterface().getStepInjectionMetadataEntries();
String masterKeys = "SCHEMA TABLE LOADACTION STOPONERROR DELIMITER ENCLOSURE DBNAMEOVERRIDE MAPPINGS ";
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 GroupByMetaInjection method getStepInjectionMetadataEntries.
@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
Entry[] topEntries = new Entry[] { Entry.PASS_ALL_ROWS, Entry.TEMP_DIRECTORY, Entry.TEMP_FILE_PREFIX, Entry.GROUP_LINE_NUMBER_ENABLED, Entry.GROUP_LINE_NUMBER_FIELDNAME, Entry.ALLWAYS_PASS_A_ROW };
for (Entry topEntry : topEntries) {
all.add(new StepInjectionMetaEntry(topEntry.name(), topEntry.getValueType(), topEntry.getDescription()));
}
// The group
//
StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry(Entry.GROUP_FIELDS.name(), ValueMetaInterface.TYPE_NONE, Entry.GROUP_FIELDS.description);
all.add(fieldsEntry);
StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry(Entry.GROUP_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.GROUP_FIELD.description);
fieldsEntry.getDetails().add(fieldEntry);
Entry[] fieldsEntries = new Entry[] { Entry.GROUP_FIELDNAME };
for (Entry entry : fieldsEntries) {
StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
fieldEntry.getDetails().add(metaEntry);
}
// The aggregations
//
StepInjectionMetaEntry aggsEntry = new StepInjectionMetaEntry(Entry.AGG_FIELDS.name(), ValueMetaInterface.TYPE_NONE, Entry.AGG_FIELDS.description);
all.add(aggsEntry);
StepInjectionMetaEntry aggEntry = new StepInjectionMetaEntry(Entry.AGG_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.AGG_FIELD.description);
aggsEntry.getDetails().add(aggEntry);
Entry[] aggEntries = new Entry[] { Entry.AGG_FIELDNAME, Entry.AGG_SUBJECT, Entry.AGG_TYPE, Entry.AGG_VALUE };
for (Entry entry : aggEntries) {
StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
aggEntry.getDetails().add(metaEntry);
}
return all;
}
Aggregations