use of org.talend.core.service.IDbMapService in project tdi-studio-se by Talend.
the class UpdateELTComponentMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
boolean isModified = false;
ProcessType processType = getProcessType(item);
List nodes = processType.getNode();
List<ConnectionType> connections = processType.getConnection();
for (ConnectionType connection : connections) {
String sourceNodeName = connection.getSource();
String targetNodeName = connection.getTarget();
if (sourceNodeName.matches("tELT.+Input.+") && targetNodeName.matches("tELT.+Map.+")) {
//$NON-NLS-1$ //$NON-NLS-2$
NodeType eltInputNode = getNodeTypeByUniqueName(nodes, sourceNodeName);
//$NON-NLS-1$
String orginalTableName = getPropertyValue(eltInputNode, "ELT_TABLE_NAME");
//$NON-NLS-1$
String orginalSchemaName = getPropertyValue(eltInputNode, "ELT_SCHEMA_NAME");
if (orginalSchemaName == null) {
continue;
}
String tableName = TalendQuoteUtils.removeQuotes(orginalTableName);
String schemaName = TalendQuoteUtils.removeQuotes(orginalSchemaName);
String connectionName;
if (schemaName.trim().equals("")) {
//$NON-NLS-1$
connectionName = tableName;
} else {
//$NON-NLS-1$
connectionName = schemaName + "." + tableName;
}
if (connection.getLabel().equals(tableName)) {
connection.setLabel(connectionName);
isModified = true;
}
List<MetadataTypeImpl> tables = eltInputNode.getMetadata();
for (MetadataTypeImpl table : tables) {
if (table.getLabel().equals(tableName)) {
table.setLabel(connectionName);
isModified = true;
}
}
NodeType eltMapNode = getNodeTypeByUniqueName(nodes, targetNodeName);
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDbMapService.class)) {
IDbMapService service = (IDbMapService) GlobalServiceRegister.getDefault().getService(IDbMapService.class);
service.updateEMFDBMapData(eltMapNode, tableName, connectionName);
isModified = true;
}
}
}
if (isModified) {
try {
ProxyRepositoryFactory.getInstance().save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations