Search in sources :

Example 11 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class DesignerMapperService method updateEntriesByMetaColumns.

private void updateEntriesByMetaColumns(String schemaId, IMetadataTable metadataTable, ExternalMapperTable table, MapperComponent component) {
    String id = table.getId();
    if (schemaId.equals(id)) {
        List<ExternalMapperTableEntry> mapperTableEntries = table.getMetadataTableEntries();
        List<ExternalMapperTableEntry> newTableEntries = new ArrayList<ExternalMapperTableEntry>();
        /* bug 21080 */
        for (ExternalMapperTableEntry oldEntry : mapperTableEntries) {
            String expression = oldEntry.getExpression();
            String columnname = oldEntry.getName();
            if (expression != null) {
                oldMappingMap.put(columnname, expression);
            }
        }
        List<IMetadataColumn> columns = metadataTable.getListColumns();
        if (columns != null) {
            for (IMetadataColumn metadataColumn : columns) {
                ExternalMapperTableEntry tableEntry = new ExternalMapperTableEntry();
                tableEntry.setName(metadataColumn.getLabel());
                tableEntry.setType(metadataColumn.getTalendType());
                tableEntry.setNullable(metadataColumn.isNullable());
                ExternalMapperTableEntry sameEntry = null;
                for (ExternalMapperTableEntry oldEntry : mapperTableEntries) {
                    if (oldEntry.getName().equals(metadataColumn.getLabel())) {
                        sameEntry = oldEntry;
                    }
                }
                if (sameEntry != null) {
                    tableEntry.setExpression(sameEntry.getExpression());
                    tableEntry.setOperator(sameEntry.getOperator());
                    String oldExpression = oldMappingMap.get(tableEntry.getName());
                    if (oldExpression != null) {
                        tableEntry.setExpression(oldExpression);
                    }
                }
                newTableEntries.add(tableEntry);
            }
        }
        mapperTableEntries.clear();
        table.setMetadataTableEntries(newTableEntries);
        final IMetadataTable mapperTabel = getMetadataTable(component, table.getName());
        if (mapperTabel != null) {
            if (mapperTabel.getListColumns() != null) {
                mapperTabel.getListColumns().clear();
                mapperTabel.getListColumns().addAll(metadataTable.getListColumns());
            } else {
                mapperTabel.setListColumns(metadataTable.getListColumns());
            }
        }
    }
    oldMappingMap.clear();
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 12 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class MapperComponent method getHashConfiguration.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.process.IHashableInputConnections#getHashConfiguration(java.lang.String)
     */
public IHashConfiguration getHashConfiguration(String connectionName) {
    IHashConfiguration hashConfigurationForMapper = null;
    ExternalMapperData externalData = (ExternalMapperData) getExternalData();
    List<ExternalMapperTable> inputTables = externalData.getInputTables();
    List<IHashableColumn> hashableColumns = new ArrayList<IHashableColumn>();
    for (ExternalMapperTable inputTable : inputTables) {
        if (inputTable.getName().equals(connectionName)) {
            List<ExternalMapperTableEntry> metadataTableEntries = inputTable.getMetadataTableEntries();
            if (metadataTableEntries != null) {
                int metadataTableEntriesListSize = metadataTableEntries.size();
                for (int i = 0; i < metadataTableEntriesListSize; i++) {
                    ExternalMapperTableEntry entry = metadataTableEntries.get(i);
                    if (entry.getExpression() != null && !entry.getExpression().trim().equals("")) {
                        //$NON-NLS-1$
                        hashableColumns.add(new HashableColumn(entry.getName(), i));
                    }
                }
            }
            IMatchingMode matchingMode = MATCHING_MODE.parse(inputTable.getMatchingMode());
            if (matchingMode == null) {
                matchingMode = MATCHING_MODE.UNIQUE_MATCH;
            }
            ILookupMode lookupMode = LOOKUP_MODE.parse(inputTable.getLookupMode());
            if (lookupMode == null) {
                lookupMode = LOOKUP_MODE.LOAD_ONCE;
            }
            //$NON-NLS-1$
            IElementParameter tempFolderElem = getElementParameter("TEMPORARY_DATA_DIRECTORY");
            // modified by wzhang to fix 7824
            String tempFolder = null;
            if (tempFolderElem != null) {
                tempFolder = (String) tempFolderElem.getValue();
            }
            if (("").equals(tempFolder)) {
                //$NON-NLS-1$ //$NON-NLS-2$
                tempFolder = (String) this.getProcess().getElementParameter("COMP_DEFAULT_FILE_DIR").getValue() + "/temp";
                tempFolder = TalendTextUtils.addQuotes(tempFolder);
            }
            //$NON-NLS-1$
            IElementParameter rowsBufferSizeElem = getElementParameter("ROWS_BUFFER_SIZE");
            String rowsBufferSize = null;
            if (rowsBufferSizeElem != null) {
                rowsBufferSize = (String) rowsBufferSizeElem.getValue();
            }
            hashConfigurationForMapper = new HashConfiguration(hashableColumns, matchingMode, inputTable.isPersistent(), tempFolder, rowsBufferSize);
            break;
        }
    }
    return hashConfigurationForMapper;
}
Also used : HashConfiguration(org.talend.core.model.process.HashConfiguration) IHashConfiguration(org.talend.core.model.process.IHashConfiguration) IHashableColumn(org.talend.core.model.process.IHashableColumn) HashableColumn(org.talend.core.model.process.HashableColumn) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ILookupMode(org.talend.core.model.process.ILookupMode) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) IHashableColumn(org.talend.core.model.process.IHashableColumn) IMatchingMode(org.talend.core.model.process.IMatchingMode) IElementParameter(org.talend.core.model.process.IElementParameter) IHashConfiguration(org.talend.core.model.process.IHashConfiguration)

Example 13 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(Collection<? extends AbstractDataMapTable> tables) {
    for (IDataMapTable table : tables) {
        ExternalMapperTable externalMapperTable = new ExternalMapperTable();
        fillExternalTable(table, externalMapperTable);
        ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
        boolean isVarTable = table instanceof VarsTable;
        boolean isInputTable = table instanceof InputTable;
        for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            if (isVarTable) {
                externalMapperTableEntry.setType(((VarTableEntry) dataMapTableEntry).getType());
                externalMapperTableEntry.setNullable(((VarTableEntry) dataMapTableEntry).isNullable());
            } else {
                externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
                externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
            }
            if (isInputTable) {
                externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
            }
            perTableEntries.add(externalMapperTableEntry);
        }
        externalMapperTable.setMetadataTableEntries(perTableEntries);
    }
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 14 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(List<? extends AbstractDataMapTable> tables, List<? extends AbstractDataMapTable> intables) {
    // for (int i = 0; i < tables.size(); i++) {
    if (tables.size() <= 0 || intables.size() <= 0) {
        return;
    }
    IDataMapTable outtable = tables.get(0);
    IDataMapTable intable = intables.get(0);
    ExternalMapperTable externalMapperTable = new ExternalMapperTable();
    fillExternalTable(outtable, externalMapperTable);
    ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
    List<IMetadataColumn> columnList = null;
    if (mapperManager != null && mapperManager.getAbstractMapComponent() != null) {
        List<? extends IConnection> connList = mapperManager.getAbstractMapComponent().getOutgoingConnections();
        if (connList != null && connList.size() >= 1) {
            List<IMetadataTable> metaList = connList.get(0).getTarget().getMetadataList();
            if (metaList != null && metaList.size() >= 1) {
                columnList = metaList.get(0).getListColumns();
            }
        }
    }
    for (ITableEntry dataMapTableEntry : intable.getColumnEntries()) {
        if (columnList != null) {
            boolean find = false;
            for (IMetadataColumn column : columnList) {
                if (dataMapTableEntry.getName().equals(column.getLabel())) {
                    find = true;
                    break;
                }
            }
            if (find) {
                ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
                externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
                externalMapperTableEntry.setName(dataMapTableEntry.getName());
                externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
                externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
                perTableEntries.add(externalMapperTableEntry);
            }
        } else {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
            externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
            perTableEntries.add(externalMapperTableEntry);
        }
    }
    externalMapperTable.setMetadataTableEntries(perTableEntries);
// }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 15 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class ExternalDataConverter method fillExternalTable.

/**
     * DOC amaumont Comment method "process".
     * 
     * @param externalMapperTable
     * @param table
     */
private void fillExternalTable(OutputTable table, ExternalMapperTable externalMapperTable) {
    fillExternalTableWithCommonsData(table, externalMapperTable);
    externalMapperTable.setReject(table.isReject());
    externalMapperTable.setRejectInnerJoin(table.isRejectInnerJoin());
    externalMapperTable.setErrorRejectTable(table.isErrorRejectTable());
    externalMapperTable.setIsJoinTableOf(table.getIsJoinTableOf());
    externalMapperTable.setActivateExpressionFilter(table.isActivateExpressionFilter());
    externalMapperTable.setActivateCondensedTool(table.isActivateCondensedTool());
    externalMapperTable.setActivateColumnNameFilter(table.isActivateColumnNameFilter());
    externalMapperTable.setExpressionFilter(table.getExpressionFilter() != null && isFilterEqualsToDefault(table.getExpressionFilter().getExpression()) ? null : table.getExpressionFilter().getExpression());
    externalMapperTable.setId(table.getId());
    if (mapperManager.isAdvancedMap()) {
        externalMapperTable.setConstraintTableEntries(null);
    } else {
        ArrayList<ExternalMapperTableEntry> constraintTableEntries = new ArrayList<ExternalMapperTableEntry>();
        for (FilterTableEntry constraintTableEntry : table.getFilterEntries()) {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(constraintTableEntry.getExpression());
            externalMapperTableEntry.setName(constraintTableEntry.getName());
            constraintTableEntries.add(externalMapperTableEntry);
        }
        externalMapperTable.setConstraintTableEntries(constraintTableEntries);
    }
    outputTables.add(externalMapperTable);
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry)

Aggregations

ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)22 ArrayList (java.util.ArrayList)15 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 AbstractInOutTableEntry (org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)3 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)3 HashMap (java.util.HashMap)2 Problem (org.talend.core.model.process.Problem)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)2 ILanguage (org.talend.designer.mapper.language.ILanguage)2 MapperTableEntry (org.talend.designer.mapper.model.emf.mapper.MapperTableEntry)2 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)2 DataMapExpressionParser (org.talend.designer.mapper.utils.DataMapExpressionParser)2 List (java.util.List)1 Pattern (org.apache.oro.text.regex.Pattern)1 PatternMatcher (org.apache.oro.text.regex.PatternMatcher)1 Perl5Matcher (org.apache.oro.text.regex.Perl5Matcher)1