Search in sources :

Example 6 with IOConnection

use of org.talend.designer.dbmap.external.connection.IOConnection 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 7 with IOConnection

use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.

the class TableManager method getPhysicalInputTableNames.

/**
     * DOC amaumont Comment method "getPhysicalTableNames".
     */
public String[] getPhysicalInputTableNames() {
    List<IOConnection> inputConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
    ArrayList<String> names = new ArrayList<String>();
    for (IOConnection connection : inputConnections) {
        String name = connection.getName();
        if (name != null) {
            names.add(name);
        }
    }
    return names.toArray(new String[0]);
}
Also used : IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ArrayList(java.util.ArrayList)

Example 8 with IOConnection

use of org.talend.designer.dbmap.external.connection.IOConnection in project tdi-studio-se by Talend.

the class MapperManager method addInputAliasTable.

/**
     * DOC amaumont Comment method "addAlias".
     */
public void addInputAliasTable() {
    AliasDialog aliasDialog = new AliasDialog(this, tableManager.getPhysicalInputTableNames(), tableManager.getAliases(), tableManager.getVisibleTables());
    if (!aliasDialog.open()) {
        return;
    }
    List<IOConnection> incomingConnections = getComponent().getMapperMain().getIoInputConnections();
    IOConnection connectionFound = null;
    for (IOConnection connection : incomingConnections) {
        if (connection.getName().equalsIgnoreCase(aliasDialog.getTableName())) {
            connectionFound = connection;
            break;
        }
    }
    List<DataMapTableView> inputsTablesView = getUiManager().getInputsTablesView();
    int sizeOutputsView = inputsTablesView.size();
    Control lastChild = null;
    if (sizeOutputsView - 1 >= 0) {
        lastChild = inputsTablesView.get(sizeOutputsView - 1);
    }
    String alias = aliasDialog.getAlias();
    //$NON-NLS-1$
    boolean isPhysicalTable = alias.equals("") || alias.equalsIgnoreCase(aliasDialog.getTableName());
    String aliasOrTableName = isPhysicalTable ? aliasDialog.getTableName() : alias;
    IMetadataTable metadataTable = isPhysicalTable ? connectionFound.getTable() : connectionFound.getTable().clone();
    boolean isInvisiblePhysicalTable = aliasDialog.isSameAsPhysicalTable(aliasOrTableName) && !aliasDialog.isSameAsVisibleTableName(aliasOrTableName);
    InputTable inputTable = new InputTable(this, metadataTable, aliasOrTableName);
    if (isInvisiblePhysicalTable) {
        inputTable.setAlias(null);
    } else {
        inputTable.setAlias(aliasOrTableName);
    }
    inputTable.setTableName(aliasDialog.getTableName());
    inputTable.initFromExternalData(null);
    TablesZoneView tablesZoneViewInputs = uiManager.getTablesZoneViewInputs();
    DataMapTableView dataMapTableView = uiManager.createNewInputTableView(lastChild, inputTable, tablesZoneViewInputs);
    tablesZoneViewInputs.setSize(tablesZoneViewInputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewInputs.layout(true, true);
    uiManager.moveInputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    tablesZoneViewInputs.layout();
    uiManager.selectDataMapTableView(dataMapTableView, true, false);
    uiManager.updateDropDownJoinTypeForInputs();
    uiManager.parseAllExpressionsForAllTables();
    uiManager.refreshSqlExpression();
    getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) Control(org.eclipse.swt.widgets.Control) AliasDialog(org.talend.designer.dbmap.ui.dialog.AliasDialog) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) 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) TablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView)

Aggregations

IOConnection (org.talend.designer.dbmap.external.connection.IOConnection)8 ArrayList (java.util.ArrayList)4 InputTable (org.talend.designer.dbmap.model.table.InputTable)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)3 HashMap (java.util.HashMap)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)2 ExternalDbMapTable (org.talend.designer.dbmap.external.data.ExternalDbMapTable)2 AbstractInOutTable (org.talend.designer.dbmap.model.table.AbstractInOutTable)2 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)2 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)2 List (java.util.List)1 Control (org.eclipse.swt.widgets.Control)1 IODataComponent (org.talend.core.model.components.IODataComponent)1 IConnection (org.talend.core.model.process.IConnection)1 Problem (org.talend.core.model.process.Problem)1 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)1 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)1