Search in sources :

Example 16 with ExternalMapperData

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

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

ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)17 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)13 ArrayList (java.util.ArrayList)6 IExternalData (org.talend.core.model.process.IExternalData)3 MapperData (org.talend.designer.mapper.model.emf.mapper.MapperData)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 IConnection (org.talend.core.model.process.IConnection)2 MapperComponent (org.talend.designer.mapper.MapperComponent)2 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)2 ExternalDataConverter (org.talend.designer.mapper.external.converter.ExternalDataConverter)2 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)2 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 MarshalException (org.exolab.castor.xml.MarshalException)1 Unmarshaller (org.exolab.castor.xml.Unmarshaller)1 ValidationException (org.exolab.castor.xml.ValidationException)1 Test (org.junit.Test)1 IComponent (org.talend.core.model.components.IComponent)1