Search in sources :

Example 1 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class MapperHelper method getPersistentTableEntitys.

private static List<MapperTableEntry> getPersistentTableEntitys(List<ExternalMapperTableEntry> entities) {
    List<MapperTableEntry> persistentEntities = new ArrayList<MapperTableEntry>();
    for (ExternalMapperTableEntry entity : entities) {
        final MapperTableEntry emfMapperTableEntry = MapperFactory.eINSTANCE.createMapperTableEntry();
        emfMapperTableEntry.setExpression(entity.getExpression());
        emfMapperTableEntry.setName(entity.getName());
        emfMapperTableEntry.setNullable(entity.isNullable());
        emfMapperTableEntry.setType(entity.getType());
        emfMapperTableEntry.setOperator(entity.getOperator());
        persistentEntities.add(emfMapperTableEntry);
    }
    return persistentEntities;
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) MapperTableEntry(org.talend.designer.mapper.model.emf.mapper.MapperTableEntry) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList)

Example 2 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class ProblemsAnalyser method checkExpressionSyntaxProblems.

private void checkExpressionSyntaxProblems(ICodeProblemsChecker codeChecker, ILanguage currentLanguage, boolean keyLanguageCheckerIsUsed, ExternalMapperTable table, List<ExternalMapperTableEntry> entries, PROBLEM_KEY_FIELD problemKeyField) {
    for (ExternalMapperTableEntry entry : entries) {
        List<Problem> problems = null;
        if (keyLanguageCheckerIsUsed) {
            String key = mapperManager.buildProblemKey(problemKeyField, table.getName(), entry.getName());
            problems = codeChecker.getProblemsFromKey(key);
        } else {
            problems = checkCodeProblems(entry.getExpression());
        }
        if (problems != null) {
            String location = currentLanguage.getLocation(table.getName(), entry.getName());
            //$NON-NLS-1$ //$NON-NLS-2$  //$NON-NLS-3$
            String prefix = "Expression of " + problemKeyField.getLabel() + " " + location + " is invalid : ";
            for (Problem problem : problems) {
                if (!problem.getDescription().startsWith(prefix)) {
                    //$NON-NLS-1$
                    String description = prefix + problem.getDescription() + ".";
                    problem.setDescription(description);
                }
                addProblem(problem);
            }
        }
    }
// for (ExternalMapperTableEntry entry : metadataTableEntries) {
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) Problem(org.talend.core.model.process.Problem)

Example 3 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class ProblemsAnalyser method checkLookupTablesKeyProblems.

public void checkLookupTablesKeyProblems(ExternalMapperData externalData) {
    List<ExternalMapperTable> lookupTables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
    List<? extends IConnection> mainConnections = mapperManager.getAbstractMapComponent().getIncomingConnections(EConnectionType.FLOW_MAIN);
    if (mainConnections.size() == 1) {
        ExternalMapperTable mainTable = null;
        for (ExternalMapperTable table : lookupTables) {
            if (mainConnections.get(0).getName().equals(table.getName())) {
                mainTable = table;
                break;
            }
        }
        if (mainTable != null) {
            lookupTables.remove(mainTable);
        }
    }
    for (ExternalMapperTable table : lookupTables) {
        List<ExternalMapperTableEntry> columnEntries = table.getMetadataTableEntries();
        boolean atLeastOneExpressionFilled = false;
        for (ExternalMapperTableEntry entry : columnEntries) {
            if (!StringUtils.isEmpty(entry.getExpression())) {
                atLeastOneExpressionFilled = true;
                break;
            }
        }
        if (!atLeastOneExpressionFilled) {
            String matchingMode = table.getMatchingMode();
            if (!TMAP_MATCHING_MODE.ALL_ROWS.name().equals(matchingMode)) {
                addProblem(new Problem(null, //$NON-NLS-1$ //$NON-NLS-2$
                "The lookup table '" + table.getName() + "' should have at least one expression key filled.", ProblemStatus.WARNING));
            }
        } else {
            String matchingMode = table.getMatchingMode();
            if (TMAP_MATCHING_MODE.ALL_ROWS.name().equals(matchingMode)) {
                addProblem(new Problem(null, "The expression key can't be used in lookup table '" + table.getName() + "' with match mode 'All Rows'.", ProblemStatus.WARNING));
            }
        }
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 4 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class OutputTable method initFromExternalData.

public void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        this.reject = externalMapperTable.isReject();
        this.rejectInnerJoin = externalMapperTable.isRejectInnerJoin();
        this.isJoinTableOf = externalMapperTable.getIsJoinTableOf();
        this.isErrorRejectTable = externalMapperTable.isErrorRejectTable();
        List<ExternalMapperTableEntry> externalConstraintTableEntries = externalMapperTable.getConstraintTableEntries();
        if (externalConstraintTableEntries != null) {
            if (!mapperManager.isAdvancedMap()) {
                for (ExternalMapperTableEntry entry : externalConstraintTableEntries) {
                    FilterTableEntry filterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression());
                    // mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
                    addFilterEntry(filterTableEntry);
                }
            } else {
                ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
                JavaGenerationManager javaGenerationManager = new JavaGenerationManager(currentLanguage);
                DataMapExpressionParser expressionParser = new DataMapExpressionParser(currentLanguage);
                String expressionFilter = javaGenerationManager.buildConditions(externalConstraintTableEntries, expressionParser);
                if (!expressionFilter.trim().equals("")) {
                    //$NON-NLS-1$
                    this.getExpressionFilter().setExpression(expressionFilter);
                    this.setActivateExpressionFilter(true);
                }
            }
        }
    }
}
Also used : ILanguage(org.talend.designer.mapper.language.ILanguage) JavaGenerationManager(org.talend.designer.mapper.language.generation.JavaGenerationManager) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) DataMapExpressionParser(org.talend.designer.mapper.utils.DataMapExpressionParser) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry)

Example 5 with ExternalMapperTableEntry

use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.

the class VarsTable method initFromExternalData.

public void initFromExternalData(ExternalMapperTable externalMapperTable) {
    super.initFromExternalData(externalMapperTable);
    if (externalMapperTable != null) {
        List<ExternalMapperTableEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
        if (metadataTableEntries != null) {
            for (ExternalMapperTableEntry externalMapperTableEntry : metadataTableEntries) {
                VarTableEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getType());
                // mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
                if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
                    varTableEntry.setNullable(externalMapperTableEntry.isNullable());
                }
                addColumnEntry(varTableEntry);
            }
        }
    } else {
        setMinimized(true);
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry)

Aggregations

ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)22 ArrayList (java.util.ArrayList)15 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 AbstractInOutTableEntry (org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)3 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)3 HashMap (java.util.HashMap)2 Problem (org.talend.core.model.process.Problem)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)2 ILanguage (org.talend.designer.mapper.language.ILanguage)2 MapperTableEntry (org.talend.designer.mapper.model.emf.mapper.MapperTableEntry)2 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)2 DataMapExpressionParser (org.talend.designer.mapper.utils.DataMapExpressionParser)2 List (java.util.List)1 Pattern (org.apache.oro.text.regex.Pattern)1 PatternMatcher (org.apache.oro.text.regex.PatternMatcher)1 Perl5Matcher (org.apache.oro.text.regex.Perl5Matcher)1