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();
}
});
}
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
}
});
}
}
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'.");
}
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);
}
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;
}
Aggregations