Search in sources :

Example 1 with MapperMain

use of org.talend.designer.mapper.MapperMain 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();
}
Also used : ExternalDataConverter(org.talend.designer.mapper.external.converter.ExternalDataConverter) InputTable(org.talend.designer.mapper.model.table.InputTable) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) ArrayList(java.util.ArrayList) ICodeProblemsChecker(org.talend.core.language.ICodeProblemsChecker) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) MapperMain(org.talend.designer.mapper.MapperMain) MapperComponent(org.talend.designer.mapper.MapperComponent)

Example 2 with MapperMain

use of org.talend.designer.mapper.MapperMain 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)

Aggregations

ArrayList (java.util.ArrayList)2 MapperComponent (org.talend.designer.mapper.MapperComponent)2 MapperMain (org.talend.designer.mapper.MapperMain)2 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)2 ExternalDataConverter (org.talend.designer.mapper.external.converter.ExternalDataConverter)2 InputTable (org.talend.designer.mapper.model.table.InputTable)2 Test (org.junit.Test)1 ICodeProblemsChecker (org.talend.core.language.ICodeProblemsChecker)1 Problem (org.talend.core.model.process.Problem)1 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)1 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)1 MapperManager (org.talend.designer.mapper.managers.MapperManager)1