use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class FileToTableMappingComposite method computeLineCount.
/**
* Compute all line count
*/
private void computeLineCount() {
ImportConfig importConfig = importSettingPage.getImportDataWizard().getImportConfig();
/*Compute all the record count*/
lineCount = 0;
Object[] itemArray = treeViewer.getCheckedElements();
for (Object object : itemArray) {
DefaultSchemaNode node = (DefaultSchemaNode) object;
TableConfig tableConfig = importConfig.getTableConfig(node.getName());
if (tableConfig != null) {
lineCount += tableConfig.getLineCount();
}
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ExportSettingForLoadDBPage method initTableColumnInfo.
/**
* load tables and columns
*/
public void initTableColumnInfo() {
// FIXME move this logic to core module
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.taskLoading, 2);
tablesOrViewLst = new ArrayList<ICubridNode>();
List<String> tableNames = new ArrayList<String>();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
StringBuilder sql = new StringBuilder();
sql.append("SELECT c.class_name, c.class_type ");
sql.append("FROM db_class c, db_attribute a ");
sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' ");
sql.append("AND a.from_class_name IS NULL ");
sql.append("GROUP BY c.class_name, c.class_type ");
sql.append("ORDER BY c.class_type, c.class_name");
String query = sql.toString();
// [TOOLS-2425]Support shard broker
if (getDatabase() != null) {
query = DatabaseInfo.wrapShardQuery(getDatabase().getDatabaseInfo(), query);
}
try {
monitor.subTask(Messages.taskLoadingTable);
conn = JDBCConnectionManager.getConnection(getDatabase().getDatabaseInfo(), true);
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while (rs.next()) {
//$NON-NLS-1$
String tableName = rs.getString(1);
//$NON-NLS-1$
String tableType = rs.getString(2);
if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
continue;
}
String iconPath = "icons/navigator/schema_table_item.png";
if ("VCLASS".equalsIgnoreCase(tableType)) {
//export all view now so don't need select view node
continue;
}
ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
classNode.setContainer(true);
classNode.setType(NodeType.TABLE_COLUMN_FOLDER);
tablesOrViewLst.add(classNode);
tableNames.add(tableName);
}
QueryUtil.freeQuery(rs);
monitor.worked(1);
} catch (SQLException e) {
CommonUITool.openErrorBox(getShell(), e.getErrorCode() + System.getProperty("line.separator") + Messages.importErrorHead + e.getMessage());
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn, stmt, rs);
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ExportSettingPage method initTableColumnInfo.
/**
* load tables and columns
*/
public void initTableColumnInfo() {
// FIXME move this logic to core module
tableColumMap.clear();
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.taskLoading, 2);
tablesOrViewLst = new ArrayList<ICubridNode>();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
StringBuilder sql = new StringBuilder();
sql.append("SELECT c.class_name, c.class_type ");
sql.append("FROM db_class c, db_attribute a ");
sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' ");
sql.append("AND a.from_class_name IS NULL ");
sql.append("GROUP BY c.class_name, c.class_type ");
sql.append("ORDER BY c.class_type, c.class_name");
String query = sql.toString();
// [TOOLS-2425]Support shard broker
if (CubridDatabase.hasValidDatabaseInfo(getDatabase())) {
query = getDatabase().getDatabaseInfo().wrapShardQuery(query);
}
try {
monitor.subTask(Messages.taskLoadingTable);
conn = JDBCConnectionManager.getConnection(getDatabase().getDatabaseInfo(), true);
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while (rs.next()) {
//$NON-NLS-1$
String tableName = rs.getString(1);
//$NON-NLS-1$
String tableType = rs.getString(2);
if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
continue;
}
String iconPath = "icons/navigator/schema_table_item.png";
if ("VCLASS".equalsIgnoreCase(tableType)) {
//export all view now so don't need select view node
continue;
}
ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
if ("VCLASS".equalsIgnoreCase(tableType)) {
classNode.setData(VIEWNODEFLAG, "true");
} else {
classNode.setData(VIEWNODEFLAG, "false");
}
classNode.setContainer(true);
classNode.setType(NodeType.TABLE_COLUMN_FOLDER);
tablesOrViewLst.add(classNode);
}
QueryUtil.freeQuery(rs);
monitor.worked(1);
monitor.subTask(Messages.taskLoadingColumn);
} catch (SQLException e) {
String msg = e.getErrorCode() + StringUtil.NEWLINE + Messages.importErrorHead + e.getMessage();
CommonUITool.openErrorBox(getShell(), msg);
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn, stmt, rs);
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class FileToTableMappingComposite method loadClassInfo.
public List<ICubridNode> loadClassInfo() {
// FIXME move this logic to core module
allTableList = new ArrayList<ICubridNode>();
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.taskLoading, 2);
Connection conn = null;
Statement stmt = null;
ResultSet rsTable = null;
try {
monitor.subTask(Messages.taskLoadingTable);
monitor.worked(1);
StringBuilder sql = new StringBuilder();
sql.append("SELECT c.class_name ");
sql.append("FROM db_class c, db_attribute a ");
sql.append("WHERE c.class_name = a.class_name AND c.is_system_class = 'NO' ");
sql.append("AND a.from_class_name IS NULL ");
sql.append("AND c.class_type = 'CLASS' ");
sql.append("GROUP BY c.class_name ");
sql.append("ORDER BY c.class_name");
conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
stmt = conn.createStatement();
rsTable = stmt.executeQuery(sql.toString());
while (rsTable.next()) {
//$NON-NLS-1$
String tableName = rsTable.getString(1);
if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
continue;
}
String iconPath = "icons/navigator/schema_table_item.png";
ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
classNode.setContainer(true);
allTableList.add(classNode);
}
monitor.subTask(Messages.taskLoadingColumn);
monitor.worked(1);
} catch (SQLException e) {
String msg = e.getErrorCode() + StringUtil.NEWLINE + Messages.importErrorHead + e.getMessage();
CommonUITool.openErrorBox(getShell(), msg);
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn, stmt, rsTable);
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
return allTableList;
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class FileToTableMappingComposite method createClassNode.
public ICubridNode createClassNode(String tableName, boolean isFirstRowAsColumnName, List<String> firstRowColsLst, List<String> colNameList, List<String> colTypeList) {
// FIXME move this logic to core module
int columnCount = firstRowColsLst.size();
String iconPath = "icons/navigator/schema_table_item.png";
ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
classNode.setContainer(true);
List<String> columnNames;
if (isFirstRowAsColumnName) {
columnNames = firstRowColsLst;
} else {
columnNames = new ArrayList<String>();
for (int i = 0; i < columnCount; i++) {
columnNames.add("Column_" + String.valueOf(i));
}
}
for (String columnName : columnNames) {
colNameList.add(columnName);
colTypeList.add(NEW_ATTR_TYPE);
}
classNode.setData(ImportObjectLabelProvider.IS_NEW, true);
classNode.setData(ImportObjectLabelProvider.CREATE_DDL, getCreateTableDDL(classNode, colNameList, colTypeList));
allTableList.add(classNode);
refreshTable();
return classNode;
}
Aggregations