Search in sources :

Example 26 with IDataMapTable

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

the class UIManager method processColumnNameChanged.

/**
     * DOC amaumont Comment method "processNewProcessColumnName".
     * 
     * @param previousColumnName TODO
     * @param dataMapTableView
     * @param renamingDependentEntries TODO
     * @param text
     * @param entry
     */
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry, boolean renamingDependentEntries) {
    mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
    Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
    boolean atLeastOneLinkHasBeenRemoved = false;
    for (DataMapTableView view : tableViews) {
        IDataMapTable dataMapTable = view.getDataMapTable();
        List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
        for (IColumnEntry entry : metadataTableEntries) {
            if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                atLeastOneLinkHasBeenRemoved = true;
            }
        }
        if (dataMapTable instanceof OutputTable) {
            List<FilterTableEntry> constraintWhereEntries = ((OutputTable) dataMapTable).getWhereFilterEntries();
            for (FilterTableEntry entry : constraintWhereEntries) {
                if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
            List<FilterTableEntry> constraintOtherEntries = ((OutputTable) dataMapTable).getOtherFilterEntries();
            for (FilterTableEntry entry : constraintOtherEntries) {
                if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
        }
    }
    mapperManager.getUiManager().refreshBackground(false, false);
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
    TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
    TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
    mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
    refreshSqlExpression();
    if (!renamingDependentEntries) {
        AbstractInOutTable currentTable = (AbstractInOutTable) currentModifiedITableEntry.getParent();
        if (currentTable instanceof InputTable) {
            InputTable currentInputTable = (InputTable) currentTable;
            String physicalTableName = currentInputTable.getTableName();
            String alias = currentInputTable.getAlias();
            InputTable physicalInputTable = null;
            List<InputTable> inputTables = mapperManager.getInputTables();
            if (alias != null) {
                for (InputTable table : inputTables) {
                    if (table.equals(physicalTableName)) {
                        physicalInputTable = table;
                    }
                }
            } else {
                physicalInputTable = currentInputTable;
            }
            if (physicalInputTable == null) {
                List<IOConnection> incomingConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
                IOConnection connectionFound = null;
                for (IOConnection connection : incomingConnections) {
                    if (connection.getName().equals(physicalTableName)) {
                        connectionFound = connection;
                    }
                }
                IMetadataColumn metadataColumn = connectionFound.getTable().getColumn(previousColumnName);
                if (metadataColumn != null) {
                    metadataColumn.setLabel(newColumnName);
                }
            }
            for (InputTable table : inputTables) {
                if ((// Physical table parent
                alias != null && table.getAlias() == null && table.getName().equals(physicalTableName) || // Alias table
                alias == null && table.getAlias() != null && table.getTableName().equals(physicalTableName))) {
                    TableEntryLocation location = new TableEntryLocation(table.getName(), previousColumnName);
                    DataMapTableView aliasTableView = mapperManager.retrieveDataMapTableView(location);
                    ITableEntry aliasTableEntry = mapperManager.retrieveTableEntry(location);
                    if (aliasTableEntry != null) {
                        processColumnNameChanged(previousColumnName, newColumnName, aliasTableView, aliasTableEntry, true);
                    }
                }
            }
        }
    }
// if (atLeastOneLinkHasBeenRemoved) {
// new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
//
// public void run() {
// TableViewerCreator tableViewerCreatorForColumns = dataMapTableView
// .getTableViewerCreatorForColumns();
// boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(),
// Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
// Messages.getString("UIManager.propagateMessage")); //$NON-NLS-1$
// if (propagate) {
// TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), previousColumnName);
// TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), newColumnName);
// mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
// refreshSqlExpression();
// }
// }
// }).start();
// }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) 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) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation)

Example 27 with IDataMapTable

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

the class MapperManager method addNewFilterEntry.

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

Example 28 with IDataMapTable

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

the class MapperManager method replacePreviousLocationInAllExpressions.

/**
     * DOC amaumont Comment method "replacePreviousLocationInAllExpressions".
     */
public void replacePreviousLocationInAllExpressions(final TableEntryLocation previousLocation, final TableEntryLocation newLocation) {
    DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(getCurrentLanguage());
    Collection<IDataMapTable> tablesData = getTablesData();
    for (IDataMapTable table : tablesData) {
        List<IColumnEntry> columnEntries = table.getColumnEntries();
        for (IColumnEntry entry : columnEntries) {
            replaceLocation(previousLocation, newLocation, dataMapExpressionParser, table, entry);
        }
        if (table instanceof OutputTable) {
            List<FilterTableEntry> whereConstraintEntries = ((OutputTable) table).getWhereFilterEntries();
            for (FilterTableEntry entry : whereConstraintEntries) {
                replaceLocation(previousLocation, newLocation, dataMapExpressionParser, table, entry);
            }
            List<FilterTableEntry> otherConstraintEntries = ((OutputTable) table).getOtherFilterEntries();
            for (FilterTableEntry entry : otherConstraintEntries) {
                replaceLocation(previousLocation, newLocation, dataMapExpressionParser, table, entry);
            }
        }
    }
    uiManager.refreshBackground(false, false);
}
Also used : DataMapExpressionParser(org.talend.designer.dbmap.utils.DataMapExpressionParser) 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 29 with IDataMapTable

use of org.talend.designer.abstractmap.model.table.IDataMapTable 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);
    removeTablePair(tableManager.getData(view));
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable)

Example 30 with IDataMapTable

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

the class TableEntriesManager method addInternal.

/**
     * DOC amaumont Comment method "add".
     * 
     * @param dataMapTableEntry
     */
private void addInternal(ITableEntry dataMapTableEntry) {
    tableEntries.put(TableEntryLocation.getNewInstance(dataMapTableEntry), dataMapTableEntry);
    IDataMapTable dataMapTable = dataMapTableEntry.getParent();
    InputTable inputTable = isPhysicalTable(dataMapTable);
    if (inputTable != null) {
        IMetadataColumn metadataColumn = ((InputColumnTableEntry) dataMapTableEntry).getMetadataColumn();
        addMetadataColumnFromDbTable(inputTable.getTableName(), metadataColumn.getLabel(), metadataColumn);
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Aggregations

IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)39 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)14 ArrayList (java.util.ArrayList)9 OutputTable (org.talend.designer.mapper.model.table.OutputTable)8 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)7 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)5 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)5 List (java.util.List)4 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)4 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)4 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)4 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 InputTable (org.talend.designer.mapper.model.table.InputTable)4 VarsTable (org.talend.designer.mapper.model.table.VarsTable)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3