Search in sources :

Example 16 with ExternalMapperTableEntry

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

the class MapperComponentDocumentation method generateMapperTablesInfo.

/**
     * This method used for generating all mapper tables information into xml file.
     * 
     * @param externalNodeElement
     * @param tables
     * @param mapperTableType
     */
private void generateMapperTablesInfo(Element externalNodeElement, List<ExternalMapperTable> tables, String mapperTableType) {
    //$NON-NLS-1$
    Element mapperTableElement = externalNodeElement.addElement("mapperTable");
    //$NON-NLS-1$
    mapperTableElement.addAttribute("type", HTMLDocUtils.checkString(mapperTableType));
    Element tableElement = null;
    for (ExternalMapperTable table : tables) {
        //$NON-NLS-1$
        tableElement = mapperTableElement.addElement("table");
        generateTableSummaryInfo(mapperTableElement, tableElement, table);
        List<ExternalMapperTableEntry> globalMapKeysValuesEntries = table.getGlobalMapKeysValues();
        if (HTMLDocUtils.checkList(globalMapKeysValuesEntries)) {
            //$NON-NLS-1$
            Element globalMapKeysValuesElement = tableElement.addElement("globalMapKeysValues");
            for (ExternalMapperTableEntry entry : globalMapKeysValuesEntries) {
                generateTablesEntriesInfo(globalMapKeysValuesElement, entry);
            }
        }
        List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
        if (HTMLDocUtils.checkList(metadataTableEntries)) {
            //$NON-NLS-1$
            Element metadataTableEntriesElement = tableElement.addElement("metadataTableEntries");
            for (ExternalMapperTableEntry entry : metadataTableEntries) {
                generateTablesEntriesInfo(metadataTableEntriesElement, entry);
            }
        }
        List<ExternalMapperTableEntry> constraintTableEntries = table.getConstraintTableEntries();
        if (HTMLDocUtils.checkList(constraintTableEntries)) {
            //$NON-NLS-1$
            Element constraintTableEntriesElement = tableElement.addElement("constraintTableEntries");
            for (ExternalMapperTableEntry entry : constraintTableEntries) {
                generateTablesEntriesInfo(constraintTableEntriesElement, entry);
            }
        }
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) Element(org.dom4j.Element) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 17 with ExternalMapperTableEntry

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

the class ProblemsAnalyserTest method prepareExternalData.

private ExternalMapperTable prepareExternalData(IMetadataTable table) {
    ExternalMapperTable externalMapperTable = new ExternalMapperTable();
    ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
    for (IMetadataColumn column : table.getListColumns()) {
        ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
        externalMapperTableEntry.setName(column.getLabel());
        externalMapperTableEntry.setType(column.getTalendType());
        externalMapperTableEntry.setNullable(column.isNullable());
        perTableEntries.add(externalMapperTableEntry);
    }
    externalMapperTable.setMetadataTableEntries(perTableEntries);
    return externalMapperTable;
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 18 with ExternalMapperTableEntry

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

the class ProblemsAnalyser method checkExpressionSyntaxProblems.

/**
     * DOC amaumont Comment method "checkExpressionSyntaxProblems".
     * 
     * @param tables
     * @param codeChecker
     */
private void checkExpressionSyntaxProblems(List<ExternalMapperTable> tables, ICodeProblemsChecker codeChecker) {
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    boolean keyLanguageCheckerIsUsed = currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA;
    for (ExternalMapperTable table : tables) {
        List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
        // loop on all entries of current table
        if (metadataTableEntries != null) {
            checkExpressionSyntaxProblems(codeChecker, currentLanguage, keyLanguageCheckerIsUsed, table, metadataTableEntries, JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN);
        }
        List<ExternalMapperTableEntry> globalMapKeysValues = table.getGlobalMapKeysValues();
        // loop on all entries of current table
        if (globalMapKeysValues != null) {
            checkExpressionSyntaxProblems(codeChecker, currentLanguage, keyLanguageCheckerIsUsed, table, globalMapKeysValues, JavaGenerationManager.PROBLEM_KEY_FIELD.GLOBAL_MAP);
        }
        if (table.getConstraintTableEntries() != null || table.isActivateExpressionFilter() && table.getExpressionFilter() != null && !table.getExpressionFilter().trim().equals("")) {
            //$NON-NLS-1$
            //$NON-NLS-1$ //$NON-NLS-2$
            String prefix = "Filter invalid in table " + table.getName() + " : ";
            if (table.getConstraintTableEntries() != null) {
                for (ExternalMapperTableEntry entry : table.getConstraintTableEntries()) {
                    checkFilterEntry(codeChecker, keyLanguageCheckerIsUsed, table, prefix, entry.getExpression());
                }
            }
            if (table.isActivateExpressionFilter() && table.getExpressionFilter() != null && !table.getExpressionFilter().trim().equals("")) {
                //$NON-NLS-1$
                checkFilterEntry(codeChecker, keyLanguageCheckerIsUsed, table, prefix, table.getExpressionFilter());
            }
        }
    }
// for (ExternalMapperTable table : tables) {
}
Also used : ILanguage(org.talend.designer.mapper.language.ILanguage) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 19 with ExternalMapperTableEntry

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

the class MapperHelper method isGeneratedAsVirtualComponent.

/**
     * 
     * DOC YeXiaowei Comment method "isGeneratedAsVirtualComponent".
     * 
     * @param mapperNode
     * @return
     */
public static boolean isGeneratedAsVirtualComponent(final INode mapperNode) {
    if (isMapperOnBigDataProcess(mapperNode.getComponent().getPaletteType())) {
        return false;
    }
    boolean hasPersistentSortedLookup = false;
    List<IConnection> incomingConnections = (List<IConnection>) mapperNode.getIncomingConnections();
    ExternalMapperData internalExternalData = (ExternalMapperData) mapperNode.getExternalNode().getExternalData();
    if (internalExternalData != null && incomingConnections.size() > 0) {
        List<ExternalMapperTable> inputTables = internalExternalData.getInputTables();
        int sizeInputTables = inputTables.size();
        HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
        for (IConnection connection : incomingConnections) {
            hNameToConnection.put(connection.getName(), connection);
        }
        for (int iInputTable = 1; iInputTable < sizeInputTables; iInputTable++) {
            // T_TM_M_241
            ExternalMapperTable inputTable = inputTables.get(iInputTable);
            String tableName = inputTable.getName();
            IConnection connection = hNameToConnection.get(tableName);
            if (connection == null) {
                continue;
            }
            if (inputTable != null) {
                // T_TM_M_245
                List<ExternalMapperTableEntry> metadataTableEntries = inputTable.getMetadataTableEntries();
                if (metadataTableEntries == null) {
                    continue;
                }
                if (inputTable.isPersistent() && !"ALL_ROWS".equals(inputTable.getMatchingMode()) && !"DYNAMIC".equals(inputTable.getLookupMode())) {
                    //$NON-NLS-1$  //$NON-NLS-2$
                    hasPersistentSortedLookup = true;
                }
            }
        // T_TM_M_245
        }
    // T_TM_M_241
    }
    return hasPersistentSortedLookup;
}
Also used : HashMap(java.util.HashMap) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) IConnection(org.talend.core.model.process.IConnection) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with ExternalMapperTableEntry

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

the class AbstractInOutTable method updateTableEntries.

private void updateTableEntries(List<IMetadataColumn> columns, Map<String, ExternalMapperTableEntry> nameToPerTabEntry) {
    for (IMetadataColumn column : columns) {
        AbstractInOutTableEntry columnEntry = getNewTableEntry(column);
        ExternalMapperTableEntry externalMapperTableEntry = nameToPerTabEntry.get(columnEntry.getMetadataColumn().getLabel());
        if (externalMapperTableEntry != null) {
            columnEntry.setExpression(externalMapperTableEntry.getExpression());
            if (columnEntry instanceof InputColumnTableEntry) {
                InputColumnTableEntry entry = (InputColumnTableEntry) columnEntry;
                entry.setOperator(externalMapperTableEntry.getOperator());
            }
        // mapperManager.getProblemsManager().checkProblemsForTableEntry(columnEntry, false);
        }
        dataMapTableEntries.add(columnEntry);
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

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