Search in sources :

Example 1 with IExternalMapEntry

use of org.talend.core.model.process.node.IExternalMapEntry in project tdi-studio-se by Talend.

the class DbMapComponent method inputMetadataColumnAmountChanged.

private void inputMetadataColumnAmountChanged(IODataComponent dataComponent, IExternalNode externalNode) {
    List<ColumnNameChanged> removedMetadataColumns = dataComponent.getRemoveMetadataColumns();
    IExternalData iExternalData = externalNode.getExternalData();
    if (iExternalData == null || removedMetadataColumns == null || removedMetadataColumns.size() == 0) {
        return;
    }
    List<ExternalDbMapTable> metaTableList = (List<ExternalDbMapTable>) iExternalData.getInputTables();
    if (metaTableList == null || metaTableList.size() == 0) {
        return;
    }
    // in the eltmap, the input table name is same with it's input connection name
    String tableName = dataComponent.getName();
    if (StringUtils.isEmpty(tableName)) {
        return;
    }
    for (ExternalDbMapTable metaTable : metaTableList) {
        if (tableName.equals(metaTable.getTableName())) {
            List<IExternalMapEntry> externalMapEntryList = (List<IExternalMapEntry>) metaTable.returnTableEntries();
            if (externalMapEntryList == null || externalMapEntryList.size() == 0) {
                continue;
            }
            if (removedMetadataColumns != null && 0 < removedMetadataColumns.size()) {
                for (ColumnNameChanged removedMetadataColumn : removedMetadataColumns) {
                    if ("".equals(removedMetadataColumn.getNewName())) {
                        //$NON-NLS-1$
                        String columnName = removedMetadataColumn.getOldName();
                        for (int i = externalMapEntryList.size() - 1; 0 <= i; i--) {
                            IExternalMapEntry mapEntry = externalMapEntryList.get(i);
                            if (columnName.equals(mapEntry.getName())) {
                                externalMapEntryList.remove(i);
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IExternalData(org.talend.core.model.process.IExternalData) IExternalMapEntry(org.talend.core.model.process.node.IExternalMapEntry)

Example 2 with IExternalMapEntry

use of org.talend.core.model.process.node.IExternalMapEntry in project tdi-studio-se by Talend.

the class MapDataDelegateHelper method addAll.

private void addAll(Map<IExternalMapTable, List<IExternalMapEntry>> targetMap, Map<IExternalMapTable, List<IExternalMapEntry>> sourceMap) {
    for (IExternalMapTable table : sourceMap.keySet()) {
        List<IExternalMapEntry> tlist = targetMap.get(table);
        List<IExternalMapEntry> sList = sourceMap.get(table);
        if (sList != null) {
            if (tlist == null) {
                targetMap.put(table, sList);
            } else {
                for (IExternalMapEntry entry : sList) {
                    if (!tlist.contains(entry)) {
                        tlist.add(entry);
                    }
                }
            }
        }
    }
}
Also used : IExternalMapTable(org.talend.core.model.process.node.IExternalMapTable) IExternalMapEntry(org.talend.core.model.process.node.IExternalMapEntry)

Example 3 with IExternalMapEntry

use of org.talend.core.model.process.node.IExternalMapEntry in project tdi-studio-se by Talend.

the class MapDataDelegateHelper method getExpressionColumns.

/**
     * 
     * ggu Comment method "getExpressionColumns".
     * 
     * @param expression -> if null, will return the all table for type
     * @param types ->
     * @return
     */
public Map<IExternalMapTable, List<IExternalMapEntry>> getExpressionColumns(String expression, ExternalDataType... types) {
    Map<IExternalMapTable, List<IExternalMapEntry>> tableMap = new HashMap<IExternalMapTable, List<IExternalMapEntry>>();
    if (types != null && types.length > 0) {
        for (ExternalDataType type : types) {
            switch(type) {
                case INPUT:
                    return getExpressionColumns(getInputTables(), expression);
                case OUTPUT:
                    return getExpressionColumns(getOutputTables(), expression);
                case VAR:
                    return getExpressionColumns(getVarsTables(), expression);
                default:
            }
        }
    } else {
        addAll(tableMap, getExpressionColumns(getInputTables(), expression));
        addAll(tableMap, getExpressionColumns(getOutputTables(), expression));
        addAll(tableMap, getExpressionColumns(getVarsTables(), expression));
    }
    return tableMap;
}
Also used : ExternalDataType(org.talend.core.model.process.IExternalData.ExternalDataType) HashMap(java.util.HashMap) IExternalMapTable(org.talend.core.model.process.node.IExternalMapTable) ArrayList(java.util.ArrayList) List(java.util.List) IExternalMapEntry(org.talend.core.model.process.node.IExternalMapEntry)

Example 4 with IExternalMapEntry

use of org.talend.core.model.process.node.IExternalMapEntry in project tdi-studio-se by Talend.

the class MapperComponent method checkNeededRoutines.

@Override
public List<String> checkNeededRoutines(List<String> possibleRoutines, String additionalString) {
    List<String> routinesToAdd = new ArrayList<String>();
    for (String routine : possibleRoutines) {
        List<ExternalMapperTable> listOutput = (List<ExternalMapperTable>) this.getExternalData().getOutputTables();
        for (ExternalMapperTable outTable : listOutput) {
            List<IExternalMapEntry> listOutEntry = (List<IExternalMapEntry>) outTable.returnTableEntries();
            if (listOutEntry != null && !listOutEntry.isEmpty()) {
                for (IExternalMapEntry outEntry : listOutEntry) {
                    String expression = outEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
        }
        List<ExternalMapperTable> listInput = (List<ExternalMapperTable>) this.getExternalData().getInputTables();
        for (ExternalMapperTable inputTable : listInput) {
            List<IExternalMapEntry> listInEntry = (List<IExternalMapEntry>) inputTable.returnTableEntries();
            if (listInEntry != null && !listInEntry.isEmpty()) {
                for (IExternalMapEntry inEntry : listInEntry) {
                    String expression = inEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
        }
        List<ExternalMapperTable> listVar = (List<ExternalMapperTable>) this.getExternalData().getVarsTables();
        for (IExternalMapTable varTable : listVar) {
            List<IExternalMapEntry> listVarEntry = (List<IExternalMapEntry>) varTable.returnTableEntries();
            if (listVarEntry != null && !listVarEntry.isEmpty()) {
                for (IExternalMapEntry varEntry : listVarEntry) {
                    String expression = varEntry.getExpression();
                    if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
        }
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
            IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
            List<String> experssionFilters = service.getExpressionFilter(this.getExternalData());
            if (!experssionFilters.isEmpty()) {
                for (String experssion : experssionFilters) {
                    if (experssion != null && !routinesToAdd.contains(routine) && experssion.contains(routine + additionalString)) {
                        routinesToAdd.add(routine);
                    }
                }
            }
        }
    }
    return routinesToAdd;
}
Also used : IDesignerMapperService(org.talend.core.service.IDesignerMapperService) IExternalMapTable(org.talend.core.model.process.node.IExternalMapTable) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IExternalMapEntry(org.talend.core.model.process.node.IExternalMapEntry)

Aggregations

IExternalMapEntry (org.talend.core.model.process.node.IExternalMapEntry)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IExternalMapTable (org.talend.core.model.process.node.IExternalMapTable)3 HashMap (java.util.HashMap)1 EList (org.eclipse.emf.common.util.EList)1 ColumnNameChanged (org.talend.core.model.metadata.ColumnNameChanged)1 IExternalData (org.talend.core.model.process.IExternalData)1 ExternalDataType (org.talend.core.model.process.IExternalData.ExternalDataType)1 IDesignerMapperService (org.talend.core.service.IDesignerMapperService)1 ExternalDbMapTable (org.talend.designer.dbmap.external.data.ExternalDbMapTable)1 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)1