use of org.talend.designer.dbmap.language.generation.DbGenerationManager in project tdi-studio-se by Talend.
the class PostgresGenerationManager method getHandledTableName.
protected String getHandledTableName(DbMapComponent component, String name, String aliasName, boolean generateSubSql) {
List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
if (inputConnections == null) {
return name;
}
for (IConnection iconn : inputConnections) {
boolean inputIsELTDBMap = false;
INode source = iconn.getSource();
String schemaStr = "";
String tableNameStr = "";
if (source != null) {
inputIsELTDBMap = isELTDBMap(source);
if (inputIsELTDBMap) {
tableNameStr = iconn.getName();
} else {
IElementParameter schema = source.getElementParameter("ELT_SCHEMA_NAME");
IElementParameter tableName = source.getElementParameter("ELT_TABLE_NAME");
if (schema != null && schema.getValue() != null) {
schemaStr = TalendTextUtils.removeQuotes(schema.getValue().toString());
}
if (tableName != null && tableName.getValue() != null) {
tableNameStr = TalendTextUtils.removeQuotes(tableName.getValue().toString());
}
}
}
String tableName = schemaStr;
if ("".equals(tableName)) {
tableName = tableNameStr;
} else {
if (!"".equals(tableNameStr)) {
tableName = tableName + "." + tableNameStr;
}
}
if (tableName.equals(name)) {
StringBuffer sb = new StringBuffer();
if (inputIsELTDBMap && generateSubSql) {
DbMapComponent externalNode = null;
if (source instanceof DbMapComponent) {
externalNode = (DbMapComponent) source;
} else {
externalNode = (DbMapComponent) source.getExternalNode();
}
DbGenerationManager genManager = externalNode.getGenerationManager();
String deliveredTable = genManager.buildSqlSelect(externalNode, iconn.getMetadataTable().getTableName(), //$NON-NLS-1$
tabSpaceString + " ");
int begin = 1;
int end = deliveredTable.length() - 1;
if (begin <= end) {
//$NON-NLS-1$ //$NON-NLS-2$
sb.append("(").append(DbMapSqlConstants.NEW_LINE).append(tabSpaceString).append(" ");
sb.append(deliveredTable.substring(begin, end)).append(DbMapSqlConstants.NEW_LINE).append(tabSpaceString).append(//$NON-NLS-1$
" ) ");
}
if (aliasName != null && !aliasName.trim().isEmpty()) {
tableNameStr = aliasName;
}
}
StringBuffer tempExp = getSchemaAndTable(schemaStr, tableNameStr);
sb.append(tempExp);
return sb.toString();
}
}
return name;
}
use of org.talend.designer.dbmap.language.generation.DbGenerationManager in project tdi-studio-se by Talend.
the class UIManager method refreshSqlExpression.
/**
* Refresh Sql select query in the bottom tab and its title.
*/
public void refreshSqlExpression() {
if (getTabFolderEditors().getSelectionIndex() == 2) {
mapperManager.getComponent().restoreMapperModelFromInternalData();
OutputDataMapTableView selectedOutputTableView = getCurrentSelectedOutputTableView();
if (selectedOutputTableView == null) {
} else {
IDataMapTable dataMapTable = selectedOutputTableView.getDataMapTable();
String tableName = dataMapTable.getName();
DbGenerationManager generationMnager = mapperManager.getComponent().getGenerationManager();
String sql = generationMnager.buildSqlSelect(mapperManager.getComponent(), tableName);
getTabFolderEditors().getItem(2).setText(//$NON-NLS-1$
Messages.getString("TabFolderEditors.SqlSelectQuery", new Object[] { tableName }));
getTabFolderEditors().getStyledSqlText().setText(sql);
}
}
}
Aggregations