use of com.cubrid.common.ui.spi.progress.OpenTablesDetailInfoPartProgress in project cubrid-manager by CUBRID.
the class TableSchemaCompareInfoPart method getTableInfoList.
/**
* Returns all tables detail of a database
*
* @param db
* @return
*/
public List<TableDetailInfo> getTableInfoList(CubridDatabase db) {
// FIXME logic code move to core module
OpenTablesDetailInfoPartProgress progress = new OpenTablesDetailInfoPartProgress(db);
List<TableDetailInfo> tableList = new ArrayList<TableDetailInfo>();
Map<String, TableDetailInfo> map = new HashMap<String, TableDetailInfo>();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = JDBCConnectionManager.getConnection(db.getDatabaseInfo(), true);
if (!progress.loadUserSchemaList(conn, map)) {
return tableList;
}
Set<String> tableNameSet = map.keySet();
if (tableNameSet == null) {
return tableList;
}
List<String> tableNames = new ArrayList<String>();
for (String tableName : tableNameSet) {
tableNames.add(tableName);
}
Collections.sort(tableNames);
List<String> partitionClasses = new ArrayList<String>();
for (String tableName : tableNames) {
TableDetailInfo info = map.get(tableName);
if ("YES".equals(info.getPartitioned())) {
String sql = "SELECT b.* FROM db_partition a, db_class b " + "WHERE a.class_name='" + tableName.toLowerCase(Locale.getDefault()) + "' AND LOWER(b.class_name)=LOWER(a.partition_class_name)";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
String className = rs.getString("class_name");
partitionClasses.add(className);
}
QueryUtil.freeQuery(stmt, rs);
}
if (info.getClassType().equals("CLASS") && !partitionClasses.contains(tableName)) {
info.setRecordsCount(-1);
tableList.add(info);
}
}
} catch (Exception e) {
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn, stmt, rs);
}
return tableList;
}
use of com.cubrid.common.ui.spi.progress.OpenTablesDetailInfoPartProgress in project cubrid-manager by CUBRID.
the class TableSchemaCompareRunner method getTableInfoList.
/**
* Returns all tables detail of a database
*
* @param db
* @return
*/
private List<TableDetailInfo> getTableInfoList(CubridDatabase db) {
// FIXME logic code move to core module
OpenTablesDetailInfoPartProgress progress = new OpenTablesDetailInfoPartProgress(db);
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = JDBCConnectionManager.getConnection(db.getDatabaseInfo(), true);
Map<String, TableDetailInfo> map = new HashMap<String, TableDetailInfo>();
if (!progress.loadUserSchemaList(conn, map)) {
return null;
}
Set<String> tableNameSet = map.keySet();
List<TableDetailInfo> tableList = new ArrayList<TableDetailInfo>();
if (tableNameSet != null) {
List<String> tableNames = new ArrayList<String>();
for (String tableName : tableNameSet) {
tableNames.add(tableName);
}
Collections.sort(tableNames);
List<String> partitionClasses = new ArrayList<String>();
for (String tableName : tableNames) {
TableDetailInfo info = map.get(tableName);
if (dialog.isCanceled()) {
return null;
}
if ("YES".equals(info.getPartitioned())) {
String sql = "SELECT b.* FROM db_partition a, db_class b " + "WHERE a.class_name='" + tableName.toLowerCase(Locale.getDefault()) + "' AND LOWER(b.class_name)=LOWER(a.partition_class_name)";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
if (dialog.isCanceled()) {
return null;
}
String className = rs.getString("class_name");
partitionClasses.add(className);
}
QueryUtil.freeQuery(stmt, rs);
}
if ("CLASS".equals(info.getClassType()) && !partitionClasses.contains(tableName)) {
info.setRecordsCount(-1);
tableList.add(info);
}
}
}
return tableList;
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
QueryUtil.freeQuery(conn, stmt, rs);
}
return null;
}
use of com.cubrid.common.ui.spi.progress.OpenTablesDetailInfoPartProgress in project cubrid-manager by CUBRID.
the class TableSchemaCompareUtil method getTableInfoList.
/**
* Returns all tables detail of a database
*
* @param db
* @return
*/
public static List<TableDetailInfo> getTableInfoList(CubridDatabase db) {
// FIXME logic code move to core module
if (db.isVirtual()) {
return new ArrayList<TableDetailInfo>();
}
OpenTablesDetailInfoPartProgress progress = new OpenTablesDetailInfoPartProgress(db);
List<TableDetailInfo> tableList = null;
Connection conn = null;
try {
conn = JDBCConnectionManager.getConnection(db.getDatabaseInfo(), true);
Map<String, TableDetailInfo> map = new HashMap<String, TableDetailInfo>();
if (!progress.loadUserSchemaList(conn, map)) {
return null;
}
tableList = new ArrayList<TableDetailInfo>();
Set<String> tableNameSet = map.keySet();
if (tableNameSet != null) {
List<String> tableNames = new ArrayList<String>();
for (String tableName : tableNameSet) {
tableNames.add(tableName);
}
Collections.sort(tableNames);
for (String tableName : tableNames) {
TableDetailInfo info = map.get(tableName);
String classType = info.getClassType();
if (classType.equals("CLASS") || classType.equals("VCLASS")) {
info.setRecordsCount(-1);
tableList.add(info);
}
}
}
} catch (Exception e) {
tableList = null;
LOGGER.error(e.getMessage(), e);
}
return tableList;
}
use of com.cubrid.common.ui.spi.progress.OpenTablesDetailInfoPartProgress in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method refresh.
/**
* Refresh all data
*/
private void refresh() {
if (CommonUITool.openConfirmBox(Messages.tablesDetailInfoPartRefreshConfirm)) {
OpenTablesDetailInfoPartProgress progress = new OpenTablesDetailInfoPartProgress(database);
progress.loadTablesInfo();
if (progress.isSuccess()) {
reload(progress.getList());
tableListView.setInput(tableList);
tableListView.refresh();
}
}
}
use of com.cubrid.common.ui.spi.progress.OpenTablesDetailInfoPartProgress in project cubrid-manager by CUBRID.
the class OpenTargetAction method showTableDashboard.
public void showTableDashboard(CubridDatabase database) {
if (database == null) {
return;
}
if (database.getDatabaseInfo() == null || !JDBCConnectionManager.isConnectable(database.getDatabaseInfo())) {
return;
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
TableDashboardInput input = new TableDashboardInput(database);
TableDashboardPart tablesDetailInfoPart = (TableDashboardPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditor(input);
if (tablesDetailInfoPart == null) {
OpenTablesDetailInfoPartProgress progress = new OpenTablesDetailInfoPartProgress(database);
progress.loadTablesInfo();
if (progress.isSuccess()) {
input.setTableList(progress.getList());
try {
window.getActivePage().openEditor(input, TableDashboardPart.ID);
} catch (PartInitException e) {
LOGGER.error("Can not initialize the db table list UI.", e);
}
}
} else {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(tablesDetailInfoPart);
}
}
Aggregations