Search in sources :

Example 11 with InputTable

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

the class InputDataMapTableView method createMapSettingTable.

@Override
protected void createMapSettingTable() {
    ExtendedTableModel<GlobalMapEntry> tableMapSettingEntriesModel = ((InputTable) abstractDataMapTable).getTableMapSettingEntriesModel();
    extendedTableViewerForMapSetting = new AbstractExtendedTableViewer<GlobalMapEntry>(tableMapSettingEntriesModel, centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
            initMapSettingColumns(tableViewerCreator);
        }

        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setBorderVisible(false);
        }
    };
    if (tableMapSettingEntriesModel != null) {
        if (!getInputTable().isMainConnection()) {
            if (!getMapperManager().isMRProcess()) {
                tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, LOOKUP_MODEL_SETTING, null));
            }
            tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, MATCH_MODEL_SETTING, null));
            tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, JOIN_MODEL_SETTING, null));
            if (!getMapperManager().isBigDataProcess()) {
                tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, PERSISTENCE_MODEL_SETTING, null));
            }
        // remove schema type in input tables
        // tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_TYPE, null));
        } else {
        // tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_TYPE, null));
        }
    // if (getInputTable().isRepository()) {
    // tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_ID, null));
    // }
    }
    mapSettingViewerCreator = extendedTableViewerForMapSetting.getTableViewerCreator();
    mapSettingTable = extendedTableViewerForMapSetting.getTable();
    tableForMapSettingGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
    mapSettingTable.setLayoutData(tableForMapSettingGridData);
    mapSettingTable.setHeaderVisible(true);
    mapSettingTable.setLinesVisible(true);
    boolean mappingSettingVisible = false;
    if (abstractDataMapTable instanceof AbstractInOutTable) {
        mappingSettingVisible = ((AbstractInOutTable) abstractDataMapTable).isActivateCondensedTool();
    }
    tableForMapSettingGridData.exclude = !mappingSettingVisible;
    mapSettingTable.setVisible(mappingSettingVisible);
    mapSettingViewerCreator.setCellModifier(new TableCellModifier(mapSettingViewerCreator));
    mapSettingViewerCreator.getTableViewer().setSelection(null);
    mapSettingTable.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            mapSettingViewerCreator.getTableViewer().setSelection(null);
        }

        public void focusGained(FocusEvent e) {
        }
    });
    final TableViewer mapSettingTableViewer = mapSettingViewerCreator.getTableViewer();
    mapSettingTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            selectThisDataMapTableView();
        }
    });
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) InputTable(org.talend.designer.mapper.model.table.InputTable) GridData(org.eclipse.swt.layout.GridData) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) FocusListener(org.eclipse.swt.events.FocusListener) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 12 with InputTable

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

the class InputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    boolean isMainConnection = ((InputTable) getDataMapTable()).isMainConnection();
    TableViewerCreatorColumn column = null;
    if (!isMainConnection) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle(Messages.getString("InputDataMapTableView.columnTitle.Expr"));
        column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
        expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS }, false);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

            public String get(InputColumnTableEntry bean) {
                return bean.getExpression();
            }

            public void set(InputColumnTableEntry bean, String value) {
                // System.out.println("value='" + value + "'");
                bean.setExpression(value);
                InputTable inputTable = getInputTable();
                boolean tableHasAtLeastOneHashKey = mapperManager.isTableHasAtLeastOneHashKey(inputTable);
                if (!tableHasAtLeastOneHashKey) {
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode != TMAP_MATCHING_MODE.ALL_ROWS) {
                        inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
                        refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
                    }
                } else {
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode == TMAP_MATCHING_MODE.ALL_ROWS) {
                        IUIMatchingMode newMatchModel = previousMatchingModeSelected == null || previousMatchingModeSelected == TMAP_MATCHING_MODE.ALL_ROWS ? TMAP_MATCHING_MODE.UNIQUE_MATCH : previousMatchingModeSelected;
                        inputTable.setMatchingMode(newMatchModel);
                        refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
                    }
                    mapperManager.getUiManager().setStatusBarValues(STATUS.EMPTY, null);
                }
                mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true, true);
                if (!mapperManager.isCheckSyntaxEnabled()) {
                    mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreatorForColumns);
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            mapperManager.getProblemsManager().checkLookupExpressionProblem();
                        }
                    });
                }
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        //$NON-NLS-1$
        column.setDefaultInternalValue("");
        column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
        column.setImageProvider(new IColumnImageProvider<InputColumnTableEntry>() {

            public Image getImage(InputColumnTableEntry bean) {
                if (bean.getExpression() != null && !bean.getExpression().trim().equals("")) {
                    //$NON-NLS-1$
                    if (mapperManager.isAdvancedMap()) {
                        return ImageProviderMapper.getImage(ImageInfo.LOOKUP_KEY_ICON);
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            }
        });
    }
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

        public String get(InputColumnTableEntry bean) {
            return bean.getMetadataColumn().getLabel();
        }

        public void set(InputColumnTableEntry bean, String value) {
            bean.getMetadataColumn().setLabel(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    if (isMainConnection && PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive()) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        column.setTitle("Preview");
        column.setId(DataMapTableView.PREVIEW_COLUMN);
        column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

            public String get(InputColumnTableEntry bean) {
                IMetadataColumn metadataColumn = bean.getMetadataColumn();
                if (metadataColumn != null) {
                    String label = metadataColumn.getLabel();
                    TraceData preview = bean.getPreviewValue();
                    if (preview != null && preview.getData() != null) {
                        return preview.getData().get(label);
                    }
                }
                return "";
            }

            public void set(InputColumnTableEntry bean, String value) {
            // do nothing
            }
        });
    }
}
Also used : Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) IUIMatchingMode(org.talend.designer.mapper.model.table.IUIMatchingMode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) InputTable(org.talend.designer.mapper.model.table.InputTable) TraceData(org.talend.core.model.process.TraceData) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 13 with InputTable

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

the class ProblemsAnalyserTest method testGetLookupTableProblem.

@Test
public void testGetLookupTableProblem() {
    MapperComponent mapperComponent = createMapperComponent();
    ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
    MapperManager mapperManager = mapperComponent.getMapperMain().getMapperManager();
    ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
    MapperMain mapperMain = ((MapperComponent) mapperManager.getAbstractMapComponent()).getMapperMain();
    List<? extends IConnection> incomingConnections = new ArrayList<IConnection>(mapperManager.getAbstractMapComponent().getIncomingConnections());
    ArrayList<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
    ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
    InputTable lookupTable = inputTables.get(1);
    ProblemsAnalyser analyser = new ProblemsAnalyser(mapperManager);
    // match mode:Unique Match +no expression
    lookupTable.setMatchingMode(TMAP_MATCHING_MODE.UNIQUE_MATCH);
    analyser.getLookupTableProblem(lookupTable, mapperManager.isTableHasAtLeastOneHashKey(lookupTable));
    List<Problem> problems = analyser.getProblems();
    Assert.assertEquals(problems.size(), 1);
    Assert.assertEquals(problems.get(0).getDescription(), "The lookup table 'row2' should have at least one expression key filled.");
    // match mode:All Row +expression
    lookupTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
    lookupTable.getColumnEntries().get(0).setExpression("row1.newColumn1");
    analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
    analyser.getLookupTableProblem(lookupTable, mapperManager.isTableHasAtLeastOneHashKey(lookupTable));
    problems = analyser.getProblems();
    Assert.assertEquals(problems.size(), 1);
    Assert.assertEquals(problems.get(0).getDescription(), "The expression key can't be used in lookup table 'row2' with match mode 'All Rows'.");
}
Also used : ExternalDataConverter(org.talend.designer.mapper.external.converter.ExternalDataConverter) MapperManager(org.talend.designer.mapper.managers.MapperManager) ArrayList(java.util.ArrayList) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) InputTable(org.talend.designer.mapper.model.table.InputTable) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) Problem(org.talend.core.model.process.Problem) MapperMain(org.talend.designer.mapper.MapperMain) MapperComponent(org.talend.designer.mapper.MapperComponent) Test(org.junit.Test)

Example 14 with InputTable

use of org.talend.designer.mapper.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();
    ILanguage currentLanguage = LanguageProvider.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.retrieveAbstractDataMapTableView(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) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) ILanguage(org.talend.designer.mapper.language.ILanguage)

Example 15 with InputTable

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

the class CompleteDropTargetTableListener method insertNewVarEntry.

private int insertNewVarEntry(ILanguage currentLanguage, DataMapTableView dataMapTableViewTarget, int currentIndex, ITableEntry tableEntrySource, String columnName) {
    ITableEntry dataMapTableEntry;
    String type = null;
    if (tableEntrySource.getParent() instanceof InputTable) {
        type = ((InputColumnTableEntry) tableEntrySource).getMetadataColumn().getTalendType();
    } else if (tableEntrySource.getParent() instanceof VarsTable) {
        type = ((VarTableEntry) tableEntrySource).getType();
    }
    dataMapTableEntry = getMapperManager().addNewVarEntry(dataMapTableViewTarget, columnName, currentIndex++, type);
    String location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
    //$NON-NLS-1$
    dataMapTableEntry.setExpression(location + " ");
    return currentIndex;
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Aggregations

InputTable (org.talend.designer.mapper.model.table.InputTable)24 ArrayList (java.util.ArrayList)10 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)8 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)8 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)8 OutputTable (org.talend.designer.mapper.model.table.OutputTable)5 HashMap (java.util.HashMap)4 List (java.util.List)4 VarsTable (org.talend.designer.mapper.model.table.VarsTable)4 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 Point (org.eclipse.swt.graphics.Point)3 GridData (org.eclipse.swt.layout.GridData)3 Table (org.eclipse.swt.widgets.Table)3 TableItem (org.eclipse.swt.widgets.TableItem)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)3 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)3 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)3 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)3