Search in sources :

Example 6 with OutputTable

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

the class TableEntriesManager method remove.

public void remove(ITableEntry dataMapTableEntry, boolean removingPhysicalInputTable) {
    if (dataMapTableEntry != null) {
        mapperManager.removeLinksOf(dataMapTableEntry);
        tableEntries.remove(TableEntriesManager.buildLocation(dataMapTableEntry));
        dataMapTableEntryToProperties.remove(dataMapTableEntry);
        IDataMapTable dataMapTable = dataMapTableEntry.getParent();
        if (dataMapTableEntry instanceof IColumnEntry) {
            dataMapTableEntry.getParent().removeColumnEntry((IColumnEntry) dataMapTableEntry);
            InputTable inputTable = isPhysicalTable(dataMapTable);
            if (inputTable != null && !removingPhysicalInputTable) {
                removeMetadataColumnFromDbTable(inputTable.getTableName(), dataMapTableEntry.getName());
            }
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            if (dataMapTable instanceof OutputTable) {
                if (FilterTableEntry.WHERE_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
                    ((OutputTable) dataMapTable).removeWhereFilterEntry((FilterTableEntry) dataMapTableEntry);
                } else if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
                    ((OutputTable) dataMapTable).removeOtherFilterEntry((FilterTableEntry) dataMapTableEntry);
                }
            }
        } else {
            String exceptionMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
            throw new IllegalArgumentException(exceptionMessage);
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) 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 7 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable 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 8 with OutputTable

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

the class MapperManager method addOutput.

/**
     * DOC amaumont Comment method "addOutput".
     */
public void addOutput() {
    String tableName = uiManager.openNewOutputCreationDialog();
    if (tableName == null) {
        return;
    }
    IProcess process = mapperComponent.getProcess();
    //$NON-NLS-1$
    String uniqueName = process.generateUniqueConnectionName("table");
    process.addUniqueConnectionName(uniqueName);
    MetadataTable metadataTable = new MetadataTable();
    metadataTable.setTableName(uniqueName);
    // metadataTable.setId(uniqueName);
    metadataTable.setLabel(tableName);
    List<DataMapTableView> outputsTablesView = getUiManager().getOutputsTablesView();
    int sizeOutputsView = outputsTablesView.size();
    Control lastChild = null;
    if (sizeOutputsView - 1 >= 0) {
        lastChild = outputsTablesView.get(sizeOutputsView - 1);
    }
    IDataMapTable abstractDataMapTable = new OutputTable(this, metadataTable, uniqueName, tableName);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    tablesZoneViewOutputs.layout();
    uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
Also used : Control(org.eclipse.swt.widgets.Control) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) 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) TablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 9 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable 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 10 with OutputTable

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

Aggregations

OutputTable (org.talend.designer.dbmap.model.table.OutputTable)18 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)9 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)7 InputTable (org.talend.designer.dbmap.model.table.InputTable)7 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)6 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Control (org.eclipse.swt.widgets.Control)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 IOConnection (org.talend.designer.dbmap.external.connection.IOConnection)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 ControlListener (org.eclipse.swt.events.ControlListener)2 Point (org.eclipse.swt.graphics.Point)2 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)2 IProcess (org.talend.core.model.process.IProcess)2 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)2