use of org.talend.designer.mapper.MapperComponent in project tdi-studio-se by Talend.
the class MapperUI method createWindow.
/**
* DOC amaumont Comment method "createUI".
*
* @param display
*/
public Shell createWindow(final Display display, MapperModel model) {
Shell activeShell = display.getActiveShell();
Shell mapperShell = null;
int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
if (activeShell == null) {
mapperShell = new Shell(mapperShell, style);
} else {
mapperShell = new Shell(activeShell, style);
}
this.mapperUIParent = mapperShell;
final Shell mapperShellFinal = mapperShell;
mapperShell.addShellListener(new ShellListener() {
public void shellActivated(ShellEvent e) {
}
public void shellClosed(ShellEvent e) {
UIManager uiManager = mapperManager.getUiManager();
if (uiManager.getMapperResponse() == SWT.NONE) {
for (DataMapTableView dataMapTableView : uiManager.getInputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : uiManager.getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : uiManager.getVarsTablesView()) {
dataMapTableView.notifyFocusLost();
}
uiManager.setMapperResponse(SWT.CANCEL);
uiManager.prepareClosing(uiManager.getMapperResponse());
}
if (!mapperManager.componentIsReadOnly() && mapperManager.isDataChanged() && !mapperManager.getUiManager().isCloseWithoutPrompt()) {
boolean closeWindow = MessageDialog.openConfirm(mapperShellFinal, //$NON-NLS-1$
Messages.getString("MapperUI.CancelWithoutSaveModifications.Title"), //$NON-NLS-1$
Messages.getString("MapperUI.CancelWithoutSaveModifications.Message"));
if (!closeWindow) {
e.doit = false;
} else {
mapperManager.getAbstractMapComponent().setExternalData(mapperManager.getOriginalExternalData());
mapperManager.getUiManager().prepareClosing(SWT.CANCEL);
}
}
}
public void shellDeactivated(ShellEvent e) {
}
public void shellDeiconified(ShellEvent e) {
}
public void shellIconified(ShellEvent e) {
}
});
MapperComponent component = (MapperComponent) mapperManager.getAbstractMapComponent();
ExternalMapperUiProperties uiProperties = mapperManager.getUiManager().getUiProperties();
mapperShell.setImage(CoreImageProvider.getComponentIcon(component.getComponent(), ICON_SIZE.ICON_32));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
String productName = brandingService.getFullProductName();
mapperShell.setText(Messages.getString("MapperMain.ShellTitle", productName, component.getComponent().getName(), //$NON-NLS-1$
component.getUniqueName()));
Rectangle boundsMapper = uiProperties.getBoundsMapper();
if (uiProperties.isShellMaximized()) {
mapperShell.setMaximized(uiProperties.isShellMaximized());
} else {
if (uiProperties.getBoundsMapper().equals(ExternalMapperUiProperties.DEFAULT_BOUNDS_MAPPER)) {
mapperShell.setMaximized(true);
// boundsMapper = display.getBounds(); //no need this, will cause the full problems.
} else {
// // move shell at outer of display zone to avoid visual effect on loading
// Rectangle tmpBoundsMapper = new Rectangle(-boundsMapper.width, boundsMapper.y, boundsMapper.width,
// boundsMapper.height);
// shell.setBounds(tmpBoundsMapper);
boundsMapper = uiProperties.getBoundsMapper();
if (boundsMapper.x < 0) {
boundsMapper.x = 0;
}
if (boundsMapper.y < 0) {
boundsMapper.y = 0;
}
mapperShell.setBounds(boundsMapper);
}
}
createCompositeContent(model);
mapperShell.open();
return mapperShell;
}
use of org.talend.designer.mapper.MapperComponent in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public List<Problem> checkProblems(ExternalMapperData externalData) {
problems.clear();
if (externalData != null) {
checkLookupTablesKeyProblems(externalData);
ICodeProblemsChecker codeChecker = LanguageProvider.getCurrentLanguage().getCodeChecker();
if (mapperManager.isCheckSyntaxEnabled()) {
List<ExternalMapperTable> extInputTables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
List<ExternalMapperTable> extVarTables = new ArrayList<ExternalMapperTable>(externalData.getVarsTables());
List<ExternalMapperTable> extOutputTables = new ArrayList<ExternalMapperTable>(externalData.getOutputTables());
checkExpressionSyntaxProblems(extInputTables, codeChecker);
checkExpressionSyntaxProblems(extVarTables, codeChecker);
checkExpressionSyntaxProblems(extOutputTables, codeChecker);
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getAbstractMapComponent().getIncomingConnections());
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
MapperMain mapperMain = ((MapperComponent) mapperManager.getAbstractMapComponent()).getMapperMain();
ArrayList<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
checkKeysProblems(inputTables);
checkOutputTablesProblems(extOutputTables);
}
}
return getProblems();
}
use of org.talend.designer.mapper.MapperComponent 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.MapperComponent in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method testCheckLookupTablesKeyProblems.
@Test
public void testCheckLookupTablesKeyProblems() {
MapperComponent mapperComponent = createMapperComponent();
ProblemsAnalyser analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
IExternalData externalData = mapperComponent.getExternalData();
ExternalMapperTable lookupTable = (ExternalMapperTable) externalData.getInputTables().get(1);
// match mode:Unique Match +no expression
lookupTable.setMatchingMode(TMAP_MATCHING_MODE.UNIQUE_MATCH.name());
analyser.checkLookupTablesKeyProblems((ExternalMapperData) externalData);
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.name());
lookupTable.getMetadataTableEntries().get(0).setExpression("row1.newColumn1");
analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
analyser.checkLookupTablesKeyProblems((ExternalMapperData) externalData);
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.MapperComponent in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method createMapperComponent.
private MapperComponent createMapperComponent() {
IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
IComponent tMapComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_DI.getName());
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("test1");
Process process = new Process(property1);
Node tMysqlInput_1 = new Node(tMysqlComponent, process);
IMetadataTable tMysqlInput_1_table = tMysqlInput_1.getMetadataTable("tMysqlInput_1");
createMetadataColumns(tMysqlInput_1_table, 2);
Node tMysqlInput_2 = new Node(tMysqlComponent, process);
IMetadataTable tMysqlInput_2_table = tMysqlInput_2.getMetadataTable("tMysqlInput_2");
createMetadataColumns(tMysqlInput_2_table, 2);
Node tMap_1 = new Node(tMapComponent, process);
Connection row1 = new Connection(tMysqlInput_1, tMap_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row1", "row1", false);
Connection row2 = new Connection(tMysqlInput_2, tMap_1, EConnectionType.FLOW_REF, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row2", "row2", false);
tMap_1.getExternalNode().initialize();
MapperComponent mapperComponent = (MapperComponent) tMap_1.getExternalNode();
ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
ExternalMapperTable externalTable = prepareExternalData(tMysqlInput_1_table);
externalTable.setName(row1.getName());
externalData.getInputTables().add(externalTable);
externalTable = prepareExternalData(tMysqlInput_2_table);
externalTable.setName(row2.getName());
externalData.getInputTables().add(externalTable);
return mapperComponent;
}
Aggregations