Search in sources :

Example 1 with InputTable

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

the class TableManager method getAliases.

/**
     * DOC amaumont Comment method "getAliases".
     */
public String[] getAliases() {
    List<InputTable> inputTables = getInputTables();
    ArrayList<String> names = new ArrayList<String>();
    for (InputTable table : inputTables) {
        String alias = table.getAlias();
        if (alias != null) {
            names.add(alias);
        }
    }
    return names.toArray(new String[0]);
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) ArrayList(java.util.ArrayList)

Example 2 with InputTable

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

the class ProblemsAnalyser method checkProblems.

public List<Problem> checkProblems(ExternalDbMapData externalData) {
    problems.clear();
    if (externalData != null) {
        List<IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getIncomingConnections());
        List<IConnection> outgoingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getOutgoingConnections());
        ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
        MapperMain mapperMain = mapperManager.getComponent().getMapperMain();
        List<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
        ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
        List<IOConnection> outputsIOConnections = mapperMain.createIOConnections(outgoingConnections);
        ArrayList<OutputTable> outputTables = converter.prepareOutputTables(outputsIOConnections, this.mapperManager.getComponent().getMetadataList(), externalData);
        List<? super AbstractInOutTable> tablesWriteMode = new ArrayList<AbstractInOutTable>();
        tablesWriteMode.addAll(inputTables);
        tablesWriteMode.addAll(outputTables);
        List<? extends AbstractInOutTable> tablesReadMode = (List<? extends AbstractInOutTable>) tablesWriteMode;
        ProblemsManager problemsManager = new ProblemsManager(mapperManager);
        ArrayList<Problem> problemsLocal = new ArrayList<Problem>();
        for (AbstractInOutTable table : tablesReadMode) {
            List<IColumnEntry> columnEntries = table.getColumnEntries();
            problemsManager.checkProblemsForAllEntries(columnEntries);
            for (IColumnEntry entry : columnEntries) {
                List<Problem> problemsOfEntry = entry.getProblems();
                if (problemsOfEntry != null) {
                    problemsLocal.addAll(problemsOfEntry);
                }
            }
        }
        problems.addAll(problemsLocal);
    }
    return getProblems();
}
Also used : ExternalDataConverter(org.talend.designer.dbmap.external.converter.ExternalDataConverter) ArrayList(java.util.ArrayList) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IConnection(org.talend.core.model.process.IConnection) 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) ArrayList(java.util.ArrayList) List(java.util.List) Problem(org.talend.core.model.process.Problem) MapperMain(org.talend.designer.dbmap.MapperMain) ProblemsManager(org.talend.designer.dbmap.managers.ProblemsManager)

Example 3 with InputTable

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

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
    if (searchValue.equals("")) {
        uiManager.unselectAllEntriesOfAllTables();
        return;
    }
    // SearchPattern
    matcher.setPattern("*" + searchValue.trim() + "*");
    List<InputTable> inputTables = mapperManager.getInputTables();
    List<OutputTable> outputTables = mapperManager.getOutputTables();
    int index = -1;
    // for the InputTables
    for (InputTable inputTable : inputTables) {
        for (IColumnEntry column : inputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
    // for the OutputTables
    for (OutputTable outputTable : outputTables) {
        // OutputTable Filters
        for (FilterTableEntry entry : outputTable.getWhereFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        for (FilterTableEntry entry : outputTable.getOtherFilterEntries()) {
            if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
                Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
                map.put(0, entry);
                index++;
                searchMaps.put(index, map);
            }
        }
        // OutputTable Columns
        for (IColumnEntry column : outputTable.getColumnEntries()) {
            int i = -1;
            Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
            boolean modified = false;
            if (column.getExpression() != null && matcher.matches(column.getExpression())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (column.getName() != null && matcher.matches(column.getName())) {
                i++;
                map.put(i, column);
                modified = true;
            }
            if (modified) {
                index++;
                searchMaps.put(index, map);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 4 with InputTable

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

the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.

public void moveScrollBarZoneAtSelectedTableItem(ITableEntry entry) {
    if (entry != null) {
        DataMapTableView dataMapTableView = mapperManager.retrieveIDataMapTableView(entry.getParent());
        Rectangle tableViewBounds = dataMapTableView.getBounds();
        IDataMapTable table = entry.getParent();
        TableItem tableItem = mapperManager.retrieveTableItem(entry);
        if (table != null && tableItem != null) {
            Rectangle tableItemBounds = tableItem.getBounds();
            int selection = tableViewBounds.y + tableItemBounds.y;
            ScrolledComposite scrollComposite = null;
            if (table instanceof InputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewInputs();
            } else if (table instanceof OutputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewOutputs();
            }
            if (scrollComposite != null) {
                setPositionOfVerticalScrollBarZone(scrollComposite, selection);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 5 with InputTable

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

the class MapperUI method init.

public void init(MapperModel mapperModel) {
    // long time1 = System.currentTimeMillis();
    // CommandStack commandStack = new CommandStackForComposite(this.mapperUIParent);
    // mapperManager.setCommandStack(commandStack);
    final UIManager uiManager = mapperManager.getUiManager();
    final ExternalDbMapUiProperties uiProperties = uiManager.getUiProperties();
    addParentListeners(uiManager, uiProperties);
    final Display display = mapperUIParent.getDisplay();
    bgColorLinksZone = ColorProviderMapper.getColor(ColorInfo.COLOR_BACKGROUND_LINKS_ZONE);
    GridLayout parentLayout = new GridLayout(1, true);
    mapperUIParent.setLayout(parentLayout);
    addKeyListener(uiManager, display);
    addBackgroundRefreshLimiters(display);
    this.dropTargetOperationListener = new DropTargetOperationListener(mapperManager);
    dropTargetOperationListener.addControl(this.mapperUIParent.getShell());
    mainSashForm = new SashForm(mapperUIParent, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasFlowViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    datasFlowViewSashForm.setBackgroundMode(SWT.INHERIT_FORCE);
    initBackgroundComponents();
    if (WindowSystem.isGTK()) {
        datasFlowViewSashForm.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
    }
    // dropTargetOperationListener.addControl(datasFlowViewSashForm);
    // datasFlowViewSashForm.addControlListener(new ControlListener() {
    //
    // public void controlMoved(ControlEvent e) {
    // }
    //
    // public void controlResized(ControlEvent e) {
    // createBgImages();
    // updateBackground(true, false);
    // }
    //
    // });
    /* Create the tabs */
    String dbmsId = null;
    if (mapperModel.getInputDataMapTables() != null && !mapperModel.getInputDataMapTables().isEmpty()) {
        InputTable input = mapperModel.getInputDataMapTables().get(0);
        if (input.getMetadataTable() != null) {
            dbmsId = input.getMetadataTable().getDbms();
        }
    }
    tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager, dbmsId);
    createInputZoneWithTables(mapperModel, uiManager, display);
    createVarsZoneWithTables(mapperModel, display);
    createOutputZoneWithTables(mapperModel, uiManager, display);
    mapperManager.initInternalData();
    uiManager.parseAllExpressionsForAllTables();
    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    this.draggingInfosPopup = DraggingInfosPopup.getNewShell(this.mapperUIParent.getShell());
    configureZoneScrollBars(display);
    int[] weightsDatasFlowViewSashForm = uiProperties.getWeightsDatasFlowViewSashForm();
    datasFlowViewSashForm.setWeights(weightsDatasFlowViewSashForm.length != 0 ? weightsDatasFlowViewSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_DATAS_FLOW_SASH_FORM);
    int[] weightsMainSashForm = uiProperties.getWeightsMainSashForm();
    mainSashForm.setWeights(weightsMainSashForm.length != 0 ? weightsMainSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_MAIN_SASH_FORM);
    new FooterComposite(this.mapperUIParent, SWT.NONE, mapperManager);
    if (WindowSystem.isGTK()) {
        // resize especially for GTK
        new AsynchronousThreading(1000, false, display, new Runnable() {

            public void run() {
                resizeNotMinimizedTablesAtExpandedSize(display);
                mapperUIParent.getShell().layout();
            }
        }).start();
    }
    if (WindowSystem.isWIN32()) {
        List<DataMapTableView> inputsTablesView = uiManager.getInputsTablesView();
        for (DataMapTableView view : inputsTablesView) {
            ((InputDataMapTableView) view).refreshLabelForJoinDropDown();
        }
    }
    selectFirstInOutTablesView();
    mapperManager.getUiManager().refreshSqlExpression();
}
Also used : TabFolderEditors(org.talend.designer.dbmap.ui.tabs.TabFolderEditors) FooterComposite(org.talend.designer.dbmap.ui.footer.FooterComposite) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) UIManager(org.talend.designer.dbmap.managers.UIManager) 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) ExternalDbMapUiProperties(org.talend.designer.dbmap.external.data.ExternalDbMapUiProperties) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading) SashForm(org.eclipse.swt.custom.SashForm) InputTable(org.talend.designer.dbmap.model.table.InputTable) GridLayout(org.eclipse.swt.layout.GridLayout) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

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