use of org.talend.designer.dbmap.external.data.ExternalDbMapTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method prepareExternalData.
/**
*
* Prepare ExternalMapperData object from internal data.
*
* @param mapperModel
* @return
*/
public ExternalDbMapData prepareExternalData(MapperModel mapperModel, ExternalDbMapUiProperties uiProperties) {
ExternalDbMapData externalData = new ExternalDbMapData();
inputTables = new ArrayList<ExternalDbMapTable>();
externalData.setInputTables(inputTables);
outputTables = new ArrayList<ExternalDbMapTable>();
externalData.setOutputTables(outputTables);
varsTables = new ArrayList<ExternalDbMapTable>();
externalData.setVarsTables(varsTables);
loadInExternalData(mapperModel.getInputDataMapTables());
loadInExternalData(mapperModel.getOutputDataMapTables());
externalData.setUiProperties(uiProperties);
return externalData;
}
use of org.talend.designer.dbmap.external.data.ExternalDbMapTable 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.external.data.ExternalDbMapTable in project tdi-studio-se by Talend.
the class DbMapComponent method renameInputConnection.
@Override
public void renameInputConnection(String oldConnectionName, String newConnectionName) {
if (oldConnectionName == null || newConnectionName == null) {
throw new NullPointerException();
}
if (externalData != null) {
List<ExternalDbMapTable> inputTables = externalData.getInputTables();
for (ExternalDbMapTable table : inputTables) {
if (table.getTableName() != null && (table.getTableName().equals(oldConnectionName) || table.getName().equals(oldConnectionName))) {
table.setTableName(newConnectionName);
table.setName(newConnectionName);
TableEntryLocation oldLocation = new TableEntryLocation(oldConnectionName, null);
TableEntryLocation newLocation = new TableEntryLocation(newConnectionName, null);
replaceLocationsInAllExpressions(oldLocation, newLocation, true);
}
}
}
}
use of org.talend.designer.dbmap.external.data.ExternalDbMapTable 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