use of org.talend.designer.mapper.external.converter.ExternalDataConverter in project tdi-studio-se by Talend.
the class MapperMain method createModelFromExternalData.
public void createModelFromExternalData(List<IOConnection> inputs, List<IOConnection> outputs, List<IMetadataTable> outputMetadataTables, ExternalMapperData externalData, boolean checkProblems) {
if (externalData == null) {
externalData = new ExternalMapperData();
}
mapperManager.getUiManager().setUiProperties(externalData.getUiProperties());
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
this.mapperModel = converter.prepareModel(inputs, outputs, outputMetadataTables, externalData, checkProblems);
}
use of org.talend.designer.mapper.external.converter.ExternalDataConverter 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.external.converter.ExternalDataConverter 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'.");
}
Aggregations