use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class SQLBuilderDialog method deleteNoUseTable.
private void deleteNoUseTable() {
// add for bug TDI-17097
connection = (DatabaseConnection) SQLBuilderRepositoryNodeManager.getItem(SQLBuilderRepositoryNodeManager.getRoot(nodeInEditor)).getConnection();
if (SQLBuilderRepositoryNodeManager.tList instanceof List) {
if (SQLBuilderRepositoryNodeManager.tList.size() == 0) {
SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
}
} else {
SQLBuilderRepositoryNodeManager.tList = new ArrayList<MetadataTable>();
SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
}
if (SQLBuilderRepositoryNodeManager.tList == null || SQLBuilderRepositoryNodeManager.tList.size() == 0) {
return;
}
// changed for bug TDI-19892
if (node == null) {
SQLBuilderRepositoryNodeManager.tList = null;
return;
}
IRepositoryViewObject repositoryObject = node.getObject();
Item item = repositoryObject.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
manager.deleteNouseTables(((DatabaseConnectionItem) item).getConnection());
}
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method saveEMFMetadataColumn.
@SuppressWarnings("unchecked")
private static void saveEMFMetadataColumn(String id, List<MetadataColumn> columnNodes) {
DatabaseConnectionItem item = getEMFItem(id);
final DatabaseConnection connection = (DatabaseConnection) item.getConnection();
IMetadataConnection iMetadataConnection = ConvertionHelper.convert(connection);
Set<MetadataTable> tableset = ConnectionHelper.getTables(connection);
List<MetadataTable> tables = new ArrayList<MetadataTable>();
tables.addAll(tableset);
List<MetadataColumn> emfCols = new ArrayList<MetadataColumn>();
List<MetadataColumn> dbCols = new ArrayList<MetadataColumn>();
for (MetadataColumn col : columnNodes) {
for (MetadataTable table : tables) {
if (table.getLabel().equals(col.getTable().getLabel())) {
List<TdColumn> returnCols = ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection, table.getSourceName());
for (MetadataColumn emfcolumn : table.getColumns()) {
for (MetadataColumn column : returnCols) {
if (emfcolumn.getLabel().equals(col.getLabel()) && column.getLabel().equals(col.getOriginalField())) {
emfCols.add(emfcolumn);
dbCols.add(column);
}
}
}
}
}
}
saveOneMetadataColumn(emfCols, columnNodes, dbCols);
saveMetaData(item);
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method getItem.
/**
* method "getItem" get DatabaseConnectionItem by current RepositoryNode .
*
* @param newNode current RepositoryNode
* @return DatabaseConnectionItem : item current node.
*/
public static DatabaseConnectionItem getItem(RepositoryNode newNode) {
IRepositoryViewObject repositoryObject = newNode.getObject();
DatabaseConnectionItem item = (DatabaseConnectionItem) repositoryObject.getProperty().getItem();
return item;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method saveEMFQuery.
/**
* method "saveQuery" use save inputed Query to EMF's xml File.
*
* @param repositoryNode current RepositoryNode
* @param query need to save Query
*/
private void saveEMFQuery(String id, Query query, String oldQuery) {
DatabaseConnectionItem item = getEMFItem(id);
if (query != null) {
Connection connection = item.getConnection();
QueriesConnection queriesConnection = connection.getQueries();
if (queriesConnection == null) {
queriesConnection = ConnectionFactory.eINSTANCE.createQueriesConnection();
queriesConnection.setConnection(connection);
connection.setQueries(queriesConnection);
}
boolean isModify = false;
List<Query> queries = queriesConnection.getQuery();
for (Query query2 : queries) {
if (oldQuery != null && (query2.getLabel().equals(oldQuery)) || query2.getLabel().equals(query.getLabel())) {
// reset new label, if changed
query2.setLabel(query.getLabel());
query2.setComment(query.getComment());
query2.setValue(query.getValue());
// add by hywang
query2.setContextMode(query.isContextMode());
// assign id to old query without id
assignQueryId(query2, queriesConnection);
isModify = true;
}
}
if (!isModify) {
// assign id to new query
assignQueryId(query, queriesConnection);
queriesConnection.getQuery().add(query);
}
}
deleteNouseTables(item.getConnection());
saveMetaData(item);
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method deleteQueries.
/**
* method "deleteQueries" use delete Queries.
*
* @param repositoryNode databaseConnection's RepositoryNode
* @param queries need to deleted Queries
*/
public void deleteQueries(RepositoryNode repositoryNode, List<Query> queries) {
DatabaseConnectionItem item = getEMFItem(repositoryNode.getObject().getId());
for (Query query : queries) {
ProxyRepositoryFactory.getInstance().setSubItemDeleted(item, query, true);
}
saveMetaData(item);
}
Aggregations