Search in sources :

Example 6 with InputColumnTableEntry

use of org.talend.designer.mapper.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.

the class LinkManager method registerLevelForNewLink.

/**
     * DOC amaumont Comment method "registerLevelForNewLink".
     * 
     * @param link
     * @param graphicalLinksFromTarget
     */
public void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
    boolean hasAlreadyInputTarget = false;
    boolean hasAlreadyVarTarget = false;
    ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = sourceEntry.getParent().getClass() == targetEntry.getParent().getClass();
    if (hasSameZone) {
        boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
        boolean isVarTarget = targetEntry instanceof VarTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInputTarget) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isVarTarget) {
            leveledLinks = getVarLinksForLevels();
        }
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
                ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
                ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
                if (targetEntry == targetTableEntry) {
                    if (sourceTableEntry instanceof InputColumnTableEntry && (targetTableEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
                        hasAlreadyInputTarget = true;
                    }
                    if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
                        hasAlreadyVarTarget = true;
                    }
                    if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
                        linksFromLevelsList.add(link);
                        link.setLevel(indexOfLeveledLink + 1);
                        break;
                    }
                }
            }
        }
        if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
            ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
            int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
            link.setLevel(firstEmptyIndex + 1);
            list.add(link);
            if (firstEmptyIndex < leveledLinks.size()) {
                leveledLinks.set(firstEmptyIndex, list);
            } else {
                leveledLinks.add(list);
            }
        }
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputTable(org.talend.designer.mapper.model.table.InputTable) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) List(java.util.List) ArrayList(java.util.ArrayList) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 7 with InputColumnTableEntry

use of org.talend.designer.mapper.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.

the class LinkManager method unregisterLevelForRemovedLink.

/**
     * DOC amaumont Comment method "unregisterLevelForRemovedLink".
     * 
     * @param link
     * @param sourceGraphicalLinks
     */
public void unregisterLevelForRemovedLink(IMapperLink link, Set<IMapperLink> sourceGraphicalLinks) {
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = link.getPointLinkDescriptor1().getTableEntry().getClass() == targetEntry.getClass();
    if (hasSameZone) {
        boolean isInput = targetEntry instanceof InputColumnTableEntry;
        boolean isVar = targetEntry instanceof VarTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInput) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isVar) {
            leveledLinks = getVarLinksForLevels();
        }
        boolean breakAll = false;
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                int lstSizeInternal = linksFromLevelsList.size();
                for (int i = 0; i < lstSizeInternal; i++) {
                    IMapperLink currentLink = linksFromLevelsList.get(i);
                    if (currentLink == link) {
                        linksFromLevelsList.remove(i);
                        if (linksFromLevelsList.size() == 0) {
                            leveledLinks.set(indexOfLeveledLink, null);
                        }
                        breakAll = true;
                        break;
                    }
                }
                // for (int i = 0; i < lstSizeInternal; i++) {
                if (breakAll) {
                    break;
                }
            }
        }
    // for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) List(java.util.List) ArrayList(java.util.ArrayList) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 8 with InputColumnTableEntry

use of org.talend.designer.mapper.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.

the class MapperManager method addNewColumnEntry.

/**
     * This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
     * want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
     * 
     * @param dataMapTableView
     * @param metadataColumn, can be null if added in VarsTable
     * @param index
     */
public IColumnEntry addNewColumnEntry(DataMapTableView dataMapTableView, IMetadataColumn metadataColumn, Integer index) {
    IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
    IColumnEntry dataMapTableEntry = null;
    if (dataMapTableView.getZone() == Zone.INPUTS) {
        dataMapTableEntry = new InputColumnTableEntry(abstractDataMapTable, metadataColumn);
    } else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
        String expression = metadataColumn.getExpression();
        if (expression != null && !"".equals(expression)) {
            dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn, expression);
        } else {
            dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn);
        }
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
    }
    tableEntriesManager.addTableEntry(dataMapTableEntry, index);
    return dataMapTableEntry;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 9 with InputColumnTableEntry

use of org.talend.designer.mapper.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.

the class UIManager method parseFilterColumn.

public ParseExpressionResult parseFilterColumn(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
    if (currentModifiedITableEntry instanceof InputColumnTableEntry) {
        InputColumnTableEntry entry = (InputColumnTableEntry) currentModifiedITableEntry;
        if (StringUtils.trimToNull(expression) == null) {
            entry.setOperator(null);
        }
    }
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
    boolean linkHasBeenAdded = false;
    boolean linkHasBeenRemoved = false;
    DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
    TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
    Set<TableEntryLocation> alreadyProcessed = new HashSet<TableEntryLocation>();
    Set<ITableEntry> sourcesForTarget = mapperManager.getSourcesForTarget(currentModifiedITableEntry);
    Set<ITableEntry> sourcesForTargetToDelete = new HashSet<ITableEntry>(sourcesForTarget);
    boolean isInputEntry = currentModifiedITableEntry instanceof InputColumnTableEntry;
    ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
    for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
        TableEntryLocation location = tableEntriesLocationsSource;
        // tests to know if link must be removed if key is unchecked
        boolean dontRemoveLink = (!isInputEntry || isInputEntry && (inputExpressionAppliedOrCanceled || !inputExpressionAppliedOrCanceled && !mapperManager.checkEntryHasInvalidUncheckedKey((InputColumnTableEntry) currentModifiedITableEntry)));
        if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry) && (mapperManager.isAdvancedMap() || !mapperManager.isAdvancedMap() && dontRemoveLink)) {
            ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
            if (sourceTableEntry != null && sourcesForTarget.contains(sourceTableEntry)) {
                Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
                Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
                for (IMapperLink link : linksFromTarget) {
                    link.calculate();
                }
            }
        }
    }
    mapperManager.orderLinks();
    if (!mapperManager.isAdvancedMap()) {
        if (dataMapTableView.getZone() == Zone.INPUTS) {
            if (linkHasBeenAdded || linkHasBeenRemoved) {
                checkTargetInputKey(currentModifiedITableEntry, checkInputKeyAutomatically, inputExpressionAppliedOrCanceled);
            }
            if (inputExpressionAppliedOrCanceled) {
                openChangeKeysDialog((InputDataMapTableView) dataMapTableView);
            }
        }
    }
    return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) ParseExpressionResult(org.talend.designer.mapper.utils.ParseExpressionResult) DataMapExpressionParser(org.talend.designer.mapper.utils.DataMapExpressionParser) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) HashSet(java.util.HashSet) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 10 with InputColumnTableEntry

use of org.talend.designer.mapper.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.

the class AbstractInOutTable method updateTableEntries.

private void updateTableEntries(List<IMetadataColumn> columns, Map<String, ExternalMapperTableEntry> nameToPerTabEntry) {
    for (IMetadataColumn column : columns) {
        AbstractInOutTableEntry columnEntry = getNewTableEntry(column);
        ExternalMapperTableEntry externalMapperTableEntry = nameToPerTabEntry.get(columnEntry.getMetadataColumn().getLabel());
        if (externalMapperTableEntry != null) {
            columnEntry.setExpression(externalMapperTableEntry.getExpression());
            if (columnEntry instanceof InputColumnTableEntry) {
                InputColumnTableEntry entry = (InputColumnTableEntry) columnEntry;
                entry.setOperator(externalMapperTableEntry.getOperator());
            }
        // mapperManager.getProblemsManager().checkProblemsForTableEntry(columnEntry, false);
        }
        dataMapTableEntries.add(columnEntry);
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Aggregations

InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)13 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)6 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 InputTable (org.talend.designer.mapper.model.table.InputTable)5 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)4 VarTableEntry (org.talend.designer.mapper.model.tableentry.VarTableEntry)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 ArrayList (java.util.ArrayList)3 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)3 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)3 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)3 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)3 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)3 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Point (org.eclipse.swt.graphics.Point)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ILanguage (org.talend.designer.mapper.language.ILanguage)2