Search in sources :

Example 26 with IColumnEntry

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

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
    if (searchValue.equals("")) {
        uiManager.unselectAllEntriesOfAllTables();
        return;
    }
    // SearchPattern
    matcher.setPattern("*" + searchValue.trim() + "*");
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<VarsTable> varsTables = mapperManager.getVarsTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    int index = -1;
    // for the InputTables
    for (InputTable inputTable : inputTables) {
        for (IColumnEntry column : inputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
        // ExpressionFilter
        ExpressionFilterEntry expressionFilterEntry = inputTable.getExpressionFilter();
        if (expressionFilterEntry.getExpression() != null && matcher.matches(expressionFilterEntry.getExpression())) {
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            map.put(0, expressionFilterEntry);
            index++;
            searchMaps.put(index, map);
        }
    }
    // for the VarsTables
    for (VarsTable varsTable : varsTables) {
        for (IColumnEntry column : varsTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
    // for the OutputTables
    for (OutputTable outputTable : outputTables) {
        for (IColumnEntry column : outputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
        // ExpressionFilter
        ExpressionFilterEntry expressionFilterEntry = outputTable.getExpressionFilter();
        if (expressionFilterEntry.getExpression() != null && matcher.matches(expressionFilterEntry.getExpression())) {
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            map.put(0, expressionFilterEntry);
            index++;
            searchMaps.put(index, map);
        }
    }
}
Also used : VarsTable(org.talend.designer.mapper.model.table.VarsTable) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)

Example 27 with IColumnEntry

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

the class AutoMapper method map.

/**
     * DOC amaumont Comment method "map".
     */
public void map() {
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    IDbLanguage currentLanguage = mapperManager.getCurrentLanguage();
    HashMap<String, InputTable> nameToInputTable = new HashMap<String, InputTable>(inputTables.size());
    for (InputTable inputTable : inputTables) {
        nameToInputTable.put(inputTable.getName(), inputTable);
    }
    // output tables are the references
    for (OutputTable outputTable : outputTables) {
        List<IColumnEntry> outputEntries = outputTable.getColumnEntries();
        boolean mapFound = false;
        for (IColumnEntry outputEntry : outputEntries) {
            mapFound = false;
            if (mapperManager.checkEntryHasEmptyExpression(outputEntry)) {
                String outputColumnName = outputEntry.getName();
                for (InputTable inputTable : inputTables) {
                    List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
                    for (IColumnEntry inputEntry : inputColumnEntries) {
                        if (inputEntry.getName().equalsIgnoreCase(outputColumnName)) {
                            outputEntry.setExpression(currentLanguage.getLocation(inputTable.getName(), inputEntry.getName()));
                            mapFound = true;
                            break;
                        }
                    }
                    if (mapFound) {
                        break;
                    }
                }
            }
        }
        DataMapTableView view = mapperManager.retrieveIDataMapTableView(outputTable);
        view.getTableViewerCreatorForColumns().getTableViewer().refresh();
    }
    mapperManager.getProblemsManager().checkProblems();
    List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
    for (DataMapTableView view : outputsTablesView) {
        mapperManager.getUiManager().parseAllExpressions(view, true);
        mapperManager.getProblemsManager().checkProblemsForAllEntries(view, true);
    }
    mapperManager.getUiManager().refreshBackground(true, false);
}
Also used : HashMap(java.util.HashMap) IDbLanguage(org.talend.designer.dbmap.language.IDbLanguage) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable)

Example 28 with IColumnEntry

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

the class CompleteDropTargetListener method updateExpressionsOfInsertedEntries.

/**
     * DOC amaumont Comment method "updateExpressionsOfInsertedEntries".
     * 
     * @param uiManager
     * @param currentLanguage
     * @param metadataEditorView
     * @param currentIndex
     * @param sourceEntriesOfEntriesBeingAdded
     * @param targetTableIsConstraintsTable
     * @param tableViewerCreatorTarget
     * @param metadataColumnsBeingAdded
     * @param metadataEditorEvent
     */
@SuppressWarnings("unchecked")
private void updateExpressionsOfInsertedEntries(IDbLanguage currentLanguage, MetadataTableEditorView metadataEditorView, int currentIndex, ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded, boolean targetTableIsConstraintsTable, TableViewerCreator tableViewerCreatorTarget, ArrayList<IMetadataColumn> metadataColumnsBeingAdded) // , MetadataEditorEvent metadataEditorEvent
{
    UIManager uiManager = getUiManager();
    if (metadataEditorView != null && !targetTableIsConstraintsTable) {
        metadataEditorView.getMetadataTableEditor().addAll(currentIndex, metadataColumnsBeingAdded);
        // metadataEditorEvent.indexStartInsert = currentIndex;
        // IAction action = MetadataEditorActionFactory.getInstance().getAction(metadataEditorView,
        // metadataEditorEvent);
        // action.run(metadataEditorEvent);
        Zone zoneTarget = getMapperManager().retrieveDataMapTableView(tableViewerCreatorTarget.getTable()).getZone();
        List<IColumnEntry> lastCreatedTableEntries = uiManager.getLastCreatedInOutColumnEntries();
        for (int i = 0; i < lastCreatedTableEntries.size(); i++) {
            ITableEntry tableEntrySource = sourceEntriesOfEntriesBeingAdded.get(i);
            ITableEntry dataMapTableEntry = lastCreatedTableEntries.get(i);
            if (zoneTarget == Zone.INPUTS) {
                setDefaultOperator((InputColumnTableEntry) dataMapTableEntry);
            }
            DataMapTableView dataMapTableView = getMapperManager().retrieveIDataMapTableView(tableEntrySource.getParent());
            Zone zoneSource = dataMapTableView.getZone();
            String location = null;
            if (zoneSource == Zone.OUTPUTS) {
                location = tableEntrySource.getExpression();
            } else {
                location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
            }
            if (location != null) {
                //$NON-NLS-1$
                dataMapTableEntry.setExpression(location + " ");
            }
        }
    }
    tableViewerCreatorTarget.getTableViewer().refresh();
    List<ITableEntry> refreshedTableEntriesList = tableViewerCreatorTarget.getInputList();
    for (ITableEntry tableEntry : refreshedTableEntriesList) {
        uiManager.parseExpression(tableEntry.getExpression(), tableEntry, false, true, false);
    }
}
Also used : Zone(org.talend.designer.dbmap.ui.visualmap.zone.Zone) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.dbmap.managers.UIManager) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) Point(org.eclipse.swt.graphics.Point)

Example 29 with IColumnEntry

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

the class DataMapTableView method unselectAllEntriesIfErrorDetected.

/**
     * DOC amaumont Comment method "unselectAllEntriesIfErrorDetected".
     * 
     * @param e
     */
protected void unselectAllEntriesIfErrorDetected(TableCellValueModifiedEvent e) {
    if (e.column.getId().equals(ID_EXPRESSION_COLUMN)) {
        ITableEntry currentEntry = (ITableEntry) e.bean;
        TableViewer tableViewer = null;
        if (currentEntry instanceof IColumnEntry) {
            tableViewer = DataMapTableView.this.getTableViewerCreatorForColumns().getTableViewer();
        } else if (currentEntry instanceof FilterTableEntry) {
            if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) currentEntry).getFilterKind())) {
                tableViewer = entendedTableViewerForOtherClauses.getTableViewerCreator().getTableViewer();
            } else {
                tableViewer = extendedTableViewerForFilters.getTableViewerCreator().getTableViewer();
            }
        }
        if (currentEntry.getProblems() != null) {
            tableViewer.getTable().deselectAll();
        }
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 30 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry 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)

Aggregations

IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)42 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)16 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)10 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)10 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)9 InputTable (org.talend.designer.mapper.model.table.InputTable)8 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)8 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 TableViewer (org.eclipse.jface.viewers.TableViewer)6 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)5 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4