use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method loadInExternalData.
private void loadInExternalData(Collection<? extends IDataMapTable> tables) {
for (IDataMapTable table : tables) {
ExternalDbMapTable externalMapperTable = new ExternalDbMapTable();
fillExternalTable(table, externalMapperTable);
ArrayList<ExternalDbMapEntry> perTableEntries = new ArrayList<ExternalDbMapEntry>();
boolean isInputTable = table instanceof InputTable;
for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
ExternalDbMapEntry externalMapperTableEntry = new ExternalDbMapEntry();
externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
if (isInputTable) {
externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
externalMapperTableEntry.setJoin(((InputColumnTableEntry) dataMapTableEntry).isJoin());
}
perTableEntries.add(externalMapperTableEntry);
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
}
}
use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class MapperMain method getMetadataListIn.
/**
* DOC amaumont Comment method "getMetadataListIn".
*/
public List<IMetadataTable> getMetadataListIn() {
List<InputTable> tables = mapperManager.getInputTables();
List<IMetadataTable> metadataTables = new ArrayList<IMetadataTable>(tables.size());
for (InputTable table : tables) {
metadataTables.add(table.getMetadataTable());
}
return metadataTables;
}
use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method prepareInputTables.
public ArrayList<InputTable> prepareInputTables(List<IOConnection> inputConnections, ExternalDbMapData externalData) {
// Map<String, ExternalMapperTable> nameToInputPersistentTable = new HashMap<String, ExternalMapperTable>();
// if (externalData != null) {
// for (ExternalMapperTable persistentTable : externalData.getInputTables()) {
// nameToInputPersistentTable.put(persistentTable.getName(), persistentTable);
// }
// }
Map<String, IOConnection> nameToConnection = new HashMap<String, IOConnection>();
for (IOConnection connection : inputConnections) {
nameToConnection.put(connection.getName(), connection);
}
ArrayList<InputTable> inputDataMapTables = new ArrayList<InputTable>();
if (externalData == null) {
for (IOConnection connection : inputConnections) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(null);
inputDataMapTables.add(inputTable);
}
} else {
ArrayList<IOConnection> remainingConnections = new ArrayList<IOConnection>(inputConnections);
for (ExternalDbMapTable persistentTable : externalData.getInputTables()) {
String name = persistentTable.getTableName() != null ? persistentTable.getTableName() : persistentTable.getName();
IOConnection connection = nameToConnection.get(name);
if (connection != null) {
remainingConnections.remove(connection);
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(persistentTable);
inputDataMapTables.add(inputTable);
}
}
// if(externalData.getInputTables().size() > 0) {
// for (IOConnection connection : remainingConnections) {
// InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
// inputTable.initFromExternalData(null);
// inputDataMapTables.add(inputTable);
// }
// }
}
// sort for put table with main connection at top position of the list
Collections.sort(inputDataMapTables, new Comparator<InputTable>() {
@Override
public int compare(InputTable o1, InputTable o2) {
if (o1.isMainConnection()) {
return -1;
} else if (o2.isMainConnection()) {
return 1;
}
return 0;
}
});
return inputDataMapTables;
}
Aggregations