Search in sources :

Example 31 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable 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;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) Property(org.talend.core.model.properties.Property) MapperComponent(org.talend.designer.mapper.MapperComponent)

Example 32 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable 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 33 with ExternalMapperTable

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

the class ProblemsAnalyser method checkOutputTablesProblems.

/**
     * DOC amaumont Comment method "checkOutputTablesProblems".
     * 
     * @param extOutputTables
     */
private void checkOutputTablesProblems(List<ExternalMapperTable> extOutputTables) {
    ArrayList<ExternalMapperTable> rejectTables = new ArrayList<ExternalMapperTable>();
    ArrayList<ExternalMapperTable> normalTables = new ArrayList<ExternalMapperTable>();
    ArrayList<ExternalMapperTable> normalTablesWithFilter = new ArrayList<ExternalMapperTable>();
    for (ExternalMapperTable outputTable : extOutputTables) {
        if (outputTable.isReject()) {
            rejectTables.add(outputTable);
        } else if (!outputTable.isRejectInnerJoin()) {
            if (outputTable.getExpressionFilter() != null && outputTable.isActivateExpressionFilter() && //$NON-NLS-1$
            !outputTable.getExpressionFilter().trim().equals("") || outputTable.getConstraintTableEntries() != null && outputTable.getConstraintTableEntries().size() > 0) {
                normalTablesWithFilter.add(outputTable);
            } else {
                normalTables.add(outputTable);
            }
        }
    }
    if (rejectTables.size() > 0 && normalTables.size() > 0) {
        //$NON-NLS-1$
        String tables = "";
        int normalTablesListSize = normalTables.size();
        for (int i = 0; i < normalTablesListSize; i++) {
            ExternalMapperTable normalOutputTable = normalTables.get(i);
            if (i > 0) {
                //$NON-NLS-1$
                tables += ", ";
            }
            //$NON-NLS-1$ //$NON-NLS-2$
            tables += "\"" + normalOutputTable.getName() + "\"";
        }
        //$NON-NLS-1$
        String description = Messages.getString("Problem.warning.unusableReject", new Object[] { tables });
        addProblem(new Problem(null, description, ProblemStatus.WARNING));
    }
}
Also used : ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 34 with ExternalMapperTable

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

Aggregations

ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)34 ArrayList (java.util.ArrayList)20 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)13 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)11 List (java.util.List)5 HashMap (java.util.HashMap)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)4 IExternalData (org.talend.core.model.process.IExternalData)4 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)4 IConnection (org.talend.core.model.process.IConnection)3 Problem (org.talend.core.model.process.Problem)3 MapperComponent (org.talend.designer.mapper.MapperComponent)3 OutputTable (org.talend.designer.mapper.model.table.OutputTable)3 Element (org.dom4j.Element)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 InputTable (org.talend.designer.mapper.model.emf.mapper.InputTable)2 OutputTable (org.talend.designer.mapper.model.emf.mapper.OutputTable)2 UiProperties (org.talend.designer.mapper.model.emf.mapper.UiProperties)2