Search in sources :

Example 1 with ClassType

use of com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType in project cubrid-manager by CUBRID.

the class ModelUtilTest method testClassType.

public void testClassType() {
    ClassType a = ClassType.eval("normal");
    assert (a.equals(ClassType.NORMAL));
    assertTrue(ClassType.eval("") == null);
}
Also used : ClassType(com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType)

Example 2 with ClassType

use of com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType in project cubrid-manager by CUBRID.

the class GetPartitionedClassListTask method getAllPartitionedClassInfoList.

/**
	 * Get all partitioned class info list
	 * 
	 * @param tableName String the table name
	 * @return List<ClassInfo>
	 */
public List<ClassInfo> getAllPartitionedClassInfoList(String tableName) {
    List<ClassInfo> allClassInfoList = new ArrayList<ClassInfo>();
    try {
        if (errorMsg != null && errorMsg.trim().length() > 0) {
            return allClassInfoList;
        }
        if (connection == null || connection.isClosed()) {
            errorMsg = Messages.error_getConnection;
            return allClassInfoList;
        }
        String sql = "SELECT b.* FROM db_partition a, db_class b WHERE a.class_name=?" + " AND LOWER(b.class_name)=LOWER(a.partition_class_name)";
        stmt = connection.prepareStatement(sql);
        ((PreparedStatement) stmt).setString(1, tableName.toLowerCase(Locale.getDefault()));
        rs = ((PreparedStatement) stmt).executeQuery();
        while (rs.next()) {
            String className = rs.getString("class_name");
            String ownerName = rs.getString("owner_name");
            String classType = rs.getString("class_type");
            ClassType type = ClassType.NORMAL;
            if (classType != null && classType.trim().equalsIgnoreCase("VCLASS")) {
                type = ClassType.VIEW;
            }
            String isSystemClazz = rs.getString("is_system_class");
            boolean isSystemClass = false;
            if (isSystemClazz != null && isSystemClazz.trim().equalsIgnoreCase("YES")) {
                isSystemClass = true;
            }
            ClassInfo classInfo = new ClassInfo(className, ownerName, type, isSystemClass, true);
            allClassInfoList.add(classInfo);
        }
    } catch (SQLException e) {
        LOGGER.error("", e);
        errorMsg = e.getMessage();
    } finally {
        finish();
    }
    return allClassInfoList;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) ClassType(com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 3 with ClassType

use of com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType in project cubrid-manager by CUBRID.

the class ClassInfoTest method testClassInfo.

/**
	 * test ClassInfo
	 * 
	 */
public void testClassInfo() {
    String className = "className";
    String ownerName = "ownerName";
    ClassType classType = ClassType.NORMAL;
    ;
    boolean isSystemClass = true;
    boolean isPartitionedClass = true;
    //test constructor
    ClassInfo classInfo = new ClassInfo(className, ownerName, classType, isSystemClass, isPartitionedClass);
    assertNotNull(classInfo);
    //test 	getters and setters	
    classInfo.setClassName(className);
    classInfo.setOwnerName(ownerName);
    classInfo.setClassType(classType);
    classInfo.setSystemClass(isSystemClass);
    classInfo.setPartitionedClass(isPartitionedClass);
    assertEquals(classInfo.getClassName(), className);
    assertEquals(classInfo.getOwnerName(), ownerName);
    assertEquals(classInfo.getClassType(), classType);
    assertTrue(classInfo.isSystemClass());
    assertTrue(classInfo.isPartitionedClass());
}
Also used : ClassType(com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType)

Example 4 with ClassType

use of com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType in project cubrid-manager by CUBRID.

the class GetAllClassListTask method getSchema.

/**
	 * Get schema list
	 * 
	 * @param isUserSchema boolean
	 * @param isTable boolean
	 * @return List<ClassInfo>
	 */
public List<ClassInfo> getSchema(boolean isUserSchema, boolean isTable) {
    List<ClassInfo> allClassInfoList = new ArrayList<ClassInfo>();
    try {
        if (errorMsg != null && errorMsg.trim().length() > 0) {
            return allClassInfoList;
        }
        if (connection == null || connection.isClosed()) {
            errorMsg = Messages.error_getConnection;
            return allClassInfoList;
        }
        String sql = "SELECT class_name, owner_name, class_type, is_system_class, partitioned FROM db_class AS a " + "WHERE LOWER(a.class_name) NOT IN (SELECT LOWER(partition_class_name) FROM db_partition)";
        if (isUserSchema) {
            sql += " AND is_system_class='NO'";
        } else {
            sql += " AND is_system_class='YES'";
        }
        if (isTable) {
            sql += " AND class_type='CLASS'";
        } else {
            sql += " AND class_type='VCLASS'";
        }
        if (!isUserSchema) {
            sql += " OR class_name='" + ConstantsUtil.SCHEMA_DESCRIPTION_TABLE + "'";
            sql += " OR class_name='" + ConstantsUtil.CUNITOR_HA_TABLE + "'";
        }
        sql = databaseInfo.wrapShardQuery(sql);
        boolean existSchemaCommentTable = false;
        stmt = connection.createStatement();
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
            String className = rs.getString("class_name");
            if (ConstantsUtil.SCHEMA_DESCRIPTION_TABLE.equals(className)) {
                existSchemaCommentTable = true;
            }
            if (isUserSchema && ConstantsUtil.isExtensionalSystemTable(className)) {
                continue;
            }
            String ownerName = rs.getString("owner_name");
            String classType = rs.getString("class_type");
            ClassType type = ClassType.NORMAL;
            if (classType != null && classType.trim().equalsIgnoreCase("VCLASS")) {
                type = ClassType.VIEW;
            }
            String isSystemClazz = rs.getString("is_system_class");
            boolean isSystemClass = false;
            if (isSystemClazz != null && isSystemClazz.trim().equalsIgnoreCase("YES")) {
                isSystemClass = true;
            }
            String partitioned = rs.getString("partitioned");
            boolean isPartitioned = false;
            if (partitioned != null && partitioned.equalsIgnoreCase("YES")) {
                isPartitioned = true;
            }
            ClassInfo classInfo = new ClassInfo(className, ownerName, type, isSystemClass, isPartitioned);
            allClassInfoList.add(classInfo);
        }
        databaseInfo.setSupportTableComment(existSchemaCommentTable);
    //			// for table/column description table (_db_description)
    //			if (existSchemaCommentTable && !isUserSchema && isTable) {
    //				ClassInfo classInfo = new ClassInfo(
    //						ConstantsUtil.SCHEMA_DESCRIPTION_TABLE, "PUBLIC",
    //						ClassType.NORMAL, true, false);
    //				allClassInfoList.add(classInfo);
    //			}
    } catch (SQLException e) {
        errorMsg = e.getMessage();
        LOGGER.error(e.getMessage(), e);
    } finally {
        finish();
    }
    return allClassInfoList;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ClassType(com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 5 with ClassType

use of com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType in project cubrid-manager by CUBRID.

the class GetAllClassListTask method getClassInfoTaskExcute.

/**
	 * 
	 * Get class information
	 * 
	 */
public void getClassInfoTaskExcute() {
    try {
        if (errorMsg != null && errorMsg.trim().length() > 0) {
            return;
        }
        if (connection == null || connection.isClosed()) {
            errorMsg = Messages.error_getConnection;
            return;
        }
        if (tableName == null) {
            errorMsg = Messages.error_invalidInput;
            return;
        }
        String sql = "SELECT class_name, owner_name, class_type, is_system_class," + " partitioned FROM db_class WHERE class_name=?";
        // [TOOLS-2425]Support shard broker
        if (databaseInfo != null) {
            sql = databaseInfo.wrapShardQuery(sql);
        }
        stmt = connection.prepareStatement(sql);
        ((PreparedStatement) stmt).setString(1, tableName.toLowerCase(Locale.getDefault()));
        rs = ((PreparedStatement) stmt).executeQuery();
        if (rs.next()) {
            String className = rs.getString("class_name");
            String ownerName = rs.getString("owner_name");
            String classType = rs.getString("class_type");
            ClassType type = ClassType.NORMAL;
            if (classType != null && classType.trim().equalsIgnoreCase("VCLASS")) {
                type = ClassType.VIEW;
            }
            String isSystemClazz = rs.getString("is_system_class");
            boolean isSystemClass = false;
            if (isSystemClazz != null && isSystemClazz.trim().equalsIgnoreCase("YES")) {
                isSystemClass = true;
            }
            String partitioned = rs.getString("partitioned");
            boolean isPartitioned = false;
            if (partitioned != null && partitioned.equalsIgnoreCase("YES")) {
                isPartitioned = true;
            }
            classInfo = new ClassInfo(className, ownerName, type, isSystemClass, isPartitioned);
        }
    } catch (SQLException e) {
        errorMsg = e.getMessage();
    } finally {
        finish();
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) ClassType(com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Aggregations

ClassType (com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType)6 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)4 SQLException (java.sql.SQLException)4 ArrayList (java.util.ArrayList)3 PreparedStatement (java.sql.PreparedStatement)2