use of org.talend.designer.mapper.external.data.ExternalMapperTable 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;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class MapperComponent method renameMetadataColumnName.
@Override
protected void renameMetadataColumnName(String conectionName, String oldColumnName, String newColumnName) {
if (conectionName == null || oldColumnName == null || newColumnName == null) {
throw new NullPointerException();
}
if (externalData != null) {
// rename metadata column name
List<ExternalMapperTable> tables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
tables.addAll(externalData.getOutputTables());
ExternalMapperTable tableFound = null;
for (ExternalMapperTable table : tables) {
if (table.getName().equals(conectionName)) {
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
for (ExternalMapperTableEntry entry : metadataTableEntries) {
if (entry.getName().equals(oldColumnName)) {
entry.setName(newColumnName);
tableFound = table;
break;
}
}
break;
}
}
// it is necessary to update expressions only if renamed column come from input table
if (tableFound != null && externalData.getInputTables().indexOf(tableFound) != -1) {
TableEntryLocation oldLocation = new TableEntryLocation(conectionName, oldColumnName);
TableEntryLocation newLocation = new TableEntryLocation(conectionName, newColumnName);
replaceLocationsInAllExpressions(oldLocation, newLocation, false);
}
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class MapperComponent method renameInputConnection.
public void renameInputConnection(String oldConnectionName, String newConnectionName) {
if (oldConnectionName == null || newConnectionName == null) {
throw new NullPointerException();
}
if (externalData != null) {
List<ExternalMapperTable> inputTables = externalData.getInputTables();
for (ExternalMapperTable table : inputTables) {
if (table.getName().equals(oldConnectionName)) {
table.setName(newConnectionName);
TableEntryLocation oldLocation = new TableEntryLocation(oldConnectionName, null);
TableEntryLocation newLocation = new TableEntryLocation(newConnectionName, null);
replaceLocationsInAllExpressions(oldLocation, newLocation, true);
break;
}
}
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class DesignerMapperService method renameJoinTable.
/*
* (non-Javadoc)
*
* @see org.talend.designer.mapper.IDesignerMapperService#renameJoinTable(java.lang.Process,
* org.talend.core.model.process.IExternalData, java.util.List)
*/
public void renameJoinTable(IProcess process, IExternalData data, List<String> createdNames) {
if (data instanceof ExternalMapperData) {
ExternalMapperData extenalData = (ExternalMapperData) data;
final List<ExternalMapperTable> outputTables = extenalData.getOutputTables();
if (outputTables != null) {
for (ExternalMapperTable table : outputTables) {
if (table.getIsJoinTableOf() != null && !"".equals(table.getIsJoinTableOf())) {
final String newName = createNewConnectionName(process, table.getName(), createdNames);
table.setName(newName);
}
}
}
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class DesignerMapperService method isSameMetadata.
public boolean isSameMetadata(IExternalNode externalNode, String schemaId, IMetadataTable metadataTable) {
boolean isSame = true;
if (externalNode == null || schemaId == null || metadataTable == null) {
return false;
}
if (externalNode instanceof MapperComponent) {
MapperComponent component = (MapperComponent) externalNode;
IExternalData nodeData = externalNode.getExternalData();
if (nodeData != null && nodeData instanceof ExternalMapperData) {
ExternalMapperData mapperData = (ExternalMapperData) nodeData;
List<ExternalMapperTable> outputTables = mapperData.getOutputTables();
if (outputTables != null && outputTables.size() > 0) {
for (ExternalMapperTable outputTable : outputTables) {
if (schemaId.equals(outputTable.getId())) {
final IMetadataTable mapperTable = getMetadataTable(component, outputTable.getName());
if (mapperTable == null || !mapperTable.sameMetadataAs(metadataTable, IMetadataColumn.OPTIONS_NONE)) {
return false;
}
}
}
}
// for (ExternalMapperTable extTable : extTables) {
// isSame = isMetadataSame(extTable, metadataTable);
// if (!isSame)
// return isSame;
// }
}
}
return isSame;
}
Aggregations