use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class CreateViewAction method run.
public void run(CubridDatabase database) {
TaskExecutor taskExcutor = new CommonTaskExec(null);
DatabaseInfo databaseInfo = database.getDatabaseInfo();
JDBCGetAllDbUserTask task = new JDBCGetAllDbUserTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
List<String> dbUserList = task.getDbUserList();
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, true);
dialog.setDbUserList(dbUserList);
ISelectionProvider provider = getSelectionProvider();
if (dialog.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String viewName = dialog.getNewViewName();
String owner = dialog.getOwner();
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + viewName;
ClassInfo newClassInfo = new ClassInfo(viewName, owner, ClassType.VIEW, false, false);
ICubridNode newNode = CubridViewsFolderLoader.createUserViewNode(id, newClassInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
canceledTask = true;
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class CubridTablesFolderLoader method createUserTableNodes.
/**
* Create user table node
*
* @param parent ICubridNode
* @param allClassInfoList A list includes all the class info
* @param level The load level
* @param monitor The IProgressMonitor
*/
private void createUserTableNodes(ICubridNode parent, List<ClassInfo> allClassInfoList, int level, IProgressMonitor monitor) {
List<String> tables = new ArrayList<String>();
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(true);
classNode.setModelObj(classInfo);
classNode.setType(NodeType.USER_TABLE);
parent.addChild(classNode);
ICubridNodeLoader loader = null;
if (classInfo.isPartitionedClass()) {
classNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
classNode.setIconPath("icons/navigator/schema_table_partition.png");
classNode.setContainer(true);
loader = new CubridPartitionedTableLoader();
} else {
loader = new CubridUserTableLoader();
}
loader.setLevel(level);
classNode.setLoader(loader);
tables.add(classInfo.getClassName());
}
if (level == DEFINITE_LEVEL) {
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetUserClassColumnsTask task = new GetUserClassColumnsTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
Map<String, List<TableColumn>> columnsOfTable = task.getColumns(tables);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && !task.isInTransation() && errorMsg != null && errorMsg.trim().length() > 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
parent.removeAllChild();
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
for (ClassInfo classInfo : allClassInfoList) {
String tableId = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode node = parent.getChild(tableId);
CubridUserTableLoader tableLoader = (CubridUserTableLoader) node.getLoader();
tableLoader.setColumns(columnsOfTable.get(classInfo.getClassName()));
node.getChildren(monitor);
tableLoader.setLoaded(true);
}
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class CubridSystemTableFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
database.getDatabaseInfo().setSysTableInfoList(null);
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
List<ClassInfo> allClassInfoList = task.getSchema(false, true);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
parent.removeAllChild();
if (allClassInfoList != null) {
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
classNode.setType(NodeType.SYSTEM_TABLE);
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(false);
classNode.setModelObj(classInfo);
parent.addChild(classNode);
}
}
database.getDatabaseInfo().setSysTableInfoList(allClassInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class EditUserDialog method setAuthBtnEnableDisable.
/**
* Set the auth button disable
*
*/
@SuppressWarnings("unchecked")
private void setAuthBtnEnableDisable() {
grantButton.setEnabled(false);
revokeButton.setEnabled(false);
/*Can't grant/revoke for current login user*/
if (StringUtil.isEqual(this.userName, currentUserInfo.getName())) {
return;
}
DbUserInfo currentUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
boolean isDbaAuthority = currentUserInfo.isDbaAuthority();
if (classTable.getSelectionCount() > 0 && classTable.isFocusControl()) {
boolean tag = true;
if (!isDbaAuthority) {
for (TableItem item : classTable.getSelection()) {
ClassAuthorizations authorizations = currentUserAuthorizations.get(item.getText());
boolean ownertag = false;
for (ClassInfo bean : allClassInfoList) {
if (item.getText().equals(bean.getClassName())) {
if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) {
ownertag = true;
}
break;
}
}
tag = tag && (ownertag || authorizations == null || authorizations.isGrantPriv());
if (!tag) {
break;
}
}
}
grantButton.setEnabled(tag);
} else if (authTable.getSelectionCount() > 0 && authTable.isFocusControl()) {
boolean tag = true;
if (!isDbaAuthority) {
for (TableItem item : authTable.getSelection()) {
ClassAuthorizations authorizations = currentUserAuthorizations.get(item.getText());
boolean ownertag = false;
for (ClassInfo bean : allClassInfoList) {
if (item.getText().equals(bean.getClassName())) {
if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) {
ownertag = true;
}
break;
}
}
tag = tag && (ownertag || authorizations == null || (authorizations.isAllPriv() || authorizations.isRevokePriv((Map<String, Object>) item.getData())));
if (!tag) {
break;
}
}
}
revokeButton.setEnabled(tag);
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.
the class EditUserDialog method initial.
/**
* Initial data
*/
private void initial() {
if (!CubridDatabase.hasValidDatabaseInfo(database)) {
LOGGER.error("The database is invalid.");
return;
}
this.currentUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
currentUserAuthorizations = currentUserInfo.getUserAuthorizations();
for (DbUserInfo userInfo : userListInfo.getUserList()) {
if (userInfo.getName().equals(currentUserInfo.getName())) {
currentUserInfo = userInfo;
currentUserAuthorizations = currentUserInfo.getUserAuthorizations();
break;
}
}
List<String> groupList = null;
if (newFlag) {
userNameText.setEnabled(true);
classGrantMap = new HashMap<String, ClassAuthorizations>();
Map<String, String> map = new HashMap<String, String>();
map.put("0", DB_DEFAULT_USERNAME);
groupList = new ArrayList<String>();
groupList.add(DB_DEFAULT_USERNAME);
} else {
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)) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", bean.getName());
memberListData.add(map);
}
}
}
}
memberTableViewer.refresh();
if (database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName().equalsIgnoreCase(userName) || database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName().equalsIgnoreCase(DB_DBA_USERNAME)) {
changePwdBtn.setEnabled(true);
} else {
changePwdBtn.setEnabled(false);
}
userNameText.setText(userInfo.getName());
groupList = userInfo.getGroups().getGroup();
classGrantMap = userInfo.getUserAuthorizations();
oldLoginPassword = database.getDatabaseInfo().getAuthLoginedDbUserInfo().getNoEncryptPassword();
if (oldLoginPassword == null) {
oldLoginPassword = "";
}
}
Map<String, String> groupMap = new HashMap<String, String>();
Map<String, String> memberMap = new HashMap<String, String>();
// set group map
if (groupList == null) {
groupList = new ArrayList<String>();
}
for (String group : groupList) {
groupMap.put(group.toLowerCase(Locale.getDefault()), "");
}
if (memberListData != null) {
for (Map<String, String> map : memberListData) {
memberMap.put(map.get("0").toLowerCase(Locale.getDefault()), "");
}
}
for (DbUserInfo user : userListInfo.getUserList()) {
if (!groupMap.containsKey(user.getName().toLowerCase()) && !memberMap.containsKey(user.getName().toLowerCase()) && !user.getName().equalsIgnoreCase(userName)) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", user.getName().toLowerCase());
allUserListData.add(map);
}
}
for (String userName : groupList) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", userName.toLowerCase(Locale.getDefault()));
groupListData.add(map);
}
allUserTableViewer.refresh();
groupTableViewer.refresh();
Iterator<String> authIter = classGrantMap.keySet().iterator();
while (authIter.hasNext()) {
String className = authIter.next();
if (!partitionClassMap.containsKey(className)) {
authListData.add(getItemAuthMap(classGrantMap.get(className)));
authListDataOld.add(getItemAuthMap(classGrantMap.get(className)));
}
}
if (!DB_DBA_USERNAME.equalsIgnoreCase(userName) && !isDBAGroup()) {
authTableViewer.refresh();
for (ClassInfo bean : allClassInfoList) {
if (classGrantMap.containsKey(bean.getClassName()) || bean.isSystemClass() || bean.getOwnerName().equalsIgnoreCase(DB_DEFAULT_USERNAME)) {
continue;
}
Map<String, String> map = new HashMap<String, String>();
map.put("0", bean.getClassName());
map.put("1", Messages.msgUserSchema);
map.put("2", bean.getOwnerName());
map.put("3", bean.getClassType() == ClassType.VIEW ? Messages.msgVirtualClass : Messages.msgClass);
classListData.add(map);
}
classTableViewer.refresh();
packTable(classTable);
packTable(authTable);
}
packTable(allUserTable);
packTable(userGroupTable);
packTable(memberTableViewer.getTable());
}
Aggregations