Search in sources :

Example 6 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class CompleteDropTargetTableListener method updateExpressionsOfInsertedEntries.

/**
     * DOC amaumont Comment method "updateExpressionsOfInsertedEntries".
     * 
     * @param uiManager
     * @param currentLanguage
     * @param metadataEditorView
     * @param currentIndex
     * @param sourceEntriesOfEntriesBeingAdded
     * @param targetTableIsConstraintsTable
     * @param tableViewerCreatorTarget
     * @param metadataColumnsBeingAdded
     * @param metadataEditorEvent
     */
@SuppressWarnings("unchecked")
private void updateExpressionsOfInsertedEntries(ILanguage currentLanguage, MetadataTableEditorView metadataEditorView, int currentIndex, ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded, boolean targetTableIsConstraintsTable, TableViewerCreator tableViewerCreatorTarget, ArrayList<IMetadataColumn> metadataColumnsBeingAdded) // , MetadataEditorEvent metadataEditorEvent
{
    UIManager uiManager = getUiManager();
    if (metadataEditorView != null && !targetTableIsConstraintsTable) {
        metadataEditorView.getMetadataTableEditor().addAll(currentIndex, metadataColumnsBeingAdded);
        // metadataEditorEvent.indexStartInsert = currentIndex;
        // IAction action = MetadataEditorActionFactory.getInstance().getAction(metadataEditorView,
        // metadataEditorEvent);
        // action.run(metadataEditorEvent);
        Zone zoneTarget = getMapperManager().retrieveDataMapTableView(tableViewerCreatorTarget.getTable()).getZone();
        List<IColumnEntry> lastCreatedTableEntries = uiManager.getLastCreatedInOutColumnEntries();
        for (int i = 0; i < lastCreatedTableEntries.size(); i++) {
            ITableEntry tableEntrySource = sourceEntriesOfEntriesBeingAdded.get(i);
            ITableEntry dataMapTableEntry = lastCreatedTableEntries.get(i);
            if (zoneTarget == Zone.INPUTS) {
                ((InputColumnTableEntry) dataMapTableEntry).getMetadataColumn().setKey(true);
            }
            DataMapTableView dataMapTableView = getMapperManager().retrieveAbstractDataMapTableView(tableEntrySource.getParent());
            Zone zoneSource = dataMapTableView.getZone();
            String location = null;
            if (zoneSource == Zone.OUTPUTS) {
                location = tableEntrySource.getExpression();
            } else {
                location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
            }
            if (location != null) {
                //$NON-NLS-1$
                dataMapTableEntry.setExpression(location + " ");
            }
        }
    }
    tableViewerCreatorTarget.getTableViewer().refresh();
    List<ITableEntry> refreshedTableEntriesList = tableViewerCreatorTarget.getInputList();
    for (ITableEntry tableEntry : refreshedTableEntriesList) {
        uiManager.parseExpression(tableEntry.getExpression(), tableEntry, false, true, false);
    }
}
Also used : Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.mapper.managers.UIManager) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) Point(org.eclipse.swt.graphics.Point)

Example 7 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class VarsTable method initFromExternalData.

public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        List<ExternalDbMapEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
        if (metadataTableEntries != null) {
            for (ExternalDbMapEntry externalMapperTableEntry : metadataTableEntries) {
                IColumnEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getOperator());
                // mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
                addColumnEntry(varTableEntry);
            }
        }
    } else {
        setMinimized(true);
    }
}
Also used : VarTableEntry(org.talend.designer.dbmap.model.tableentry.VarTableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry)

Example 8 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class UIManager method getTableEntryPosition.

/**
     * DOC amaumont Comment method "getTableEntryPosition".
     * 
     * @param manager TODO
     * @param tableEntry
     * @param forceRecalculate TODO
     * @return
     */
public Point getTableEntryPosition(ITableEntry tableEntry, boolean forceRecalculate) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
    int entriesSize = 0;
    int minHeight = dataMapTableView.getTableViewerCreatorForColumns().getTable().getHeaderHeight() + dataMapTableView.getTableViewerCreatorForColumns().getTable().getItemHeight();
    TableItem[] tableItems = new TableItem[0];
    if (tableEntry instanceof InputColumnTableEntry || tableEntry instanceof OutputColumnTableEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
        AbstractInOutTable abstractInOutTable = (AbstractInOutTable) dataMapTableView.getDataMapTable();
        if (dataMapTableView.getZone() == Zone.OUTPUTS) {
            OutputTable outputTable = (OutputTable) abstractInOutTable;
            List<IColumnEntry> oldOuputEntries = outputTable.getDataMapTableEntries();
            entriesSize = oldOuputEntries.size();
        }
        if (dataMapTableView.getZone() == Zone.INPUTS) {
            InputTable inputTable = (InputTable) abstractInOutTable;
            List<IColumnEntry> oldOuputEntries = inputTable.getDataMapTableEntries();
            entriesSize = oldOuputEntries.size();
        }
    }
    Rectangle tableViewBounds = dataMapTableView.getBounds();
    Point pointFromTableViewOrigin = null;
    Display display = dataMapTableView.getDisplay();
    Point returnedPoint = new Point(0, 0);
    TableEntryProperties tableEntryProperties = null;
    int itemIndex = 0;
    if (tableEntry instanceof IColumnEntry || tableEntry instanceof FilterTableEntry || tableEntry instanceof GlobalMapEntry) {
        tableEntryProperties = mapperManager.getTableEntryProperties(tableEntry);
        returnedPoint = tableEntryProperties.position;
        if (forceRecalculate || returnedPoint == null) {
            int y;
            TableItem tableItem = mapperManager.retrieveTableItem(tableEntry);
            boolean isOutputEntry = tableEntry instanceof OutputColumnTableEntry;
            boolean isIntputEntry = tableEntry instanceof InputColumnTableEntry;
            boolean checked = false;
            for (int i = 0; i < tableItems.length; i++) {
                if (tableItems[i].getData() == tableEntry) {
                    itemIndex = i;
                    break;
                }
            }
            boolean allIsNull = false;
            if (tableItem == null && (isIntputEntry || isOutputEntry)) {
                if (tableItems.length > 0) {
                    tableItem = tableItems[0];
                    checked = true;
                } else {
                    allIsNull = true;
                }
            }
            if (!allIsNull) {
                Table table = tableItem.getParent();
                // FIX for issue 1225 ("1" parameter added)
                Rectangle boundsTableItem = tableItem.getBounds(1);
                y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
                if (isOutputEntry || isIntputEntry) {
                    if (entriesSize != tableItems.length) {
                        y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
                    }
                }
                if (checked) {
                    y = boundsTableItem.y + dataMapTableView.getBorderWidth();
                    checked = false;
                }
                int x = 0;
                if (y < 0) {
                    y = 0;
                }
                Point point = new Point(x, y);
                pointFromTableViewOrigin = display.map(tableItem.getParent(), dataMapTableView, point);
            } else {
                Text columnFilterText = dataMapTableView.getColumnNameFilterText();
                Point point = new Point(-dataMapTableView.getBorderWidth() - 19, minHeight);
                pointFromTableViewOrigin = display.map(columnFilterText, dataMapTableView, point);
            }
        }
    } else if (tableEntry instanceof ExpressionFilterEntry) {
        StyledText expressionFilterText = dataMapTableView.getExpressionFilterText();
        //            dataMapTableView.getex
        Point point = new Point(-dataMapTableView.getBorderWidth() - 19, 16);
        pointFromTableViewOrigin = display.map(expressionFilterText, dataMapTableView, point);
    } else {
        //$NON-NLS-1$
        throw new IllegalStateException("Case not found");
    }
    if (pointFromTableViewOrigin.y > tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION) {
        pointFromTableViewOrigin.y = tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION;
    }
    returnedPoint = convertPointToReferenceOrigin(getReferenceComposite(), pointFromTableViewOrigin, dataMapTableView);
    if (tableEntryProperties != null) {
        tableEntryProperties.position = returnedPoint;
    }
    return returnedPoint;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) Table(org.eclipse.swt.widgets.Table) AbstractDataMapTable(org.talend.designer.mapper.model.table.AbstractDataMapTable) StyledText(org.eclipse.swt.custom.StyledText) TableItem(org.eclipse.swt.widgets.TableItem) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) Rectangle(org.eclipse.swt.graphics.Rectangle) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableEntryProperties(org.talend.designer.mapper.ui.visualmap.TableEntryProperties) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) Display(org.eclipse.swt.widgets.Display)

Example 9 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class ProblemsManager method checkLookupExpressionProblem.

public boolean checkLookupExpressionProblem() {
    if (mapperManager.isBigDataProcess()) {
        List<DataMapTableView> inputsTablesView = mapperManager.getUiManager().getInputsTablesView();
        List<DataMapTableView> lookupTables = new ArrayList<DataMapTableView>();
        List<IColumnEntry> entityWithoutProblem = new ArrayList<IColumnEntry>();
        DataMapTableView firstLookup = null;
        for (int i = 0; i < inputsTablesView.size(); i++) {
            DataMapTableView inputTableView = inputsTablesView.get(i);
            InputTable dataMapTable = (InputTable) inputTableView.getDataMapTable();
            boolean mainConnection = dataMapTable.isMainConnection();
            if (mainConnection) {
                continue;
            }
            if (firstLookup == null) {
                firstLookup = inputTableView;
            } else {
                lookupTables.add(inputTableView);
            }
        }
        if (firstLookup == null || lookupTables.isEmpty()) {
            return false;
        }
        List<List<IColumnEntry>> otherLookupEntities = new ArrayList<List<IColumnEntry>>();
        for (DataMapTableView otherLookup : lookupTables) {
            otherLookupEntities.add(new ArrayList<IColumnEntry>(otherLookup.getDataMapTable().getColumnEntries()));
        }
        List<IColumnEntry> lookupEntity = firstLookup.getDataMapTable().getColumnEntries();
        for (IColumnEntry firstLookupEntity : lookupEntity) {
            String expression = firstLookupEntity.getExpression();
            if (expression == null || expression.trim().equals("")) {
                continue;
            }
            //$NON-NLS-1$//$NON-NLS-2$
            expression = expression.replaceAll("\\s*", "").trim();
            Map<List<IColumnEntry>, IColumnEntry> entitiesFound = new HashMap<List<IColumnEntry>, IColumnEntry>();
            for (List<IColumnEntry> tableEntities : otherLookupEntities) {
                for (IColumnEntry entityInOtherLookup : tableEntities) {
                    String expressionInOtherLookup = entityInOtherLookup.getExpression();
                    if (expressionInOtherLookup == null || expressionInOtherLookup.trim().equals("")) {
                        continue;
                    }
                    //$NON-NLS-1$//$NON-NLS-2$
                    expressionInOtherLookup = expressionInOtherLookup.replaceAll("\\s*", "").trim();
                    // only match the first one
                    if (expression.equals(expressionInOtherLookup)) {
                        entitiesFound.put(tableEntities, entityInOtherLookup);
                        break;
                    }
                }
            }
            if (entitiesFound.size() == otherLookupEntities.size()) {
                for (List<IColumnEntry> tableEntities : entitiesFound.keySet()) {
                    entityWithoutProblem.add(entitiesFound.get(tableEntities));
                    entityWithoutProblem.add(firstLookupEntity);
                    tableEntities.remove(entitiesFound.get(tableEntities));
                }
            }
        }
        // add back the first lookup table
        lookupTables.add(firstLookup);
        if (entityWithoutProblem.isEmpty()) {
            // no common expressions in lookup tables , then show red background color for all
            for (DataMapTableView lookupTable : lookupTables) {
                List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
                for (IColumnEntry entity : columnEntries) {
                    if (entity.getExpression() == null || entity.getExpression().trim().equals("")) {
                        continue;
                    }
                    addLookupProblem(entity);
                }
                lookupTable.getTableViewerCreatorForColumns().refresh();
            }
        } else {
            for (DataMapTableView lookupTable : lookupTables) {
                boolean needRefresh = false;
                List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
                for (IColumnEntry entity : columnEntries) {
                    if (entity.getExpression() == null || entity.getExpression().trim().equals("") || entityWithoutProblem.contains(entity)) {
                        if (entity.getProblems() != null) {
                            needRefresh = entity.getProblems().remove(lookupProblem);
                            if (entity.getProblems().isEmpty()) {
                                entity.setProblems(null);
                            }
                        }
                    } else {
                        addLookupProblem(entity);
                        needRefresh = true;
                    }
                }
                if (needRefresh) {
                    lookupTable.getTableViewerCreatorForColumns().refresh();
                }
            }
        }
        return true;
    }
    return false;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) InputTable(org.talend.designer.mapper.model.table.InputTable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class TableEntriesManager method remove.

public void remove(ITableEntry dataMapTableEntry) {
    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);
        } else if (dataMapTableEntry instanceof GlobalMapEntry) {
            if (dataMapTable instanceof OutputTable) {
                ((InputTable) dataMapTable).removeGlobalMapEntry((GlobalMapEntry) dataMapTableEntry);
            }
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            if (dataMapTable instanceof OutputTable) {
                ((OutputTable) dataMapTable).removeFilterEntry((FilterTableEntry) dataMapTableEntry);
            }
        } else if (dataMapTableEntry instanceof ExpressionFilterEntry) {
        // nothing
        } else {
            String exceptionMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
            throw new IllegalArgumentException(exceptionMessage);
        }
    }
}
Also used : FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Aggregations

IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)42 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)16 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)10 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)10 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)9 InputTable (org.talend.designer.mapper.model.table.InputTable)8 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)8 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 TableViewer (org.eclipse.jface.viewers.TableViewer)6 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)5 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4