Search in sources :

Example 6 with FilterTableEntry

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

the class TableEntriesManager method retrieveTableItem.

TableItem retrieveTableItem(ITableEntry dataMapTableEntry) {
    DataMapTableView dataMapTableView = this.mapperManager.retrieveIDataMapTableView(dataMapTableEntry.getParent());
    TableItem[] tableItems = new TableItem[0];
    if (dataMapTableEntry instanceof IColumnEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
    } else if (dataMapTableEntry instanceof FilterTableEntry) {
        if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
            tableItems = dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().getItems();
        } else {
            tableItems = dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().getItems();
        }
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("TableEntriesManager.exceptionMessage.caseNotFound"));
    }
    TableItem tableItem = null;
    for (TableItem tableItem2 : tableItems) {
        if (tableItem2.getData() == dataMapTableEntry) {
            tableItem = tableItem2;
            break;
        }
    }
    getTableEntryProperties(dataMapTableEntry).setTableItem(tableItem);
    return tableItem;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry)

Example 7 with FilterTableEntry

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

the class TableEntriesManager method addTableEntry.

/**
     * DOC amaumont Comment method "addTableEntry".
     * 
     * @param dataMapTableEntry
     * @param index
     */
public void addTableEntry(ITableEntry dataMapTableEntry, Integer index) {
    if (dataMapTableEntry == null) {
        throw new IllegalArgumentException(//$NON-NLS-1$
        Messages.getString("TableEntriesManager.exceptionMessage.dataMapTableEntryCannotNull"));
    }
    addInternal(dataMapTableEntry);
    IDataMapTable dataMapTable = dataMapTableEntry.getParent();
    if (dataMapTableEntry instanceof IColumnEntry) {
        if (index == null) {
            dataMapTable.addColumnEntry((IColumnEntry) dataMapTableEntry);
        } else {
            dataMapTable.addColumnEntry((IColumnEntry) dataMapTableEntry, index);
        }
    } else if (dataMapTableEntry instanceof FilterTableEntry) {
        if (FilterTableEntry.WHERE_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
            if (index == null) {
                ((OutputTable) dataMapTable).addWhereFilterEntry((FilterTableEntry) dataMapTableEntry);
            } else {
                ((OutputTable) dataMapTable).addWhereFilterEntry((FilterTableEntry) dataMapTableEntry, index);
            }
        } else if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
            if (index == null) {
                ((OutputTable) dataMapTable).addOtherFilterEntry((FilterTableEntry) dataMapTableEntry);
            } else {
                ((OutputTable) dataMapTable).addOtherFilterEntry((FilterTableEntry) dataMapTableEntry, index);
            }
        }
    } else {
        String exceptionMessage = Messages.getString("TableEntriesManager.exceptionMessage.typeIsNotValid", //$NON-NLS-1$
        dataMapTableEntry.getClass().toString());
        throw new IllegalArgumentException(exceptionMessage);
    }
// TableEntriesManagerEvent event = new TableEntriesManagerEvent(EVENT_TYPE.ADD);
// event.entry = dataMapTableEntry;
// fireEvent(event);
}
Also used : FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 8 with FilterTableEntry

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

the class MapperManager method changeEntryExpression.

/**
     * DOC amaumont Comment method "changeEntryExpression".
     * 
     * @param currentEntry
     * @param text
     */
public void changeEntryExpression(ITableEntry currentEntry, String text) {
    currentEntry.setExpression(text);
    getProblemsManager().checkProblemsForTableEntry(currentEntry, true);
    DataMapTableView dataMapTableView = retrieveDataMapTableView(currentEntry);
    TableViewer tableViewer = null;
    if (currentEntry instanceof IColumnEntry) {
        tableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    } else if (currentEntry instanceof FilterTableEntry) {
        if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) currentEntry).getFilterKind())) {
            tableViewer = dataMapTableView.getTableViewerCreatorForOtherFilters().getTableViewer();
        } else {
            tableViewer = dataMapTableView.getTableViewerCreatorForWhereFilters().getTableViewer();
        }
    }
    if (currentEntry.getProblems() != null) {
        tableViewer.getTable().deselectAll();
    }
    tableViewer.refresh(currentEntry);
    uiManager.parseNewExpression(text, currentEntry, false);
    uiManager.refreshSqlExpression();
}
Also used : FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 9 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry 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<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);
            }
        }
    }
    // for the OutputTables
    for (OutputTable outputTable : outputTables) {
        // OutputTable Filters
        for (FilterTableEntry entry : outputTable.getWhereFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        for (FilterTableEntry entry : outputTable.getOtherFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        // OutputTable Columns
        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);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 10 with FilterTableEntry

use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry 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, ExternalDbMapTable externalMapperTable) {
    externalMapperTable.setMinimized(table.isMinimized());
    externalMapperTable.setName(table.getUniqueName());
    externalMapperTable.setTableName(table.getTableName());
    /**
         * set custom where conditions entries
         */
    ArrayList<ExternalDbMapEntry> constraintTableEntries = new ArrayList<ExternalDbMapEntry>();
    for (FilterTableEntry constraintWhereTableEntry : table.getWhereFilterEntries()) {
        ExternalDbMapEntry externalMapperTableEntry = new ExternalDbMapEntry();
        externalMapperTableEntry.setExpression(constraintWhereTableEntry.getExpression());
        externalMapperTableEntry.setName(constraintWhereTableEntry.getName());
        constraintTableEntries.add(externalMapperTableEntry);
    }
    externalMapperTable.setCustomWhereConditionsEntries(constraintTableEntries);
    /**
         * set custom other conditions entries
         */
    constraintTableEntries = new ArrayList<ExternalDbMapEntry>();
    for (FilterTableEntry constraintOtherTableEntry : table.getOtherFilterEntries()) {
        ExternalDbMapEntry externalMapperTableEntry = new ExternalDbMapEntry();
        externalMapperTableEntry.setExpression(constraintOtherTableEntry.getExpression());
        externalMapperTableEntry.setName(constraintOtherTableEntry.getName());
        constraintTableEntries.add(externalMapperTableEntry);
    }
    externalMapperTable.setCustomOtherConditionsEntries(constraintTableEntries);
    outputTables.add(externalMapperTable);
}
Also used : ArrayList(java.util.ArrayList) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry)

Aggregations

FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)16 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)11 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)5 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)5 TableViewer (org.eclipse.jface.viewers.TableViewer)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 InputTable (org.talend.designer.dbmap.model.table.InputTable)3 HashMap (java.util.HashMap)2 AbstractExtendedTableViewer (org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)2 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)2 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)2 ArrayList (java.util.ArrayList)1 ICellEditorListener (org.eclipse.jface.viewers.ICellEditorListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1