Search in sources :

Example 41 with StepInjectionMetaEntry

use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.

the class ExcelWriterMetaInjection method getStepInjectionMetadataEntries.

@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
    StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry("FIELDS", ValueMetaInterface.TYPE_NONE, BaseMessages.getString(PKG, "ExcelWriterMetaInjection.AllFields"));
    all.add(fieldsEntry);
    StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry("FIELD", ValueMetaInterface.TYPE_NONE, BaseMessages.getString(PKG, "ExcelWriterMetaInjection.AllFields"));
    fieldsEntry.getDetails().add(fieldEntry);
    for (Entry entry : Entry.values()) {
        if (entry.getValueType() != ValueMetaInterface.TYPE_NONE) {
            StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
            fieldEntry.getDetails().add(metaEntry);
        }
    }
    return all;
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList)

Example 42 with StepInjectionMetaEntry

use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.

the class DataGridMetaInjection 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);
        }
    }
    // And the data fields
    // 
    StepInjectionMetaEntry sheetsEntry = new StepInjectionMetaEntry(Entry.DATA_LINES.name(), Entry.DATA_LINES.getValueType(), Entry.DATA_LINES.getDescription());
    all.add(sheetsEntry);
    StepInjectionMetaEntry sheetEntry = new StepInjectionMetaEntry(Entry.DATA_LINE.name(), Entry.DATA_LINE.getValueType(), Entry.DATA_LINE.getDescription());
    sheetsEntry.getDetails().add(sheetEntry);
    for (Entry entry : Entry.values()) {
        if (entry.getParent() == Entry.DATA_LINE) {
            StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
            sheetEntry.getDetails().add(metaEntry);
        }
    }
    return all;
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList)

Example 43 with StepInjectionMetaEntry

use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.

the class DataGridMetaInjection method injectStepMetadataEntries.

@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
    List<GridMetaEntry> gridMetaEntries = new ArrayList<GridMetaEntry>();
    List<List<String>> dataLines = new ArrayList<List<String>>();
    // 
    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) {
                            GridMetaEntry gridMetaEntry = new GridMetaEntry();
                            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:
                                            gridMetaEntry.fieldName = value;
                                            break;
                                        case TYPE:
                                            gridMetaEntry.fieldType = value;
                                            break;
                                        case LENGTH:
                                            gridMetaEntry.fieldLength = Const.toInt(value, -1);
                                            break;
                                        case PRECISION:
                                            gridMetaEntry.fieldPrecision = Const.toInt(value, -1);
                                            break;
                                        case CURRENCY:
                                            gridMetaEntry.currency = value;
                                            break;
                                        case GROUP:
                                            gridMetaEntry.group = value;
                                            break;
                                        case DECIMAL:
                                            gridMetaEntry.decimal = value;
                                            break;
                                        case FORMAT:
                                            gridMetaEntry.fieldFormat = value;
                                            break;
                                        case EMPTY_STRING:
                                            gridMetaEntry.setEmptyString = "Y".equalsIgnoreCase(value) || "TRUE".equalsIgnoreCase(value);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }
                            gridMetaEntries.add(gridMetaEntry);
                        }
                    }
                }
            }
        }
    }
    // Now that we know how many fields we have we can simply read all the data fields...
    // 
    List<String> line = new ArrayList<String>();
    for (StepInjectionMetaEntry lookFields : all) {
        Entry fieldsEntry = Entry.findEntry(lookFields.getKey());
        if (fieldsEntry != null) {
            if (fieldsEntry == Entry.DATA_LINES) {
                for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
                    Entry fieldEntry = Entry.findEntry(lookField.getKey());
                    if (fieldEntry != null) {
                        if (fieldEntry == Entry.DATA_LINE) {
                            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 DATA_VALUE:
                                            line.add(value);
                                            if (line.size() >= gridMetaEntries.size()) {
                                                dataLines.add(line);
                                                line = new ArrayList<String>();
                                            }
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // 
    if (gridMetaEntries.size() > 0) {
        meta.allocate(gridMetaEntries.size());
        for (int i = 0; i < gridMetaEntries.size(); i++) {
            GridMetaEntry entry = gridMetaEntries.get(i);
            // CHECKSTYLE:Indentation:OFF
            meta.getFieldName()[i] = entry.fieldName;
            meta.getFieldType()[i] = entry.fieldType;
            meta.getFieldFormat()[i] = entry.fieldFormat;
            meta.getFieldLength()[i] = entry.fieldLength;
            meta.getFieldPrecision()[i] = entry.fieldPrecision;
            meta.getCurrency()[i] = entry.currency;
            meta.getGroup()[i] = entry.group;
            meta.getDecimal()[i] = entry.decimal;
            meta.isSetEmptyString()[i] = entry.setEmptyString;
        }
    }
    if (dataLines.size() > 0) {
        // Set the data ...
        // 
        meta.setDataLines(dataLines);
    }
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) List(java.util.List) ArrayList(java.util.ArrayList)

Example 44 with StepInjectionMetaEntry

use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.

the class DenormaliserMetaInjection method getStepInjectionMetadataEntries.

@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
    StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry("FIELDS", ValueMetaInterface.TYPE_NONE, "All the fields on the spreadsheets");
    all.add(fieldsEntry);
    StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry("FIELD", ValueMetaInterface.TYPE_NONE, "All the fields on the spreadsheets");
    fieldsEntry.getDetails().add(fieldEntry);
    for (Entry entry : Entry.values()) {
        if (entry.getValueType() != ValueMetaInterface.TYPE_NONE) {
            StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
            fieldEntry.getDetails().add(metaEntry);
        }
    }
    return all;
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList)

Example 45 with StepInjectionMetaEntry

use of org.pentaho.di.trans.step.StepInjectionMetaEntry in project pentaho-kettle by pentaho.

the class ParGzipCsvInputMetaInjection method getStepInjectionMetadataEntries.

@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
    Entry[] topEntries = new Entry[] { Entry.FILENAME, Entry.FILENAME_FIELD, Entry.INCLUDING_FILENAMES, Entry.ROW_NUMBER_FIELD, Entry.HEADER_PRESENT, Entry.DELIMITER, Entry.ENCLOSURE, Entry.BUFFER_SIZE, Entry.LAZY_CONVERSION, Entry.ADD_FILES_TO_RESULT, Entry.RUN_IN_PARALLEL, Entry.ENCODING };
    for (Entry topEntry : topEntries) {
        all.add(new StepInjectionMetaEntry(topEntry.name(), topEntry.getValueType(), topEntry.getDescription()));
    }
    // The fields...
    // 
    StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry(Entry.FIELDS.name(), ValueMetaInterface.TYPE_NONE, Entry.FIELDS.description);
    all.add(fieldsEntry);
    StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry(Entry.FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.FIELD.description);
    fieldsEntry.getDetails().add(fieldEntry);
    Entry[] aggEntries = new Entry[] { Entry.FIELD_NAME, Entry.FIELD_POSITION, Entry.FIELD_LENGTH, Entry.FIELD_TYPE, Entry.FIELD_IGNORE, Entry.FIELD_FORMAT, Entry.FIELD_TRIM_TYPE, Entry.FIELD_PRECISION, Entry.FIELD_DECIMAL, Entry.FIELD_GROUP, Entry.FIELD_CURRENCY, Entry.FIELD_REPEAT, Entry.FIELD_NULL_STRING, Entry.FIELD_IF_NULL };
    for (Entry entry : aggEntries) {
        StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry(entry.name(), entry.getValueType(), entry.getDescription());
        fieldEntry.getDetails().add(metaEntry);
    }
    return all;
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList)

Aggregations

StepInjectionMetaEntry (org.pentaho.di.trans.step.StepInjectionMetaEntry)54 ArrayList (java.util.ArrayList)31 Test (org.junit.Test)17 KettleException (org.pentaho.di.core.exception.KettleException)10 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)6 KettleAttributeInterface (org.pentaho.di.core.KettleAttributeInterface)3 TextFileInputField (org.pentaho.di.trans.steps.textfileinput.TextFileInputField)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 ShellEvent (org.eclipse.swt.events.ShellEvent)1