Search in sources :

Example 6 with InputTable

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

the class MapperUI method createInputZoneWithTables.

private void createInputZoneWithTables(MapperModel mapperModel, UIManager uiManager, final Display display) {
    inputsZone = new InputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
    inputsZone.createHeaderZoneComponents();
    sc1 = new ScrolledComposite(inputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
    // this.dropTargetOperationListener.addControl(sc1);
    GridData sc1GridData = new GridData(GridData.FILL_BOTH);
    sc1.setLayoutData(sc1GridData);
    sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        // System.out.println("sc1 controlMoved");
        }

        public void controlResized(ControlEvent e) {
            // System.out.println("sc1 controlResized");
            onSashResized(display);
        }
    });
    inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
    // this.dropTargetOperationListener.addControl(inputTablesZoneView);
    inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.setExpandHorizontal(true);
    sc1.setContent(inputTablesZoneView);
    sc1MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc1);
    inputTablesZoneView.initInsertionIndicator();
    Control previousControl = null;
    List<InputTable> tables = mapperModel.getInputDataMapTables();
    Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
    if (minimizeStateOfTables != null) {
        inputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
    }
    for (InputTable inputTable : tables) {
        InputDataMapTableView dataMapTableView = uiManager.createNewInputTableView(previousControl, inputTable, inputTablesZoneView);
        if (previousControl == null) {
            uiManager.updateDropDownJoinTypeForInputs();
        }
        previousControl = dataMapTableView;
    }
    inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) Control(org.eclipse.swt.widgets.Control) InputsZone(org.talend.designer.dbmap.ui.visualmap.zone.InputsZone) InputTablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.InputTablesZoneView) GridData(org.eclipse.swt.layout.GridData) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener)

Example 7 with InputTable

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

the class ProblemsManager method checkProblemsForTableEntry.

public void checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData) {
    // if (forceRefreshData) {
    // mapperManager.getComponent().refreshMapperConnectorData();
    // checkProblems();
    // }
    List<Problem> problems = new ArrayList<Problem>(0);
    String expression = tableEntry.getExpression();
    if (tableEntry instanceof InputColumnTableEntry) {
        InputColumnTableEntry inputEntry = (InputColumnTableEntry) tableEntry;
        IDbOperatorManager operatorsManager = mapperManager.getCurrentLanguage().getOperatorsManager();
        IDbOperator dbOperator = operatorsManager.getOperatorFromValue(inputEntry.getOperator());
        boolean operatorIsSet = dbOperator != null;
        boolean expressionIsSet = expression != null && expression.trim().length() > 0;
        Problem problem = null;
        String errorMessage = null;
        String key = null;
        if (!operatorIsSet && expressionIsSet) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.operatorNotSet", new Object[] { inputEntry.getName() });
            key = KEY_OPERATOR_EMPTY;
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(key);
            problems.add(problem);
        }
        if (operatorIsSet && !expressionIsSet && !dbOperator.isMonoOperand()) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.inputExpressionEmpty", new Object[] { inputEntry.getParentName(), inputEntry.getName() });
            key = KEY_INPUT_EXPRESSION_EMPTY;
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(key);
            problems.add(problem);
        }
        Problem warningProblem = null;
        if (inputEntry.isUnmatchingEntry()) {
            InputTable inputTable = (InputTable) inputEntry.getParent();
            String message = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.entryDoesntMatch", new Object[] { inputEntry.getParentName(), inputEntry.getName(), inputTable.getTableName() });
            warningProblem = new Problem(null, message, ProblemStatus.WARNING);
            warningProblem.setKey(KEY_NO_MATCHING);
            problems.add(warningProblem);
        }
    } else if (tableEntry instanceof OutputColumnTableEntry) {
        String errorMessage = null;
        Problem problem = null;
        if (expression == null || EMPTY_STRING.equals(expression.trim())) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.outputExpressionEmpty", new Object[] { tableEntry.getParentName(), tableEntry.getName() });
        }
        if (errorMessage != null) {
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(KEY_OUTPUT_EXPRESSION_EMPTY);
            problems.add(problem);
        }
    }
    tableEntry.setProblems(problems.size() > 0 ? problems : null);
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) IDbOperator(org.talend.designer.dbmap.language.operator.IDbOperator) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry) IDbOperatorManager(org.talend.designer.dbmap.language.operator.IDbOperatorManager)

Example 8 with InputTable

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

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

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

the class TableManager method getVisibleTables.

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

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