Search in sources :

Example 21 with ExternalMapperTableEntry

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

the class AbstractInOutTable method initFromExternalData.

@Override
protected void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    expressionFilterEntry = new ExpressionFilterEntry(this);
    tableMapSettingEntriesModel = new ExtendedTableModel<GlobalMapEntry>("Model for map setting", mapSettingEntries);
    if (externalMapperTable != null) {
        this.expressionFilterEntry.setExpression(externalMapperTable.getExpressionFilter());
        this.activateExpressionFilter = externalMapperTable.isActivateExpressionFilter();
        this.activateCondensedTool = externalMapperTable.isActivateCondensedTool();
        this.activateColumnNameFilter = externalMapperTable.isActivateColumnNameFilter();
        this.id = externalMapperTable.getId();
        this.isRepository = this.id == null ? false : true;
    }
    List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
    Map<String, ExternalMapperTableEntry> nameToPerTabEntry = new HashMap<String, ExternalMapperTableEntry>();
    if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
        for (ExternalMapperTableEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
            nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
        }
    }
    String originalTableName = null;
    if (metadataTable != null) {
        originalTableName = metadataTable.getTableName();
    }
    if (isRepository) {
        IMetadataTable table = MetadataToolHelper.getMetadataFromRepository(id);
        if (table == null) {
            this.id = null;
            this.isRepository = false;
        } else {
            this.metadataTable = table;
            this.metadataTable.setTableName(originalTableName);
        }
    }
    if (metadataTable != null) {
        columns = this.metadataTable.getListColumns();
    }
    updateTableEntries(columns, nameToPerTabEntry);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HashMap(java.util.HashMap) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 22 with ExternalMapperTableEntry

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

the class InputTable method initFromExternalData.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.mapper.model.table.AbstractInOutTable#initFromExternalData(org.talend.designer.mapper.external
     * .data.ExternalMapperTable)
     */
@Override
public void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        this.innerJoin = externalMapperTable.isInnerJoin();
        this.persistent = externalMapperTable.isPersistent();
        this.matchingMode = TMAP_MATCHING_MODE.parse(externalMapperTable.getMatchingMode());
        if (matchingMode == null) {
            if (mapperManager.isTableHasAtLeastOneHashKey(this)) {
                matchingMode = mapperManager.isMRProcess() ? TMAP_MATCHING_MODE.ALL_MATCHES : TMAP_MATCHING_MODE.UNIQUE_MATCH;
            } else {
                matchingMode = TMAP_MATCHING_MODE.ALL_ROWS;
            }
        }
        if (matchingMode == TMAP_MATCHING_MODE.LAST_MATCH) {
            matchingMode = mapperManager.isMRProcess() ? TMAP_MATCHING_MODE.ALL_MATCHES : TMAP_MATCHING_MODE.UNIQUE_MATCH;
            ;
        }
        this.lookupMode = TMAP_LOOKUP_MODE.parse(externalMapperTable.getLookupMode());
        if (lookupMode == null) {
            lookupMode = TMAP_LOOKUP_MODE.LOAD_ONCE;
        }
        List<ExternalMapperTableEntry> globalMapEntries = externalMapperTable.getGlobalMapKeysValues();
        if (globalMapEntries != null) {
            for (ExternalMapperTableEntry externalMapperTableEntry : globalMapEntries) {
                GlobalMapEntry entry = new GlobalMapEntry(this, externalMapperTableEntry.getName(), // , externalMapperTableEntry.getType());
                externalMapperTableEntry.getExpression());
                // if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                // varTableEntry.setNullable(externalMapperTableEntry.isNullable());
                // }
                addGlobalMapEntry(entry);
            }
        }
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

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