Search in sources :

Example 16 with IColumnEntry

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

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry 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 18 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) {
        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.dbmap.model.tableentry.OutputColumnTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Example 19 with IColumnEntry

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

the class MapperManager method findUniqueLocation.

public TableEntryLocation findUniqueLocation(final TableEntryLocation proposedLocation, IDataMapTable table) {
    TableEntryLocation tableEntryLocation = new TableEntryLocation(proposedLocation);
    int counter = 1;
    boolean exists = true;
    while (exists) {
        boolean found = false;
        if (table != null) {
            for (IColumnEntry entry : table.getColumnEntries()) {
                // TDI-26953: drag-and-drop column name should case-sensitive
                if (entry.getName().equalsIgnoreCase(tableEntryLocation.columnName)) {
                    found = true;
                    break;
                }
            }
        }
        exists = found;
        if (!exists) {
            break;
        }
        //$NON-NLS-1$
        tableEntryLocation.columnName = proposedLocation.columnName + "_" + counter++;
    }
    return tableEntryLocation;
}
Also used : TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry)

Example 20 with IColumnEntry

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

the class ProblemsAnalyser method checkKeysProblems.

/**
     * DOC amaumont Comment method "checkKeysProblems".
     * 
     * @param incomingConnections
     * @param inputTables
     */
private void checkKeysProblems(ArrayList<InputTable> inputTables) {
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    if (!mapperManager.isAdvancedMap()) {
        for (InputTable table : inputTables) {
            if (table.isMainConnection()) {
                continue;
            }
            String tableName = table.getName();
            List<IColumnEntry> columnEntries = table.getColumnEntries();
            for (IColumnEntry entry : columnEntries) {
                InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
                String columnName = entry.getName();
                if (mapperManager.checkEntryHasInvalidUncheckedKey(inputEntry)) {
                    String description = //$NON-NLS-1$
                    "Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
                    " input entry should be checked or expression should be removed. ";
                    addProblem(new Problem(null, description, ProblemStatus.WARNING));
                }
                if (mapperManager.checkEntryHasInvalidCheckedKey(inputEntry)) {
                    String description = //$NON-NLS-1$
                    "Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
                    " input entry should be unchecked or expression should be filled. ";
                    addProblem(new Problem(null, description, ProblemStatus.WARNING));
                }
            }
        }
    }
}
Also used : ILanguage(org.talend.designer.mapper.language.ILanguage) InputTable(org.talend.designer.mapper.model.table.InputTable) Problem(org.talend.core.model.process.Problem) 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