Search in sources :

Example 31 with StepInjectionMetaEntry

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

the class TextFileInputMetaInjection method getStepInjectionMetadataEntries.

@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
    for (Entry topEntry : Entry.getTopEntries()) {
        all.add(StepInjectionUtil.getEntry(topEntry));
    }
    // The file name lines
    // 
    StepInjectionMetaEntry filesEntry = StepInjectionUtil.getEntry(Entry.FILENAME_LINES);
    all.add(filesEntry);
    StepInjectionMetaEntry fileEntry = StepInjectionUtil.getEntry(Entry.FILENAME_LINE);
    filesEntry.getDetails().add(fileEntry);
    Entry[] fileFieldsEntries = Entry.getFileFieldsEntries();
    List<StepInjectionMetaEntry> fileEntryDetails = fileEntry.getDetails();
    for (Entry entry : fileFieldsEntries) {
        StepInjectionMetaEntry metaEntry = StepInjectionUtil.getEntry(entry);
        fileEntryDetails.add(metaEntry);
    }
    // The fields...
    // 
    StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry(Entry.FIELDS);
    all.add(fieldsEntry);
    StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry(Entry.FIELD);
    fieldsEntry.getDetails().add(fieldEntry);
    Entry[] aggEntries = Entry.getAggEntries();
    List<StepInjectionMetaEntry> fieldEntryDetails = fieldEntry.getDetails();
    for (Entry entry : aggEntries) {
        StepInjectionMetaEntry metaEntry = StepInjectionUtil.getEntry(entry);
        fieldEntryDetails.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 32 with StepInjectionMetaEntry

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

the class TextFileInputMetaInjection method injectStepMetadataEntries.

@Override
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> all) throws KettleException {
    List<FileLine> fileLines = new ArrayList<FileLine>();
    List<TextFileInputField> fields = new ArrayList<TextFileInputField>();
    List<TextFileFilter> filters = new ArrayList<TextFileFilter>();
    // 
    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) {
                        TextFileInputField field = new TextFileInputField();
                        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_POSITION:
                                        field.setPosition(Const.toInt(value, -1));
                                        break;
                                    case FIELD_LENGTH:
                                        field.setLength(Const.toInt(value, -1));
                                        break;
                                    case FIELD_TYPE:
                                        field.setType(ValueMetaFactory.getIdForValueMeta(value));
                                        break;
                                    case FIELD_IGNORE:
                                        field.setIgnored("Y".equalsIgnoreCase(value));
                                        break;
                                    case FIELD_FORMAT:
                                        field.setFormat(value);
                                        break;
                                    case FIELD_TRIM_TYPE:
                                        field.setTrimType(ValueMetaString.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;
                                    case FIELD_NULL_STRING:
                                        field.setNullString(value);
                                        break;
                                    case FIELD_IF_NULL:
                                        field.setIfNullValue(value);
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                        fields.add(field);
                    }
                }
                break;
            case FILTERS:
                for (StepInjectionMetaEntry lookField : lookFields.getDetails()) {
                    Entry fieldEntry = Entry.findEntry(lookField.getKey());
                    if (fieldEntry == Entry.FILTER) {
                        TextFileFilter filterLine = new TextFileFilter();
                        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 FILTER_POSITION:
                                        filterLine.setFilterPosition(Const.toInt(value, 0));
                                        break;
                                    case FILTER_STRING:
                                        filterLine.setFilterString(value);
                                        break;
                                    case FILTER_LAST_LINE:
                                        filterLine.setFilterLastLine("Y".equalsIgnoreCase(value));
                                        break;
                                    case FILTER_POSITIVE:
                                        filterLine.setFilterPositive("Y".equalsIgnoreCase(value));
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                        filters.add(filterLine);
                    }
                }
                break;
            case FILE_TYPE:
                meta.setFileType(lookValue);
                break;
            case SEPARATOR:
                meta.setSeparator(lookValue);
                break;
            case ENCLOSURE:
                meta.setEnclosure(lookValue);
                break;
            case ESCAPE_CHAR:
                meta.setEscapeCharacter(lookValue);
                break;
            case BREAK_IN_ENCLOSURE:
                meta.setBreakInEnclosureAllowed("Y".equalsIgnoreCase(lookValue));
                break;
            case HEADER_PRESENT:
                meta.setHeader("Y".equalsIgnoreCase(lookValue));
                break;
            case NR_HEADER_LINES:
                meta.setNrHeaderLines(Const.toInt(lookValue, -1));
                break;
            case HAS_FOOTER:
                meta.setFooter("Y".equalsIgnoreCase(lookValue));
                break;
            case NR_FOOTER_LINES:
                meta.setNrFooterLines(Const.toInt(lookValue, -1));
                break;
            case HAS_WRAPPED_LINES:
                meta.setLineWrapped("Y".equalsIgnoreCase(lookValue));
                break;
            case NR_WRAPS:
                meta.setNrWraps(Const.toInt(lookValue, -1));
                break;
            case HAS_PAGED_LAYOUT:
                meta.setLayoutPaged("Y".equalsIgnoreCase(lookValue));
                break;
            case NR_DOC_HEADER_LINES:
                meta.setNrLinesDocHeader(Const.toInt(lookValue, -1));
                break;
            case NR_LINES_PER_PAGE:
                meta.setNrLinesPerPage(Const.toInt(lookValue, -1));
                break;
            case COMPRESSION_TYPE:
                meta.setFileCompression(lookValue);
                break;
            case NO_EMPTY_LINES:
                meta.setNoEmptyLines("Y".equalsIgnoreCase(lookValue));
                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.setRowNumberByFile("Y".equalsIgnoreCase(lookValue));
                break;
            case ROW_NUMBER_FIELD:
                meta.setRowNumberField(lookValue);
                break;
            case FILE_FORMAT:
                meta.setFileFormat(lookValue);
                break;
            case ENCODING:
                meta.setEncoding(lookValue);
                break;
            case ROW_LIMIT:
                meta.setRowLimit(Const.toInt(lookValue, -1));
                break;
            case DATE_FORMAT_LENIENT:
                meta.setDateFormatLenient("Y".equalsIgnoreCase(lookValue));
                break;
            case DATE_FORMAT_LOCALE:
                meta.setDateFormatLocale(new Locale(lookValue));
                break;
            case ACCEPT_FILE_NAMES:
                meta.setAcceptingFilenames("Y".equalsIgnoreCase(lookValue));
                break;
            case ACCEPT_FILE_STEP:
                meta.setAcceptingStepName(lookValue);
                break;
            case ACCEPT_FILE_FIELD:
                meta.setAcceptingField(lookValue);
                break;
            case PASS_THROUGH_FIELDS:
                meta.setPassingThruFields("Y".equalsIgnoreCase(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 SKIP_BAD_FILES:
                meta.setSkipBadFiles("Y".equalsIgnoreCase(lookValue));
                break;
            case FILE_ERROR_FIELD:
                meta.setFileErrorField(lookValue);
                break;
            case FILE_ERROR_MESSAGE_FIELD:
                meta.setFileErrorMessageField(lookValue);
                break;
            case IGNORE_ERRORS:
                meta.setErrorIgnored("Y".equalsIgnoreCase(lookValue));
                break;
            case ERROR_COUNT_FIELD:
                meta.setErrorCountField(lookValue);
                break;
            case ERROR_FIELDS_FIELD:
                meta.setErrorFieldsField(lookValue);
                break;
            case ERROR_TEXT_FIELD:
                meta.setErrorTextField(lookValue);
                break;
            case WARNING_FILES_TARGET_DIR:
                meta.setWarningFilesDestinationDirectory(lookValue);
                break;
            case WARNING_FILES_EXTENTION:
                meta.setWarningFilesExtension(lookValue);
                break;
            case ERROR_FILES_TARGET_DIR:
                meta.setErrorFilesDestinationDirectory(lookValue);
                break;
            case ERROR_FILES_EXTENTION:
                meta.setErrorLineFilesExtension(lookValue);
                break;
            case LINE_NR_FILES_TARGET_DIR:
                meta.setLineNumberFilesDestinationDirectory(lookValue);
                break;
            case LINE_NR_FILES_EXTENTION:
                meta.setLineNumberFilesExtension(lookValue);
                break;
            case ERROR_LINES_SKIPPED:
                meta.setErrorLineSkipped("Y".equalsIgnoreCase(lookValue));
                break;
            default:
                break;
        }
    }
    // 
    if (fields.size() > 0) {
        meta.setInputFields(fields.toArray(new TextFileInputField[fields.size()]));
    }
    if (fileLines.size() > 0) {
        meta.allocateFiles(fileLines.size());
        // CHECKSTYLE:Indentation:OFF
        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;
        }
    }
    if (filters.size() > 0) {
        meta.setFilter(filters.toArray(new TextFileFilter[filters.size()]));
    }
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry)

Example 33 with StepInjectionMetaEntry

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

the class TextFileInputMetaInjection method extractStepMetadataEntries.

@Override
public List<StepInjectionMetaEntry> extractStepMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> result = new ArrayList<StepInjectionMetaEntry>();
    result.add(StepInjectionUtil.getEntry(Entry.FILE_TYPE, meta.getFileType()));
    result.add(StepInjectionUtil.getEntry(Entry.SEPARATOR, meta.getSeparator()));
    result.add(StepInjectionUtil.getEntry(Entry.ENCLOSURE, meta.getEnclosure()));
    result.add(StepInjectionUtil.getEntry(Entry.ESCAPE_CHAR, meta.getEscapeCharacter()));
    result.add(StepInjectionUtil.getEntry(Entry.BREAK_IN_ENCLOSURE, meta.isBreakInEnclosureAllowed()));
    result.add(StepInjectionUtil.getEntry(Entry.HEADER_PRESENT, meta.hasHeader()));
    result.add(StepInjectionUtil.getEntry(Entry.NR_HEADER_LINES, meta.getNrHeaderLines()));
    result.add(StepInjectionUtil.getEntry(Entry.HAS_FOOTER, meta.hasFooter()));
    result.add(StepInjectionUtil.getEntry(Entry.NR_FOOTER_LINES, meta.getNrFooterLines()));
    result.add(StepInjectionUtil.getEntry(Entry.HAS_WRAPPED_LINES, meta.isLineWrapped()));
    result.add(StepInjectionUtil.getEntry(Entry.NR_WRAPS, meta.getNrWraps()));
    result.add(StepInjectionUtil.getEntry(Entry.HAS_PAGED_LAYOUT, meta.isLayoutPaged()));
    result.add(StepInjectionUtil.getEntry(Entry.NR_DOC_HEADER_LINES, meta.getNrLinesDocHeader()));
    result.add(StepInjectionUtil.getEntry(Entry.NR_LINES_PER_PAGE, meta.getNrLinesPerPage()));
    result.add(StepInjectionUtil.getEntry(Entry.COMPRESSION_TYPE, meta.getFileCompression()));
    result.add(StepInjectionUtil.getEntry(Entry.NO_EMPTY_LINES, meta.noEmptyLines()));
    result.add(StepInjectionUtil.getEntry(Entry.INCLUDE_FILENAME, meta.includeFilename()));
    result.add(StepInjectionUtil.getEntry(Entry.FILENAME_FIELD, meta.getFilenameField()));
    result.add(StepInjectionUtil.getEntry(Entry.INCLUDE_ROW_NUMBER, meta.includeRowNumber()));
    result.add(StepInjectionUtil.getEntry(Entry.ROW_NUMBER_BY_FILE, meta.isRowNumberByFile()));
    result.add(StepInjectionUtil.getEntry(Entry.ROW_NUMBER_FIELD, meta.getRowNumberField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_FORMAT, meta.getFileFormat()));
    result.add(StepInjectionUtil.getEntry(Entry.ENCODING, meta.getEncoding()));
    result.add(StepInjectionUtil.getEntry(Entry.ROW_LIMIT, meta.getRowLimit()));
    result.add(StepInjectionUtil.getEntry(Entry.DATE_FORMAT_LENIENT, meta.isDateFormatLenient()));
    result.add(StepInjectionUtil.getEntry(Entry.DATE_FORMAT_LOCALE, meta.getDateFormatLocale()));
    result.add(StepInjectionUtil.getEntry(Entry.ACCEPT_FILE_NAMES, meta.isAcceptingFilenames()));
    result.add(StepInjectionUtil.getEntry(Entry.ACCEPT_FILE_STEP, meta.getAcceptingStepName()));
    result.add(StepInjectionUtil.getEntry(Entry.ACCEPT_FILE_FIELD, meta.getAcceptingField()));
    result.add(StepInjectionUtil.getEntry(Entry.PASS_THROUGH_FIELDS, meta.isPassingThruFields()));
    result.add(StepInjectionUtil.getEntry(Entry.ADD_FILES_TO_RESULT, meta.isAddResultFile()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_SHORT_FILE_FIELDNAME, meta.getShortFileNameField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_PATH_FIELDNAME, meta.getPathField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_HIDDEN_FIELDNAME, meta.isHiddenField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_LAST_MODIFICATION_FIELDNAME, meta.getLastModificationDateField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_URI_FIELDNAME, meta.getUriField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_EXTENSION_FIELDNAME, meta.getExtensionField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_SIZE_FIELDNAME, meta.getSizeField()));
    result.add(StepInjectionUtil.getEntry(Entry.SKIP_BAD_FILES, meta.isSkipBadFiles()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_ERROR_FIELD, meta.getFileErrorField()));
    result.add(StepInjectionUtil.getEntry(Entry.FILE_ERROR_MESSAGE_FIELD, meta.getFileErrorMessageField()));
    result.add(StepInjectionUtil.getEntry(Entry.IGNORE_ERRORS, meta.isErrorIgnored()));
    result.add(StepInjectionUtil.getEntry(Entry.ERROR_COUNT_FIELD, meta.getErrorCountField()));
    result.add(StepInjectionUtil.getEntry(Entry.ERROR_FIELDS_FIELD, meta.getErrorFieldsField()));
    result.add(StepInjectionUtil.getEntry(Entry.ERROR_TEXT_FIELD, meta.getErrorTextField()));
    result.add(StepInjectionUtil.getEntry(Entry.WARNING_FILES_TARGET_DIR, meta.getWarningFilesDestinationDirectory()));
    result.add(StepInjectionUtil.getEntry(Entry.WARNING_FILES_EXTENTION, meta.getWarningFilesExtension()));
    result.add(StepInjectionUtil.getEntry(Entry.ERROR_FILES_TARGET_DIR, meta.getErrorFilesDestinationDirectory()));
    result.add(StepInjectionUtil.getEntry(Entry.ERROR_FILES_EXTENTION, meta.getErrorLineFilesExtension()));
    result.add(StepInjectionUtil.getEntry(Entry.LINE_NR_FILES_TARGET_DIR, meta.getLineNumberFilesDestinationDirectory()));
    result.add(StepInjectionUtil.getEntry(Entry.LINE_NR_FILES_EXTENTION, meta.getLineNumberFilesExtension()));
    result.add(StepInjectionUtil.getEntry(Entry.ERROR_LINES_SKIPPED, meta.isErrorLineSkipped()));
    StepInjectionMetaEntry filenameLinesEntry = StepInjectionUtil.getEntry(Entry.FILENAME_LINES);
    if (!Utils.isEmpty(meta.getFileName())) {
        for (int i = 0, len = meta.getFileName().length; i < len; i++) {
            StepInjectionMetaEntry filenameLineEntry = StepInjectionUtil.getEntry(Entry.FILENAME_LINE);
            filenameLinesEntry.getDetails().add(filenameLineEntry);
            List<StepInjectionMetaEntry> filenameLineEntryDetails = filenameLineEntry.getDetails();
            filenameLineEntryDetails.add(StepInjectionUtil.getEntry(Entry.FILENAME, meta.getFileName()[i]));
            filenameLineEntryDetails.add(StepInjectionUtil.getEntry(Entry.FILEMASK, meta.getFileMask()[i]));
            filenameLineEntryDetails.add(StepInjectionUtil.getEntry(Entry.EXCLUDE_FILEMASK, meta.getExludeFileMask()[i]));
            filenameLineEntryDetails.add(StepInjectionUtil.getEntry(Entry.FILE_REQUIRED, meta.getFileRequired()[i]));
            filenameLineEntryDetails.add(StepInjectionUtil.getEntry(Entry.INCLUDE_SUBFOLDERS, meta.getIncludeSubFolders()[i]));
        }
    }
    result.add(filenameLinesEntry);
    StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry(Entry.FIELDS);
    if (!Utils.isEmpty(meta.getInputFields())) {
        for (TextFileInputField inputField : meta.getInputFields()) {
            StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry(Entry.FIELD);
            fieldsEntry.getDetails().add(fieldEntry);
            List<StepInjectionMetaEntry> fieldDetails = fieldEntry.getDetails();
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD, inputField.getName()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_POSITION, inputField.getPosition()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_LENGTH, inputField.getLength()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_TYPE, inputField.getType()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_IGNORE, inputField.isIgnored()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_FORMAT, inputField.getFormat()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_TRIM_TYPE, inputField.getTrimType()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_PRECISION, inputField.getPrecision()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_DECIMAL, inputField.getDecimalSymbol()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_GROUP, inputField.getGroupSymbol()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_CURRENCY, inputField.getCurrencySymbol()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_REPEAT, inputField.isRepeated()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_NULL_STRING, inputField.getNullString()));
            fieldDetails.add(StepInjectionUtil.getEntry(Entry.FIELD_IF_NULL, inputField.getIfNullValue()));
        }
    }
    result.add(fieldsEntry);
    return result;
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList)

Example 34 with StepInjectionMetaEntry

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

the class TableOutputMetaInjection method extractStepMetadataEntries.

public List<StepInjectionMetaEntry> extractStepMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> list = new ArrayList<StepInjectionMetaEntry>();
    list.add(StepInjectionUtil.getEntry(Entry.TARGET_SCHEMA, meta.getSchemaName()));
    list.add(StepInjectionUtil.getEntry(Entry.TARGET_TABLE, meta.getTableName()));
    list.add(StepInjectionUtil.getEntry(Entry.COMMIT_SIZE, meta.getCommitSize()));
    list.add(StepInjectionUtil.getEntry(Entry.TRUNCATE_TABLE, meta.truncateTable()));
    list.add(StepInjectionUtil.getEntry(Entry.SPECIFY_DATABASE_FIELDS, meta.specifyFields()));
    list.add(StepInjectionUtil.getEntry(Entry.IGNORE_INSERT_ERRORS, meta.ignoreErrors()));
    list.add(StepInjectionUtil.getEntry(Entry.USE_BATCH_UPDATE, meta.useBatchUpdate()));
    list.add(StepInjectionUtil.getEntry(Entry.PARTITION_OVER_TABLES, meta.isPartitioningEnabled()));
    list.add(StepInjectionUtil.getEntry(Entry.PARTITIONING_FIELD, meta.getPartitioningField()));
    list.add(StepInjectionUtil.getEntry(Entry.PARTITION_DATA_PER, meta.isPartitioningDaily() ? "DAY" : meta.isPartitioningMonthly() ? "MONTH" : ""));
    list.add(StepInjectionUtil.getEntry(Entry.TABLE_NAME_DEFINED_IN_FIELD, meta.isTableNameInField()));
    list.add(StepInjectionUtil.getEntry(Entry.TABLE_NAME_FIELD, meta.getTableNameField()));
    list.add(StepInjectionUtil.getEntry(Entry.STORE_TABLE_NAME, meta.isTableNameInTable()));
    list.add(StepInjectionUtil.getEntry(Entry.RETURN_AUTO_GENERATED_KEY, meta.isReturningGeneratedKeys()));
    list.add(StepInjectionUtil.getEntry(Entry.AUTO_GENERATED_KEY_FIELD, meta.getGeneratedKeyField()));
    StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry(Entry.DATABASE_FIELDS);
    list.add(fieldsEntry);
    for (int i = 0; i < meta.getFieldDatabase().length; i++) {
        StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry(Entry.DATABASE_FIELD);
        List<StepInjectionMetaEntry> details = fieldEntry.getDetails();
        details.add(StepInjectionUtil.getEntry(Entry.DATABASE_FIELDNAME, meta.getFieldDatabase()[i]));
        details.add(StepInjectionUtil.getEntry(Entry.STREAM_FIELDNAME, meta.getFieldStream()[i]));
        fieldsEntry.getDetails().add(fieldEntry);
    }
    return list;
}
Also used : StepInjectionMetaEntry(org.pentaho.di.trans.step.StepInjectionMetaEntry) ArrayList(java.util.ArrayList)

Example 35 with StepInjectionMetaEntry

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

the class TableOutputMetaInjection method getStepInjectionMetadataEntries.

@Override
public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException {
    List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>();
    Entry[] topEntries = new Entry[] { Entry.TARGET_SCHEMA, Entry.TARGET_TABLE, Entry.COMMIT_SIZE, Entry.TRUNCATE_TABLE, Entry.SPECIFY_DATABASE_FIELDS, Entry.IGNORE_INSERT_ERRORS, Entry.USE_BATCH_UPDATE, Entry.PARTITION_OVER_TABLES, Entry.PARTITIONING_FIELD, Entry.PARTITION_DATA_PER, Entry.TABLE_NAME_DEFINED_IN_FIELD, Entry.TABLE_NAME_FIELD, Entry.STORE_TABLE_NAME, Entry.RETURN_AUTO_GENERATED_KEY, Entry.AUTO_GENERATED_KEY_FIELD };
    for (Entry topEntry : topEntries) {
        all.add(new StepInjectionMetaEntry(topEntry.name(), topEntry.getValueType(), topEntry.getDescription()));
    }
    // The fields
    // 
    StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry(Entry.DATABASE_FIELDS.name(), ValueMetaInterface.TYPE_NONE, Entry.DATABASE_FIELDS.description);
    all.add(fieldsEntry);
    StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry(Entry.DATABASE_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.DATABASE_FIELD.description);
    fieldsEntry.getDetails().add(fieldEntry);
    Entry[] fieldsEntries = new Entry[] { Entry.DATABASE_FIELDNAME, Entry.STREAM_FIELDNAME };
    for (Entry entry : fieldsEntries) {
        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