Search in sources :

Example 1 with FilterTableEntry

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

the class MapperManager method retrieveTableViewerCreator.

public TableViewerCreator retrieveTableViewerCreator(ITableEntry dataMapTableEntry) {
    DataMapTableView view = retrieveDataMapTableView(dataMapTableEntry);
    TableViewerCreator tableViewerCreator = null;
    if (view != null) {
        if (dataMapTableEntry instanceof AbstractInOutTableEntry || dataMapTableEntry instanceof VarTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForColumns();
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForFilters();
        }
    }
    return tableViewerCreator;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 2 with FilterTableEntry

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

the class MapperManager method removeTablePair.

/**
     * 
     * Remove the <code>DataMapTableView</code>-<code>DataMapTable</code> pair.
     * 
     * @param view
     */
public void removeTablePair(DataMapTableView view) {
    IDataMapTable dataTable = tableManager.getData(view);
    List<IColumnEntry> dataMapTableEntries = dataTable.getColumnEntries();
    if (isAdvancedMap() && dataTable instanceof AbstractInOutTable) {
        tableEntriesManager.removeAll(Arrays.asList(((AbstractInOutTable) dataTable).getExpressionFilter()));
    }
    tableEntriesManager.removeAll(dataMapTableEntries);
    if (dataTable instanceof OutputTable) {
        List<FilterTableEntry> constraintEntries = ((OutputTable) dataTable).getFilterEntries();
        tableEntriesManager.removeAll(constraintEntries);
    }
    tableManager.removeTable(view);
}
Also used : AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 3 with FilterTableEntry

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

the class MapperManager method addNewFilterEntry.

public FilterTableEntry addNewFilterEntry(DataMapTableView dataMapTableView, String name, Integer index) {
    IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
    FilterTableEntry constraintEntry = new FilterTableEntry(abstractDataMapTable, name, null);
    tableEntriesManager.addTableEntry(constraintEntry, index);
    return constraintEntry;
}
Also used : FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable)

Example 4 with FilterTableEntry

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

the class MapperManager method replaceLocation.

/**
     * 
     * DOC amaumont Comment method "replaceLocation".
     * 
     * @param previousLocation
     * @param newLocation
     * @param dataMapExpressionParser
     * @param table
     * @param entry
     * @return true if expression of entry has changed
     */
private boolean replaceLocation(final TableEntryLocation previousLocation, final TableEntryLocation newLocation, DataMapExpressionParser dataMapExpressionParser, IDataMapTable table, ITableEntry entry) {
    if (entry.getExpression() == null || entry.getExpression().trim().length() == 0) {
        return false;
    }
    boolean expressionHasChanged = false;
    String currentExpression = entry.getExpression();
    TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(currentExpression);
    // loop on all locations of current expression
    for (TableEntryLocation currentLocation : tableEntryLocations) {
        if (currentLocation.equals(previousLocation)) {
            currentExpression = dataMapExpressionParser.replaceLocation(currentExpression, previousLocation, newLocation);
            expressionHasChanged = true;
        }
    }
    if (expressionHasChanged) {
        entry.setExpression(currentExpression);
        DataMapTableView dataMapTableView = retrieveAbstractDataMapTableView(table);
        TableViewerCreator tableViewerCreator = null;
        if (entry instanceof IColumnEntry || entry instanceof FilterTableEntry) {
            if (entry instanceof IColumnEntry) {
                tableViewerCreator = dataMapTableView.getTableViewerCreatorForColumns();
            } else if (entry instanceof FilterTableEntry) {
                tableViewerCreator = dataMapTableView.getTableViewerCreatorForFilters();
            }
            tableViewerCreator.getTableViewer().refresh(entry);
        } else if (entry instanceof ExpressionFilterEntry) {
            dataMapTableView.getExpressionFilterText().setText(currentExpression);
        }
        uiManager.parseExpression(currentExpression, entry, false, true, false);
        return true;
    }
    return false;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)

Example 5 with FilterTableEntry

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

the class OutputTable method initFromExternalData.

public void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        this.reject = externalMapperTable.isReject();
        this.rejectInnerJoin = externalMapperTable.isRejectInnerJoin();
        this.isJoinTableOf = externalMapperTable.getIsJoinTableOf();
        this.isErrorRejectTable = externalMapperTable.isErrorRejectTable();
        List<ExternalMapperTableEntry> externalConstraintTableEntries = externalMapperTable.getConstraintTableEntries();
        if (externalConstraintTableEntries != null) {
            if (!mapperManager.isAdvancedMap()) {
                for (ExternalMapperTableEntry entry : externalConstraintTableEntries) {
                    FilterTableEntry filterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression());
                    // mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
                    addFilterEntry(filterTableEntry);
                }
            } else {
                ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
                JavaGenerationManager javaGenerationManager = new JavaGenerationManager(currentLanguage);
                DataMapExpressionParser expressionParser = new DataMapExpressionParser(currentLanguage);
                String expressionFilter = javaGenerationManager.buildConditions(externalConstraintTableEntries, expressionParser);
                if (!expressionFilter.trim().equals("")) {
                    //$NON-NLS-1$
                    this.getExpressionFilter().setExpression(expressionFilter);
                    this.setActivateExpressionFilter(true);
                }
            }
        }
    }
}
Also used : ILanguage(org.talend.designer.mapper.language.ILanguage) JavaGenerationManager(org.talend.designer.mapper.language.generation.JavaGenerationManager) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) DataMapExpressionParser(org.talend.designer.mapper.utils.DataMapExpressionParser) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry)

Aggregations

FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)17 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)7 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)7 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 TableItem (org.eclipse.swt.widgets.TableItem)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 ArrayList (java.util.ArrayList)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Color (org.eclipse.swt.graphics.Color)2 Point (org.eclipse.swt.graphics.Point)2 Table (org.eclipse.swt.widgets.Table)2 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)2 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1