Search in sources :

Example 86 with IMetadataTable

use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.

the class DbGenerationManager method getConnectionContextList.

protected List<String> getConnectionContextList(DbMapComponent component) {
    List<String> contextList = new ArrayList<String>();
    List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
    List<Map<String, String>> itemNameList = null;
    for (IConnection iconn : inputConnections) {
        String connName = iconn.getName();
        if (!ContextParameterUtils.containContextVariables(connName)) {
            continue;
        }
        //$NON-NLS-1$
        MapExpressionParser mapParser1 = new MapExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
        itemNameList = mapParser1.parseInTableEntryLocations(connName);
        if (itemNameList == null) {
            return contextList;
        }
        IMetadataTable metadataTable = iconn.getMetadataTable();
        for (Map<String, String> itemNamemap : itemNameList) {
            Set<Entry<String, String>> set = itemNamemap.entrySet();
            Iterator<Entry<String, String>> ite = set.iterator();
            while (ite.hasNext()) {
                Entry<String, String> entry = ite.next();
                String tableValue = entry.getKey();
                String schemaValue = entry.getValue();
                if (metadataTable != null && tableValue.equals(metadataTable.getLabel())) {
                    if (!contextList.contains(schemaValue)) {
                        contextList.add(schemaValue);
                    }
                }
            }
        }
    }
    return contextList;
}
Also used : ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 87 with IMetadataTable

use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.

the class DbGenerationManager method getOriginalColumnName.

private String getOriginalColumnName(String entryName, DbMapComponent component, ExternalDbMapTable table) {
    List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
    if (inputConnections != null) {
        for (IConnection iconn : inputConnections) {
            IMetadataTable metadataTable = iconn.getMetadataTable();
            String tName = iconn.getName();
            String tableValue = table.getTableName();
            if (tableValue != null && tableValue.equals(tName) && metadataTable != null) {
                List<IMetadataColumn> lColumn = metadataTable.getListColumns();
                for (IMetadataColumn colu : lColumn) {
                    if (colu.getLabel().equals(entryName)) {
                        String tempName = colu.getOriginalDbColumnName();
                        if (tempName != null && tempName.length() > 0) {
                            entryName = tempName;
                            return entryName;
                        }
                    }
                }
            }
        }
    }
    return entryName;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 88 with IMetadataTable

use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.

the class ExternalDataConverter method prepareOutputTables.

public ArrayList<OutputTable> prepareOutputTables(List<IOConnection> outputConnections, List<IMetadataTable> outputMetadataTables, ExternalDbMapData externalData) {
    Map<String, ExternalDbMapTable> nameToOutpuPersistentTable = new HashMap<String, ExternalDbMapTable>();
    if (externalData != null) {
        for (ExternalDbMapTable persistentTable : externalData.getOutputTables()) {
            nameToOutpuPersistentTable.put(persistentTable.getName(), persistentTable);
        }
    }
    Map<String, IOConnection> nameToOutputConn = new HashMap<String, IOConnection>();
    if (outputConnections != null) {
        for (IOConnection connection : outputConnections) {
            if (connection.getConnectionType().equals(EConnectionType.FLOW_MAIN) || connection.getConnectionType().equals(EConnectionType.FLOW_REF) || connection.getConnectionType().equals(EConnectionType.TABLE) || connection.getConnectionType().equals(EConnectionType.TABLE_REF)) {
                nameToOutputConn.put(connection.getUniqueName(), connection);
            }
        }
    }
    ArrayList<OutputTable> outputDataMapTables = new ArrayList<OutputTable>();
    for (IMetadataTable table : outputMetadataTables) {
        IOConnection connection = nameToOutputConn.get(table.getTableName());
        OutputTable outputTable = null;
        if (connection != null) {
            ExternalDbMapTable persistentTable = nameToOutpuPersistentTable.get(connection.getUniqueName());
            outputTable = new OutputTable(this.mapperManager, table.clone(), connection.getUniqueName(), connection.getName());
            outputTable.initFromExternalData(persistentTable);
        } else {
            ExternalDbMapTable persistentTable = nameToOutpuPersistentTable.get(table.getTableName());
            if (persistentTable != null) {
                outputTable = new OutputTable(this.mapperManager, table, persistentTable.getName(), persistentTable.getTableName());
                outputTable.initFromExternalData(persistentTable);
            } else {
                outputTable = new OutputTable(this.mapperManager, table, table.getTableName(), table.getLabel());
            }
        }
        if (outputTable != null) {
            outputDataMapTables.add(outputTable);
        }
    }
    return outputDataMapTables;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HashMap(java.util.HashMap) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ArrayList(java.util.ArrayList) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 89 with IMetadataTable

use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.

the class MapperMain method getMetadataListOut.

/**
     * DOC amaumont Comment method "getMetadataListOut".
     * 
     * @return
     */
public List<IMetadataTable> getMetadataListOut() {
    List<OutputTable> tables = mapperManager.getOutputTables();
    List<IMetadataTable> metadataTables = new ArrayList<IMetadataTable>(tables.size());
    for (OutputTable table : tables) {
        metadataTables.add(table.getMetadataTable());
    }
    return metadataTables;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 90 with IMetadataTable

use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.

the class ExternalDataConverter method prepareOutputTables.

private ArrayList<OutputTable> prepareOutputTables(List<IOConnection> outputConnections, List<IMetadataTable> outputMetadataTables, ExternalMapperData externalData) {
    Map<String, List<ExternalMapperTable>> nameToOutpuPersistentTable = new HashMap<String, List<ExternalMapperTable>>();
    if (externalData != null) {
        for (ExternalMapperTable persistentTable : externalData.getOutputTables()) {
            String key = persistentTable.getName();
            if (persistentTable.getIsJoinTableOf() != null) {
                key = persistentTable.getIsJoinTableOf();
            }
            List<ExternalMapperTable> list = nameToOutpuPersistentTable.get(key);
            if (list != null) {
                list.add(persistentTable);
            } else {
                list = new ArrayList<ExternalMapperTable>();
                list.add(persistentTable);
                nameToOutpuPersistentTable.put(key, list);
            }
        }
    }
    Map<String, IOConnection> nameMetadataToOutpuConn = new HashMap<String, IOConnection>();
    if (outputConnections != null) {
        for (IOConnection connection : outputConnections) {
            if (connection.getConnectionType().equals(EConnectionType.FLOW_MAIN) || connection.getConnectionType().equals(EConnectionType.FLOW_REF) || connection.getConnectionType().equals(EConnectionType.FLOW_MERGE)) {
                nameMetadataToOutpuConn.put(connection.getTable().getTableName(), connection);
            }
        }
    }
    ArrayList<OutputTable> outputDataMapTables = new ArrayList<OutputTable>();
    for (IMetadataTable table : outputMetadataTables) {
        IOConnection connection = nameMetadataToOutpuConn.get(table.getTableName());
        if (connection != null) {
            List<ExternalMapperTable> persistentTables = nameToOutpuPersistentTable.get(connection.getName());
            creatOutputTables(outputDataMapTables, persistentTables, connection.getTable(), connection, connection.getName());
        } else {
            List<ExternalMapperTable> persistentTables = nameToOutpuPersistentTable.get(table.getTableName());
            creatOutputTables(outputDataMapTables, persistentTables, table, null, table.getTableName());
        }
    }
    return outputDataMapTables;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

IMetadataTable (org.talend.core.model.metadata.IMetadataTable)212 ArrayList (java.util.ArrayList)102 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)81 IElementParameter (org.talend.core.model.process.IElementParameter)67 IConnection (org.talend.core.model.process.IConnection)66 List (java.util.List)56 INode (org.talend.core.model.process.INode)54 Node (org.talend.designer.core.ui.editor.nodes.Node)50 HashMap (java.util.HashMap)48 Map (java.util.Map)39 MetadataTable (org.talend.core.model.metadata.MetadataTable)34 INodeConnector (org.talend.core.model.process.INodeConnector)32 Connection (org.talend.designer.core.ui.editor.connections.Connection)28 Process (org.talend.designer.core.ui.editor.process.Process)25 IComponent (org.talend.core.model.components.IComponent)22 ConnectionItem (org.talend.core.model.properties.ConnectionItem)20 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)18 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)17 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 Point (org.eclipse.swt.graphics.Point)15