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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations