Search in sources :

Example 1 with SchemaProvider

use of com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider 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);
}
Also used : IDatabaseSpec(com.cubrid.common.core.common.model.IDatabaseSpec) SQLException(java.sql.SQLException) Connection(java.sql.Connection) SchemaProvider(com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment) TablesDetailInfoCTabItem(com.cubrid.common.ui.cubrid.table.dashboard.control.TableDashboardComposite.TablesDetailInfoCTabItem) CTabItem(org.eclipse.swt.custom.CTabItem) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 2 with SchemaProvider

use of com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider in project cubrid-manager by CUBRID.

the class DatabaseInfo method getSchemaInfo.

/**
	 * get a schema object via table name
	 * 
	 * Note: using delay loading method for large amount number of tables
	 * 
	 * @param connection
	 * @param tableName String The table name
	 * @return SchemaInfo The instance of SchemaInfo
	 */
public SchemaInfo getSchemaInfo(Connection connection, String tableName) {
    if (StringUtil.isEmpty(tableName)) {
        return null;
    }
    if (schemaMap == null) {
        schemaMap = new HashMap<String, SchemaInfo>();
    }
    SchemaInfo schemaInfo = schemaMap.get(tableName);
    if (schemaInfo == null) {
        SchemaProvider schemaProvider = new SchemaProvider(this, tableName);
        schemaInfo = schemaProvider.getSchema(connection);
        if (schemaInfo == null && StringUtil.isNotEmpty(schemaProvider.getErrorMessage())) {
            errorMessage = schemaProvider.getErrorMessage();
            return null;
        } else {
            putSchemaInfo(schemaInfo);
        }
    }
    return schemaInfo;
}
Also used : SchemaProvider(com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 3 with SchemaProvider

use of com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider in project cubrid-manager by CUBRID.

the class DatabaseInfo method getSchemaInfo.

/**
	 * get a schema object via table name
	 * 
	 * Note: using delay loading method for large amount number of tables
	 * 
	 * @param tableName String The table name
	 * @return SchemaInfo The instance of SchemaInfo
	 */
public SchemaInfo getSchemaInfo(String tableName) {
    if (StringUtil.isEmpty(tableName)) {
        return null;
    }
    if (null == schemaMap) {
        schemaMap = new HashMap<String, SchemaInfo>();
    }
    SchemaInfo schemaInfo = schemaMap.get(tableName);
    if (null == schemaInfo) {
        SchemaProvider schemaProvider = new SchemaProvider(this, tableName);
        schemaInfo = schemaProvider.getSchema();
        if (schemaInfo == null && StringUtil.isNotEmpty(schemaProvider.getErrorMessage())) {
            errorMessage = schemaProvider.getErrorMessage();
            return null;
        } else {
            putSchemaInfo(schemaInfo);
        }
    }
    return schemaInfo;
}
Also used : SchemaProvider(com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Aggregations

SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)3 SchemaProvider (com.cubrid.cubridmanager.core.cubrid.table.SchemaProvider)3 IDatabaseSpec (com.cubrid.common.core.common.model.IDatabaseSpec)1 SchemaComment (com.cubrid.common.core.schemacomment.model.SchemaComment)1 TablesDetailInfoCTabItem (com.cubrid.common.ui.cubrid.table.dashboard.control.TableDashboardComposite.TablesDetailInfoCTabItem)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 CTabItem (org.eclipse.swt.custom.CTabItem)1