use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo 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();
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class GetAllClassListTask method getAllClassInfoList.
/**
*
* Get all class information list
*
* @return List<ClassInfo>
*/
public List<ClassInfo> getAllClassInfoList() {
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" + " WHERE LOWER(class_name) NOT IN (" + "SELECT LOWER(partition_class_name) FROM db_partition)";
// [TOOLS-2425]Support shard broker
if (databaseInfo != null) {
sql = databaseInfo.wrapShardQuery(sql);
}
stmt = connection.createStatement();
rs = stmt.executeQuery(sql);
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;
}
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);
}
} catch (SQLException e) {
errorMsg = e.getMessage();
} finally {
finish();
}
return allClassInfoList;
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class GetAllClassListTaskTest method testGetAllClassListTaskTest.
public void testGetAllClassListTaskTest() {
//test getSchema method
//test normal case
GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
List<ClassInfo> allClassInfoList = task.getSchema(false, true);
boolean found = false;
for (ClassInfo c : allClassInfoList) {
if (c.getClassName().equals("_db_attribute")) {
found = true;
break;
}
}
assertTrue(found);
task = new GetAllClassListTask(databaseInfo);
allClassInfoList = task.getSchema(false, false);
found = false;
for (ClassInfo c : allClassInfoList) {
if (c.getClassName().equals("db_attribute")) {
found = true;
break;
}
}
assertTrue(found);
//test exception case:connection is closed
task.getSchema(false, false);
//test exception case: have error
task.setErrorMsg("error");
task.getSchema(false, false);
//test getAllClassInfoList method
//test normal case
task = new GetAllClassListTask(databaseInfo);
allClassInfoList = task.getAllClassInfoList();
found = false;
for (ClassInfo c : allClassInfoList) {
if (c.getClassName().equals("db_attribute")) {
found = true;
break;
}
}
assertTrue(found);
//test exception case:connection is closed
task.getAllClassInfoList();
//test exception case: have error
task.setErrorMsg("error");
task.getAllClassInfoList();
//test getClassInfoTaskExcute method
//test normal case
task = new GetAllClassListTask(databaseInfo);
task.setTableName("Db_attribute");
task.getClassInfoTaskExcute();
ClassInfo c = task.getClassInfo();
found = false;
if (c.getClassName().equals("db_attribute")) {
found = true;
}
assertTrue(found);
//test exception case:connection is closed
task.getClassInfoTaskExcute();
//test exception case: have error
task.setErrorMsg("error");
task.getClassInfoTaskExcute();
//test exception case: no table
task = new GetAllClassListTask(databaseInfo);
task.getClassInfoTaskExcute();
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class UserEditor method initial.
/**
*
* Initial the data
*
*/
private void initial() {
if (ownerClassTableViewer == null || ownerClassTableViewer.getControl() == null || ownerClassTableViewer.getControl().isDisposed()) {
return;
}
if (memberList == null) {
memberList = new ArrayList<String>();
}
while (!memberList.isEmpty()) {
memberList.remove(0);
}
for (DbUserInfo bean : userListInfo.getUserList()) {
if (bean.getName().equalsIgnoreCase(userName)) {
userInfo = bean;
}
List<String> groups = bean.getGroups().getGroup();
if (groups != null) {
for (String g : groups) {
if (userName != null && userName.equalsIgnoreCase(g)) {
memberList.add(bean.getName());
break;
}
}
}
}
List<String> groupList = userInfo.getGroups().getGroup();
while (!ownerClassListData.isEmpty()) {
ownerClassListData.remove(0);
}
if (allClassInfoList != null) {
for (ClassInfo c : allClassInfoList) {
if (c.getOwnerName().equalsIgnoreCase(userInfo.getName())) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", c.getClassName());
map.put("1", c.isSystemClass() ? Messages.msgSystemSchema : Messages.msgUserSchema);
map.put("2", c.getClassType() == ClassType.VIEW ? Messages.msgVirtualClass : Messages.msgClass);
ownerClassListData.add(map);
}
}
}
while (!authListData.isEmpty()) {
authListData.remove(0);
}
Map<String, String> classGrantMap = userInfo.getAuthorization();
Iterator<Map.Entry<String, String>> it = classGrantMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
String className = entry.getKey();
if (!partitionClassMap.containsKey(className)) {
String authNum = entry.getValue();
authListData.add(getItemAuthMap(new ClassAuthorizations(className, CommonUITool.str2Int(authNum))));
}
}
ownerClassTableViewer.refresh();
if (!DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
authTableViewer.refresh();
}
for (int i = 0; i < ownerClassTableViewer.getTable().getColumnCount(); i++) {
ownerClassTableViewer.getTable().getColumn(i).pack();
}
if (!DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
for (int i = 0; i < authTableViewer.getTable().getColumnCount(); i++) {
authTableViewer.getTable().getColumn(i).pack();
}
}
StringBuffer sb = new StringBuffer();
if (groupList != null) {
for (int i = 0, n = groupList.size(); i < n; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(groupList.get(i));
}
}
lblUserGroup.setText(Messages.bind(Messages.lblGroupList, sb.length() < 1 ? Messages.lblGroupNotExist : sb.toString()));
sb = new StringBuffer();
if (memberList != null) {
for (int i = 0, n = memberList.size(); i < n; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(memberList.get(i));
}
}
lblUserMember.setText(Messages.bind(Messages.lblMemberList, sb.length() < 1 ? Messages.lblMemberNotExist : sb.toString()));
}
Aggregations