Search in sources :

Example 11 with InputTable

use of org.talend.designer.dbmap.model.table.InputTable 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)

Example 12 with InputTable

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

the class TableEntriesManager method renameEntryName.

/**
     * DOC amaumont Comment method "renameEntryName".
     * 
     * @param dataMapTableEntry
     * @param newColumnName
     * @param newColumnName
     */
public void renameEntryName(ITableEntry dataMapTableEntry, String previousColumnName, String newColumnName) {
    TableEntryLocation tableEntryLocationKey = new TableEntryLocation(dataMapTableEntry.getParentName(), previousColumnName);
    // TableEntriesManager.buildLocation(dataMapTableEntry);
    ITableEntry entry = tableEntries.get(tableEntryLocationKey);
    if (entry != dataMapTableEntry) {
        //$NON-NLS-1$
        throw new IllegalStateException(Messages.getString("TableEntriesManager.exceptionMessage.tableEntriesNotSame"));
    }
    tableEntries.remove(tableEntryLocationKey);
    tableEntryLocationKey.columnName = newColumnName;
    tableEntries.put(tableEntryLocationKey, dataMapTableEntry);
    // update matching column
    IMetadataColumn metadataColumn = null;
    InputTable inputTable = isPhysicalTable(dataMapTableEntry.getParent());
    if (inputTable != null) {
        metadataColumn = getColumnFromDbTable(inputTable.getName(), dataMapTableEntry.getName());
        removeMetadataColumnFromDbTable(inputTable.getTableName(), dataMapTableEntry.getName());
        addMetadataColumnFromDbTable(inputTable.getTableName(), newColumnName, metadataColumn);
    }
    dataMapTableEntry.setName(newColumnName);
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 13 with InputTable

use of org.talend.designer.dbmap.model.table.InputTable 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)

Example 14 with InputTable

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

the class DropContextAnalyzer method checkDropIsValid.

/**
     * DOC amaumont Comment method "checkDropHasValidTarget".
     */
private boolean checkDropIsValid() {
    isInputToInput = false;
    mapOneToOneAuthorized = true;
    if (targetTableIsFiltersTable() || draggedData.getTransferableEntryList().size() <= 1) {
        mapOneToOneAuthorized = false;
    }
    if (invalidKeyPressed) {
        return false;
    }
    /*
         * INPUT => INPUT
         */
    if (zoneSource == Zone.INPUTS && zoneTarget == Zone.INPUTS) {
        isInputToInput = true;
        mapOneToOneAuthorized = false;
        List<InputTable> inputTables = mapperManager.getInputTables();
        int indexSourceInputTable = inputTables.indexOf(dataMapTableViewSource.getDataMapTable());
        int indexTargetInputTable = inputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
        if (indexSourceInputTable == indexTargetInputTable) {
            return false;
        } else {
            return true;
        }
    }
    /*
         * OUTPUT => OUTPUT
         */
    if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
        isOutputToOutput = true;
        mapOneToOneAuthorized = true;
        List<OutputTable> outputTables = mapperManager.getOutputTables();
        int indexSourceOutputTable = outputTables.indexOf(dataMapTableViewSource.getDataMapTable());
        int indexTargetOutputTable = outputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
        if (indexSourceOutputTable == indexTargetOutputTable) {
            return false;
        } else {
            return true;
        }
    }
    TableItem tableItemTarget = getTableItemFromPosition(new Point(event.x, event.y));
    if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.INPUTS) {
        /*
             * OUTPUT => OUTPUT OUTPUT => INPUT
             */
        return false;
    }
    return true;
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 15 with InputTable

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

the class AutoMapper method map.

/**
     * DOC amaumont Comment method "map".
     */
public void map() {
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    IDbLanguage currentLanguage = mapperManager.getCurrentLanguage();
    HashMap<String, InputTable> nameToInputTable = new HashMap<String, InputTable>(inputTables.size());
    for (InputTable inputTable : inputTables) {
        nameToInputTable.put(inputTable.getName(), inputTable);
    }
    // output tables are the references
    for (OutputTable outputTable : outputTables) {
        List<IColumnEntry> outputEntries = outputTable.getColumnEntries();
        boolean mapFound = false;
        for (IColumnEntry outputEntry : outputEntries) {
            mapFound = false;
            if (mapperManager.checkEntryHasEmptyExpression(outputEntry)) {
                String outputColumnName = outputEntry.getName();
                for (InputTable inputTable : inputTables) {
                    List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
                    for (IColumnEntry inputEntry : inputColumnEntries) {
                        if (inputEntry.getName().equalsIgnoreCase(outputColumnName)) {
                            outputEntry.setExpression(currentLanguage.getLocation(inputTable.getName(), inputEntry.getName()));
                            mapFound = true;
                            break;
                        }
                    }
                    if (mapFound) {
                        break;
                    }
                }
            }
        }
        DataMapTableView view = mapperManager.retrieveIDataMapTableView(outputTable);
        view.getTableViewerCreatorForColumns().getTableViewer().refresh();
    }
    mapperManager.getProblemsManager().checkProblems();
    List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
    for (DataMapTableView view : outputsTablesView) {
        mapperManager.getUiManager().parseAllExpressions(view, true);
        mapperManager.getProblemsManager().checkProblemsForAllEntries(view, true);
    }
    mapperManager.getUiManager().refreshBackground(true, false);
}
Also used : HashMap(java.util.HashMap) IDbLanguage(org.talend.designer.dbmap.language.IDbLanguage) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable)

Aggregations

InputTable (org.talend.designer.dbmap.model.table.InputTable)18 ArrayList (java.util.ArrayList)7 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)7 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)5 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)5 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)4 IOConnection (org.talend.designer.dbmap.external.connection.IOConnection)4 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)4 HashMap (java.util.HashMap)3 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)3 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)3 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 GridData (org.eclipse.swt.layout.GridData)2 Control (org.eclipse.swt.widgets.Control)2 TableItem (org.eclipse.swt.widgets.TableItem)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 Problem (org.talend.core.model.process.Problem)2 ExternalDbMapTable (org.talend.designer.dbmap.external.data.ExternalDbMapTable)2