use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.
the class ERDNDController method getDescInformation.
private void getDescInformation(SchemaInfo newSchemaInfo, CubridDatabase database, Connection conn) {
// FIXME move this logic to core module
try {
IDatabaseSpec dbSpec = database.getDatabaseInfo();
boolean isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn);
database.getDatabaseInfo().setSupportTableComment(isSupportTableComment);
if (isSupportTableComment && newSchemaInfo != null) {
Map<String, SchemaComment> map = SchemaCommentHandler.loadDescription(dbSpec, conn, newSchemaInfo.getClassname());
for (DBAttribute attr : newSchemaInfo.getAttributes()) {
SchemaComment schemaComment = SchemaCommentHandler.find(map, newSchemaInfo.getClassname(), attr.getName());
if (schemaComment != null) {
attr.setDescription(schemaComment.getDescription());
}
}
SchemaComment schemaComment = SchemaCommentHandler.find(map, newSchemaInfo.getClassname(), null);
if (schemaComment != null) {
newSchemaInfo.setDescription(schemaComment.getDescription());
}
}
} catch (SQLException e) {
LOGGER.error("", e);
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method openTableDetail.
private void openTableDetail(TableDetailInfo info) {
//if had opend, set it selection
for (CTabItem tabItem : tabFolder.getItems()) {
if (tabItem.getText().equals(info.getTableName())) {
tabFolder.setSelection(tabItem);
return;
}
}
//if a new table info, create a new tab
TableDashboardComposite tableComp = new TableDashboardComposite(tabFolder, SWT.NONE);
tableComp.initialize();
SchemaProvider schemaProvider = new SchemaProvider(database.getDatabaseInfo(), info.getTableName());
SchemaInfo schemaInfo = schemaProvider.getSchema();
if (schemaInfo == null && StringUtil.isNotEmpty(schemaProvider.getErrorMessage())) {
String msg = Messages.bind(Messages.errGetSchemaInfo, info.getTableName());
CommonUITool.openErrorBox(msg);
return;
}
// load table descriptions
// FIXME move this logic to core module
Connection conn = null;
try {
conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
IDatabaseSpec dbSpec = database.getDatabaseInfo();
boolean isSchemaCommentInstalled = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn);
if (schemaInfo != null && isSchemaCommentInstalled) {
Map<String, SchemaComment> comments = SchemaCommentHandler.loadDescription(dbSpec, conn, schemaInfo.getClassname());
SchemaCommentHandler.bindSchemaInfo(comments, schemaInfo);
}
} catch (SQLException e) {
LOGGER.error(e.getMessage(), e);
} finally {
QueryUtil.freeQuery(conn);
}
tableComp.setInput(schemaInfo, database.getDatabaseInfo(), isSchemaCommentInstalled);
}
use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method setInputs.
public void setInputs() {
tableListView.setInput(tableList);
tableListView.refresh();
Connection connection = null;
try {
connection = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
isSchemaCommentInstalled = SchemaCommentHandler.isInstalledMetaTable(database.getDatabaseInfo(), connection);
TableDashboardComposite tableComp = new TableDashboardComposite(tabFolder, SWT.NONE);
tableComp.initialize();
if (database.getDatabaseInfo().getUserTableInfoList().size() > 0) {
ClassInfo classInfo = database.getDatabaseInfo().getUserTableInfoList().get(0);
SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(connection, classInfo.getClassName());
IDatabaseSpec dbSpec = database.getDatabaseInfo();
if (schemaInfo != null && SchemaCommentHandler.isInstalledMetaTable(dbSpec, connection)) {
Map<String, SchemaComment> comments = SchemaCommentHandler.loadDescription(dbSpec, connection, classInfo.getClassName());
if (comments != null) {
SchemaCommentHandler.bindSchemaInfo(comments, schemaInfo);
}
}
tableComp.setInput(schemaInfo, database.getDatabaseInfo(), isSchemaCommentInstalled);
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
QueryUtil.freeQuery(connection);
}
if (isSchemaCommentInstalled) {
new TableEditButtonSupport(tableListView, this, 1);
}
}
use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.
the class CreateViewDialog method getViewComment.
/**
* get view's comment
*
* @return
*/
private String getViewComment() {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
SchemaComment schemaComment = null;
String viewName = tableText.getText();
try {
DatabaseInfo dbInfo = database.getDatabaseInfo();
conn = JDBCConnectionManager.getConnection(dbInfo, true);
schemaComment = SchemaCommentHandler.loadObjectDescription(dbInfo, conn, viewName, CommentType.VIEW);
} catch (SQLException e) {
LOGGER.error(e.getMessage());
CommonUITool.openErrorBox(e.getMessage());
} finally {
QueryUtil.freeQuery(stmt, rs);
}
return schemaComment.getDescription();
}
use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.
the class ColumnProposalAdvisor method loadProposal.
/**
* load proposal for database
*
* @param databaseInfo
*/
private void loadProposal(final DatabaseInfo databaseInfo) {
final String key = makeKey(databaseInfo);
Job job = new Job("Load database schema information job") {
protected IStatus run(IProgressMonitor monitor) {
List<String> tableNames = new ArrayList<String>();
Map<String, List<ColumnProposalDetailInfo>> columns = new HashMap<String, List<ColumnProposalDetailInfo>>();
GetAllSchemaTask task = null;
try {
task = new GetAllSchemaTask(databaseInfo, monitor);
task.setNeedCollationInfo(false);
task.execute();
/*Check is canceled*/
if (task.isCancel()) {
return Status.CANCEL_STATUS;
}
if (task.isSuccess()) {
Map<String, SchemaInfo> schemas = task.getSchemas();
Map<String, SchemaComment> descriptions = task.getComments();
List<String> fetchedTableNames = new ArrayList<String>();
for (SchemaInfo schemaInfo : schemas.values()) {
if (schemaInfo.isSystemClass()) {
continue;
}
String tableName = schemaInfo.getClassname();
if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
continue;
}
fetchedTableNames.add(tableName);
}
Collections.sort(fetchedTableNames);
for (String tableName : fetchedTableNames) {
if (!tableNames.contains(tableName)) {
tableNames.add(tableName);
}
if (columns.containsKey(tableName)) {
continue;
}
SchemaInfo schemaInfo = schemas.get(tableName);
if (schemaInfo == null) {
continue;
}
if (descriptions != null) {
SchemaComment schemaComment = SchemaCommentHandler.find(descriptions, tableName, null);
if (schemaComment != null) {
String description = schemaComment.getDescription();
schemaInfo.setDescription(description);
}
}
List<ColumnProposalDetailInfo> colInfoList = new ArrayList<ColumnProposalDetailInfo>();
columns.put(tableName, colInfoList);
List<DBAttribute> dbClassAttrList = schemaInfo.getClassAttributes();
for (DBAttribute attr : dbClassAttrList) {
ColumnProposalDetailInfo colInfo = new ColumnProposalDetailInfo(schemaInfo, attr);
colInfoList.add(colInfo);
}
List<DBAttribute> attrList = schemaInfo.getAttributes();
for (DBAttribute attr : attrList) {
ColumnProposalDetailInfo colInfo = new ColumnProposalDetailInfo(schemaInfo, attr);
colInfoList.add(colInfo);
}
columns.put(schemaInfo.getClassname(), colInfoList);
}
/*Cache the data*/
ColumnProposal proposal = new ColumnProposal();
proposal.setTableNames(tableNames);
proposal.setColumns(columns);
synchronized (ColumnProposalAdvisor.class) {
cachedMap.put(key, proposal);
}
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
synchronized (ColumnProposalAdvisor.class) {
collectingKeys.remove(key);
}
task.finish();
}
return Status.OK_STATUS;
}
};
/*Record collecting key*/
synchronized (ColumnProposalAdvisor.class) {
collectingKeys.add(key);
job.schedule();
}
}
Aggregations