Search in sources :

Example 11 with SchemaComment

use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.

the class LoadTableDetailInfoTask method execute.

public void execute() {
    if (StringUtil.isEmpty(tableName)) {
        return;
    }
    StringBuilder sql = new StringBuilder().append("SELECT \n").append("    c.class_name, \n").append("    COUNT(*) AS count_column, \n").append("    CAST(SUM(\n").append("    CASE \n").append("          WHEN \n").append("              \"data_type\" = 'BIGINT' THEN 8.0 \n").append("          WHEN \n").append("              \"data_type\" = 'INTEGER' THEN 4.0 \n").append("          WHEN \n").append("              \"data_type\" = 'SMALLINT' THEN 2.0 \n").append("          WHEN \n").append("              \"data_type\" = 'FLOAT' THEN 4.0 \n").append("          WHEN \n").append("              \"data_type\" = 'DOUBLE' THEN 8.0 \n").append("          WHEN \n").append("              \"data_type\" = 'MONETARY' THEN 12.0 \n").append("          WHEN \n").append("              \"data_type\" = 'STRING' THEN a.prec \n").append("          WHEN \n").append("              \"data_type\" = 'VARCHAR' THEN a.prec \n").append("          WHEN \n").append("              \"data_type\" = 'NVARCHAR' THEN a.prec \n").append("          WHEN \n").append("              \"data_type\" = 'CHAR' THEN a.prec \n").append("          WHEN \n").append("              \"data_type\" = 'NCHAR' THEN a.prec \n").append("          WHEN \n").append("              \"data_type\" = 'TIMESTAMP' THEN 8.0 \n").append("          WHEN \n").append("              \"data_type\" = 'DATE' THEN 4.0 \n").append("          WHEN \n").append("              \"data_type\" = 'TIME' THEN 4.0 \n").append("          WHEN \n").append("              \"data_type\" = 'DATETIME' THEN 4.0 \n").append("          WHEN \n").append("              \"data_type\" = 'BIT' THEN FLOOR(prec / 8.0) \n").append("          WHEN \n").append("              \"data_type\" = 'BIT VARYING' THEN FLOOR(prec / 8.0) \n").append("          ELSE 0 \n").append("    END ) AS BIGINT) AS size_column, \n").append("    SUM(\n").append("    CASE \n").append("          WHEN \n").append("              \"data_type\" = 'STRING' THEN 1 \n").append("          WHEN \n").append("              \"data_type\" = 'VARCHAR' THEN 1 \n").append("          WHEN \n").append("              \"data_type\" = 'NVARCHAR' THEN 1 \n").append("          WHEN \n").append("              \"data_type\" = 'NCHAR' THEN 1 \n").append("          WHEN \n").append("              \"data_type\" = 'BIT VARYING' THEN 1 \n").append("          ELSE 0 \n").append("    END ) AS size_over_column, \n").append("    c.class_type, \n").append("    c.partitioned \n").append("FROM \n").append("    db_class c, \n").append("    db_attribute a \n").append("WHERE \n").append("    c.class_name = ? \n").append("    AND \n").append("    c.class_name = a.class_name \n").append("    AND \n").append("    c.is_system_class = 'NO' \n").append("    AND \n").append("    c.class_type = 'CLASS' \n").append("    AND \n").append("    a.from_class_name IS NULL \n").append("GROUP BY c.class_name;\n");
    String query = sql.toString();
    StringBuilder sqlIndex = new StringBuilder().append("SELECT \n").append("    c.class_name, \n").append("    SUM(\n").append("    CASE \n").append("          WHEN \n").append("              i.is_unique = 'YES' \n").append("              AND \n").append("              i.is_primary_key = 'NO' THEN 1 \n").append("          ELSE 0 \n").append("    END ) AS count_unique, \n").append("    SUM(\n").append("    CASE \n").append("          WHEN \n").append("              i.is_unique = 'YES' \n").append("              AND \n").append("              i.is_primary_key = 'YES' THEN 1 \n").append("          ELSE 0 \n").append("    END ) AS count_primary_key, \n").append("    SUM(DECODE(i.is_foreign_key, 'YES', 1, 0)) AS count_foreign_key, \n").append("    SUM(\n").append("    CASE \n").append("          WHEN \n").append("              i.is_unique = 'NO' \n").append("              AND \n").append("              i.is_primary_key = 'NO' THEN 1 \n").append("          ELSE 0 \n").append("    END ) AS count_index \n").append("FROM \n").append("    db_class c, \n").append("    db_index_key k, \n").append("    db_index i \n").append("WHERE \n").append("    c.class_name = ? ").append("    AND \n").append("    c.class_name = k.class_name \n").append("    AND \n").append("    k.class_name = i.class_name \n").append("    AND \n").append("    k.index_name = i.index_name \n").append("    AND \n").append("    c.class_type = 'CLASS' \n").append("    AND \n").append("    c.is_system_class = 'NO' \n").append("    AND \n").append("    i.key_count >= 1 \n").append("    AND \n").append("    NOT EXISTS (SELECT 1 FROM db_partition p WHERE c.class_name = LOWER(p.partition_class_name)) \n").append("GROUP BY c.class_name;\n");
    String queryIndex = sqlIndex.toString();
    // [TOOLS-2425]Support shard broker
    if (CubridDatabase.hasValidDatabaseInfo(database)) {
        query = database.getDatabaseInfo().wrapShardQuery(query);
        queryIndex = database.getDatabaseInfo().wrapShardQuery(queryIndex);
    }
    PreparedStatement pStmt = null;
    try {
        pStmt = connection.prepareStatement(query);
        pStmt.setString(1, tableName);
        rs = pStmt.executeQuery();
        while (rs.next()) {
            String tableName = rs.getString(1);
            int countColumn = rs.getInt(2);
            BigDecimal recordsSize = rs.getBigDecimal(3);
            boolean columnOverSize = rs.getInt(4) > 0;
            String classType = rs.getString(5);
            String partitioned = rs.getString(6);
            tableInfo = new TableDetailInfo();
            tableInfo.setTableName(tableName);
            tableInfo.setColumnsCount(countColumn);
            tableInfo.setRecordsSize(recordsSize);
            tableInfo.setHasUnCountColumnSize(columnOverSize);
            tableInfo.setClassType(classType);
            tableInfo.setPartitioned(partitioned);
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        QueryUtil.freeQuery(pStmt, rs);
    }
    if (tableInfo != null) {
        try {
            pStmt = connection.prepareStatement(queryIndex);
            pStmt.setString(1, tableName);
            rs = pStmt.executeQuery();
            while (rs.next()) {
                String tableName = rs.getString(1);
                int ukCount = rs.getInt(2);
                int pkCount = rs.getInt(3);
                int fkCount = rs.getInt(4);
                int indexCount = rs.getInt(5);
                tableInfo.setTableName(tableName);
                tableInfo.setUkCount(ukCount);
                tableInfo.setPkCount(pkCount);
                tableInfo.setFkCount(fkCount);
                tableInfo.setIndexCount(indexCount);
            }
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
        } finally {
            QueryUtil.freeQuery(pStmt, rs);
        }
    }
    try {
        Map<String, SchemaComment> commentMap = SchemaCommentHandler.loadTableDescriptions(database.getDatabaseInfo(), connection);
        SchemaComment schemaComment = SchemaCommentHandler.find(commentMap, tableInfo.getTableName(), null);
        if (schemaComment != null) {
            tableInfo.setTableDesc(schemaComment.getDescription());
        }
    } catch (SQLException ex) {
        LOGGER.error(ex.getMessage(), ex);
    }
    finish();
}
Also used : SQLException(java.sql.SQLException) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) PreparedStatement(java.sql.PreparedStatement) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException)

Example 12 with SchemaComment

use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.

the class OpenTablesDetailInfoPartProgress method run.

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    DatabaseInfo databaseInfo = NodeUtil.findDatabaseInfo(database);
    if (databaseInfo == null) {
        return;
    }
    Connection conn = null;
    try {
        monitor.setTaskName(Messages.tablesDetailInfoPartProgressTaskName);
        if (databaseInfo.getUserTableInfoList() == null) {
            return;
        }
        tableList = new ArrayList<TableDetailInfo>();
        Map<String, TableDetailInfo> map = new HashMap<String, TableDetailInfo>();
        conn = JDBCConnectionManager.getConnection(databaseInfo, true);
        if (!loadUserSchemaList(conn, map)) {
            success = false;
            return;
        }
        Set<String> tableNameSet = map.keySet();
        if (tableNameSet != null) {
            Map<String, SchemaComment> comments = null;
            if (SchemaCommentHandler.isInstalledMetaTable(databaseInfo, conn)) {
                try {
                    comments = SchemaCommentHandler.loadTableDescriptions(databaseInfo, conn);
                } catch (SQLException e) {
                    LOGGER.error(e.getMessage(), e);
                }
            }
            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);
                info.setRecordsCount(-1);
                SchemaComment cmt = SchemaCommentHandler.find(comments, tableName, null);
                if (cmt != null) {
                    info.setTableDesc(cmt.getDescription());
                }
                tableList.add(info);
            }
        }
        success = true;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        QueryUtil.freeQuery(conn);
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) HashMap(java.util.HashMap) SQLException(java.sql.SQLException) Connection(java.sql.Connection) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment)

Example 13 with SchemaComment

use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.

the class ExportTableDefinitionLayoutType1 method generateTableDetailSheets.

/**
	 * generate table name sheet
	 * @param wwb
	 * @param conn
	 * @param exportSchemaInfoList
	 * @param monitor
	 * @throws Exception
	 */
public void generateTableDetailSheets(WritableWorkbook wwb, Connection conn, List<SchemaInfo> exportSchemaInfoList, IProgressMonitor monitor) throws Exception {
    int sheetIndex = 1;
    for (SchemaInfo schemaInfo : exportSchemaInfoList) {
        String tableName = schemaInfo.getClassname();
        monitor.subTask(Messages.bind(Messages.exportTableDefinitionProgressTaskWriteTable, tableName));
        List<SchemaInfo> supers = SuperClassUtil.getSuperClasses(getProgressObject().getDatabase().getDatabaseInfo(), schemaInfo);
        WritableSheet ws = wwb.createSheet(tableName, sheetIndex++);
        int rowIndex = 0;
        // Title
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell10, boldCellStyle));
        ws.mergeCells(0, 0, 7, 0);
        rowIndex++;
        // System name
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell11, boldCellStyle));
        ws.addCell(new jxl.write.Label(1, rowIndex, "", normalCellStyle));
        // Date
        ws.addCell(new jxl.write.Label(2, rowIndex, Messages.exportTableDefinitionCell4, boldCellStyle));
        ws.addCell(new jxl.write.Label(3, rowIndex, dateString, normalCellStyle));
        // Author
        ws.addCell(new jxl.write.Label(5, rowIndex, Messages.exportTableDefinitionCell5, boldCellStyle));
        ws.addCell(new jxl.write.Label(7, rowIndex, "", normalCellStyle));
        ws.mergeCells(3, 1, 4, 1);
        ws.mergeCells(5, 1, 6, 1);
        rowIndex++;
        String tableColumnText = "";
        if (getProgressObject().isInstalledMetaTable()) {
            SchemaComment tableComment = SchemaCommentHandler.find(getProgressObject().getSchemaCommentMap(), tableName, null);
            if (tableComment != null) {
                tableColumnText = tableComment.getDescription() == null ? "" : tableComment.getDescription();
            }
        }
        // Table Name
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell6, boldCellStyle));
        ws.addCell(new jxl.write.Label(1, rowIndex, tableName, normalLeftAlignCellStyle));
        ws.mergeCells(1, 2, 7, 2);
        rowIndex++;
        // Table Description
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell27, boldCellStyle));
        ws.addCell(new jxl.write.Label(1, rowIndex, tableColumnText, normalLeftAlignCellStyle));
        ws.mergeCells(1, 3, 7, 3);
        rowIndex++;
        // Column ID
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell12, boldCellStyle));
        // Data type
        ws.addCell(new jxl.write.Label(1, rowIndex, Messages.exportTableDefinitionCell14, boldCellStyle));
        // Size
        ws.addCell(new jxl.write.Label(2, rowIndex, Messages.exportTableDefinitionCell15, boldCellStyle));
        // Null
        ws.addCell(new jxl.write.Label(3, rowIndex, Messages.exportTableDefinitionCell16, boldCellStyle));
        // PK
        ws.addCell(new jxl.write.Label(4, rowIndex, Messages.exportTableDefinitionCell17, boldCellStyle));
        // FK
        ws.addCell(new jxl.write.Label(5, rowIndex, Messages.exportTableDefinitionCell18, boldCellStyle));
        // Default
        ws.addCell(new jxl.write.Label(6, rowIndex, Messages.exportTableDefinitionCell26, boldCellStyle));
        // Column description
        ws.addCell(new jxl.write.Label(7, rowIndex, Messages.exportTableDefinitionCell25, boldCellStyle));
        rowIndex++;
        // column info
        for (DBAttribute columnAtt : schemaInfo.getAttributes()) {
            String attrName = columnAtt.getName();
            String defaultValue = columnAtt.getDefault();
            String columnText = "";
            if (getProgressObject().isInstalledMetaTable()) {
                SchemaComment columnComment = SchemaCommentHandler.find(getProgressObject().getSchemaCommentMap(), tableName, attrName);
                if (columnComment != null) {
                    columnText = columnComment.getDescription() == null ? "" : columnComment.getDescription();
                }
            }
            ws.addCell(new jxl.write.Label(0, rowIndex, attrName, normalLeftAlignCellStyle));
            String showType = DataType.getShownType((columnAtt.getType()));
            if (showType.indexOf("(") > -1 && showType.endsWith("")) {
                showType = showType.substring(0, showType.indexOf("("));
            }
            ws.addCell(new jxl.write.Label(1, rowIndex, showType, normalLeftAlignCellStyle));
            int size = DataType.getSize(columnAtt.getType());
            int scale = DataType.getScale(columnAtt.getType());
            if (size < 0 && scale < 0) {
                ws.addCell(new jxl.write.Label(2, rowIndex, "", normalRightAlignCellStyle));
            } else if (scale < 0) {
                ws.addCell(new jxl.write.Number(2, rowIndex, size, normalRightAlignCellStyle));
            } else {
                ws.addCell(new jxl.write.Label(2, rowIndex, Integer.toString(size) + "," + Integer.toString(scale), normalRightAlignCellStyle));
            }
            //get nullable
            boolean isNULL = true;
            if (!columnAtt.isClassAttribute()) {
                if (columnAtt.getInherit().equals(tableName)) {
                    Constraint pk = schemaInfo.getPK(supers);
                    if (null != pk && pk.getAttributes().contains(attrName)) {
                        isNULL = false;
                    }
                } else {
                    List<Constraint> pkList = schemaInfo.getInheritPK(supers);
                    for (Constraint inheritPK : pkList) {
                        if (inheritPK.getAttributes().contains(attrName)) {
                            isNULL = false;
                        }
                    }
                }
            }
            if (columnAtt.isNotNull()) {
                isNULL = false;
            }
            ws.addCell(new jxl.write.Label(3, rowIndex, isNULL ? "Y" : "", normalCellStyle));
            //get pk
            boolean isPk = false;
            if (!columnAtt.isClassAttribute()) {
                if (columnAtt.getInherit().equals(tableName)) {
                    Constraint pk = schemaInfo.getPK(supers);
                    if (null != pk && pk.getAttributes().contains(attrName)) {
                        isPk = true;
                    }
                } else {
                    List<Constraint> pkList = schemaInfo.getInheritPK(supers);
                    for (Constraint inheritPK : pkList) {
                        if (inheritPK.getAttributes().contains(attrName)) {
                            isPk = true;
                        }
                    }
                }
            }
            ws.addCell(new jxl.write.Label(4, rowIndex, isPk ? "Y" : "", normalCellStyle));
            //get fk
            boolean isFk = false;
            for (Constraint fk : schemaInfo.getFKConstraints()) {
                for (String columns : fk.getAttributes()) {
                    if (columns.equals(attrName)) {
                        isFk = true;
                        break;
                    }
                }
            }
            ws.addCell(new jxl.write.Label(5, rowIndex, isFk ? "Y" : "", normalCellStyle));
            ws.addCell(new jxl.write.Label(6, rowIndex, defaultValue, normalCellStyle));
            ws.addCell(new jxl.write.Label(7, rowIndex, columnText, normalLeftAlignCellStyle));
            rowIndex++;
        }
        // blank
        for (int i = 0; i < 8; i++) {
            ws.addCell(new jxl.write.Label(i, rowIndex, "", normalCellStyle));
        }
        rowIndex++;
        // index
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell20, boldCellStyle));
        ws.mergeCells(0, rowIndex, 7, rowIndex);
        rowIndex++;
        // NO
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell21, boldCellStyle));
        // Index name
        ws.addCell(new jxl.write.Label(1, rowIndex, Messages.exportTableDefinitionCell22, boldCellStyle));
        // Column ID
        ws.addCell(new jxl.write.Label(3, rowIndex, Messages.exportTableDefinitionCell13, boldCellStyle));
        // Order
        ws.addCell(new jxl.write.Label(5, rowIndex, Messages.exportTableDefinitionCell23, boldCellStyle));
        // Memo
        ws.addCell(new jxl.write.Label(6, rowIndex, Messages.exportTableDefinitionCell19, boldCellStyle));
        ws.mergeCells(1, rowIndex, 2, rowIndex);
        ws.mergeCells(3, rowIndex, 4, rowIndex);
        ws.mergeCells(6, rowIndex, 7, rowIndex);
        rowIndex++;
        List<Constraint> constraints = getProgressObject().getIndexList(schemaInfo);
        for (int i = 0; i < constraints.size(); i++) {
            Constraint constraint = constraints.get(i);
            int columnSize = constraint.getAttributes().size();
            // mark current row index
            int currentRowIndex = rowIndex;
            for (int j = 0; j < columnSize; j++) {
                String columnName = constraint.getAttributes().get(j);
                ws.addCell(new jxl.write.Number(0, rowIndex, i + 1, normalCellStyle));
                ws.addCell(new jxl.write.Label(1, rowIndex, constraint.getName(), normalLeftAlignCellStyle));
                ws.addCell(new jxl.write.Label(3, rowIndex, columnName, normalLeftAlignCellStyle));
                ws.addCell(new jxl.write.Number(5, rowIndex, j + 1, normalCellStyle));
                ws.addCell(new jxl.write.Label(6, rowIndex, "", normalCellStyle));
                if (columnSize == 1) {
                    ws.mergeCells(1, rowIndex, 2, rowIndex);
                }
                ws.mergeCells(3, rowIndex, 4, rowIndex);
                ws.mergeCells(6, rowIndex, 7, rowIndex);
                rowIndex++;
            }
            //if multiple colulmn merge NO/Index Name CELL by vertical logic
            if (columnSize > 1) {
                ws.mergeCells(0, currentRowIndex, 0, currentRowIndex + columnSize - 1);
                ws.mergeCells(1, currentRowIndex, 2, currentRowIndex + columnSize - 1);
            }
        }
        // blank
        ws.addCell(new jxl.write.Label(0, rowIndex, "", normalCellStyle));
        ws.addCell(new jxl.write.Label(1, rowIndex, "", normalCellStyle));
        ws.addCell(new jxl.write.Label(3, rowIndex, "", normalCellStyle));
        ws.addCell(new jxl.write.Label(5, rowIndex, "", normalCellStyle));
        ws.addCell(new jxl.write.Label(6, rowIndex, "", normalCellStyle));
        ws.mergeCells(1, rowIndex, 2, rowIndex);
        ws.mergeCells(3, rowIndex, 4, rowIndex);
        ws.mergeCells(6, rowIndex, 7, rowIndex);
        rowIndex++;
        // DDL
        ws.addCell(new jxl.write.Label(0, rowIndex, Messages.exportTableDefinitionCell24, boldCellStyle));
        ws.mergeCells(0, rowIndex, 7, rowIndex);
        rowIndex++;
        String ddl = getProgressObject().getDDL(schemaInfo);
        ws.addCell(new jxl.write.Label(0, rowIndex, ddl, normalLeftAlignCellStyle));
        ws.mergeCells(0, rowIndex, 7, rowIndex);
        ws.setRowView(0, 500);
        int lineNumbner = ddl.split(StringUtil.NEWLINE).length;
        ws.setRowView(rowIndex, lineNumbner * 350);
        // column width
        ws.setColumnView(0, 18);
        ws.setColumnView(1, 20);
        ws.setColumnView(2, 13);
        ws.setColumnView(3, 9);
        ws.setColumnView(4, 9);
        ws.setColumnView(5, 9);
        ws.setColumnView(6, 10);
        ws.setColumnView(7, 29);
        monitor.worked(1);
    }
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) WritableSheet(jxl.write.WritableSheet) Constraint(com.cubrid.common.core.common.model.Constraint) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 14 with SchemaComment

use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.

the class ExportTableDefinitionLayoutType2 method generateTableNamesSheet.

/**
	 * Generate table name sheet
	 *
	 * @param wwb
	 * @param exportTableNames
	 * @throws Exception
	 */
public void generateTableNamesSheet(WritableWorkbook wwb, List<String> exportTableNames) throws Exception {
    WritableSheet ws = wwb.createSheet(Messages.exportTableDefinitionCell1, 0);
    // Tables
    ws.addCell(new jxl.write.Label(0, 0, Messages.exportTableDefinitionCell2, boldCellStyle));
    ws.mergeCells(0, 0, 5, 0);
    // Project
    ws.addCell(new jxl.write.Label(0, 1, Messages.exportTableDefinitionCell3, boldCellStyle));
    ws.addCell(new jxl.write.Label(1, 1, "", normalCellStyle));
    // Date
    ws.addCell(new jxl.write.Label(2, 1, Messages.exportTableDefinitionCell4, boldCellStyle));
    ws.addCell(new jxl.write.Label(3, 1, dateString, normalCellStyle));
    // Author
    ws.addCell(new jxl.write.Label(4, 1, Messages.exportTableDefinitionCell5, boldCellStyle));
    ws.addCell(new jxl.write.Label(5, 1, "", normalCellStyle));
    // Table Name
    ws.addCell(new jxl.write.Label(0, 2, Messages.exportTableDefinitionCell6, boldCellStyle));
    // Table ID
    ws.addCell(new jxl.write.Label(1, 2, Messages.exportTableDefinitionCell7, boldCellStyle));
    // Description
    ws.addCell(new jxl.write.Label(2, 2, Messages.exportTableDefinitionCell8, boldCellStyle));
    // Memo
    ws.addCell(new jxl.write.Label(5, 2, Messages.exportTableDefinitionCell9, boldCellStyle));
    ws.mergeCells(2, 2, 4, 2);
    //table name data
    int rowIndex = 3;
    for (String tableName : exportTableNames) {
        String tableColumnText = "";
        if (getProgressObject().isInstalledMetaTable()) {
            SchemaComment tableComment = SchemaCommentHandler.find(getProgressObject().getSchemaCommentMap(), tableName, null);
            if (tableComment != null) {
                tableColumnText = tableComment.getDescription() == null ? "" : tableComment.getDescription();
            }
        }
        ws.addCell(new jxl.write.Label(0, rowIndex, tableColumnText, normalLeftAlignCellStyle));
        ws.addCell(new jxl.write.Label(1, rowIndex, tableName, normalLeftAlignCellStyle));
        ws.addCell(new jxl.write.Label(2, rowIndex, "", normalCellStyle));
        ws.addCell(new jxl.write.Label(5, rowIndex, "", normalCellStyle));
        ws.mergeCells(2, rowIndex, 4, rowIndex);
        rowIndex++;
    }
    ws.setRowView(0, 500);
    // column width
    ws.setColumnView(0, 25);
    ws.setColumnView(1, 28);
    ws.setColumnView(2, 15);
    ws.setColumnView(3, 18);
    ws.setColumnView(4, 15);
    ws.setColumnView(5, 20);
}
Also used : WritableSheet(jxl.write.WritableSheet) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment) Constraint(com.cubrid.common.core.common.model.Constraint)

Example 15 with SchemaComment

use of com.cubrid.common.core.schemacomment.model.SchemaComment in project cubrid-manager by CUBRID.

the class SchemaCommentHandler method resultToMetaDesc.

private static SchemaComment resultToMetaDesc(ResultSet rs) throws SQLException {
    SchemaComment meta = new SchemaComment();
    meta.setTable(rs.getString("table_name"));
    String columnName = rs.getString("column_name");
    if (StringUtil.isEqual(columnName, "*")) {
        columnName = null;
    }
    meta.setColumn(columnName);
    meta.setDescription(rs.getString("description"));
    return meta;
}
Also used : SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment)

Aggregations

SchemaComment (com.cubrid.common.core.schemacomment.model.SchemaComment)23 SQLException (java.sql.SQLException)11 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)8 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)8 Constraint (com.cubrid.common.core.common.model.Constraint)6 PreparedStatement (java.sql.PreparedStatement)6 Connection (java.sql.Connection)5 IDatabaseSpec (com.cubrid.common.core.common.model.IDatabaseSpec)4 ResultSet (java.sql.ResultSet)4 HashMap (java.util.HashMap)4 WritableSheet (jxl.write.WritableSheet)4 Statement (java.sql.Statement)3 ArrayList (java.util.ArrayList)3 TableDetailInfo (com.cubrid.common.core.common.model.TableDetailInfo)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 PartInitException (org.eclipse.ui.PartInitException)2 DBResolution (com.cubrid.common.core.common.model.DBResolution)1 Trigger (com.cubrid.common.core.common.model.Trigger)1 ITask (com.cubrid.common.core.task.ITask)1