use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask in project cubrid-manager by CUBRID.
the class EditUserAction method doRun.
/**
* Perform do run
*
* @param node
*/
public void doRun(ISchemaNode node) {
// FIXME move this logic to core module
CubridDatabase database = node.getDatabase();
EditUserDialog dlg = new EditUserDialog(shell);
Connection con = null;
try {
con = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo(), con);
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo(), con);
GetUserListTask task = new GetUserListTask(database.getDatabaseInfo(), con);
DbUserInfoList userListInfo = null;
try {
userListInfo = task.getResultModel();
} catch (Exception e) {
LOGGER.error("load user failed", e);
return;
}
boolean isSuccess = dlg.execTask(-1, new ITask[] { classInfoTask, partitionTask }, getShell());
if (!isSuccess) {
return;
}
dlg.setUserListInfo(userListInfo);
dlg.setDatabase(database);
dlg.setUserName(node.getName());
dlg.setPartitionClassMap(partitionTask.getPartitionClassMap());
dlg.setNewFlag(false);
GetUserAuthorizationsTask privilegeTask = new GetUserAuthorizationsTask(database.getDatabaseInfo(), con);
try {
for (DbUserInfo userInfo : userListInfo.getUserList()) {
userInfo.setUserAuthorizations(privilegeTask.getUserAuthorizations(userInfo.getName()));
}
} catch (Exception e) {
LOGGER.error("get user failed", e);
return;
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
QueryUtil.freeQuery(con);
}
if (dlg.open() == IDialogConstants.OK_ID) {
if (database.getServer() != null) {
persisteManager.updateDBPassword(database.getServer().getServerName(), database.getServer().getHostAddress(), database.getServer().getMonPort(), database.getDatabaseInfo().getDbName(), database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName(), dlg.getInputtedPassword(), database.isAutoSavePassword());
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null) {
TreeViewer treeViewer = navigationView.getViewer();
if (treeViewer != null) {
DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (userInfo != null && userInfo.getName().equalsIgnoreCase(node.getName())) {
CommonUITool.openInformationBox(Messages.titleLogout, Messages.msgLogoutInfomation);
database.setLogined(false);
database.setAutoSavePassword(false);
CubridNodeChangedEvent event = new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT);
CubridNodeManager.getInstance().fireCubridNodeChanged(event);
database.removeAllChild();
treeViewer.refresh(database, true);
} else {
CommonUITool.refreshNavigatorTree(treeViewer, node.getParent());
setEnabled(false);
}
}
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
persisteManager.savaAllServers();
persisteManager.saveAllGroupNodes();
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask in project cubrid-manager by CUBRID.
the class AddUserAction method doRun.
/**
* Perform do run
*
* @param node
*/
public void doRun(ISchemaNode node) {
// FIXME move this logic to core module
CubridDatabase database = node.getDatabase();
// if (database.getDatabaseInfo().isHAMode()) {
// CommonUITool.openErrorBox(Messages.errNoSupportInHA);
// return;
// }
String childId = database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridNodeLoader.USERS_FOLDER_ID;
ICubridNode folderNode = database.getChild(childId);
if (folderNode == null) {
return;
}
EditUserDialog dlg = new EditUserDialog(getShell());
Connection con = null;
try {
con = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo(), con);
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo(), con);
GetUserListTask task = new GetUserListTask(database.getDatabaseInfo(), con);
DbUserInfoList userListInfo = null;
try {
userListInfo = task.getResultModel();
} catch (Exception e) {
LOGGER.error("load user failed", e);
return;
}
boolean isSuccess = dlg.execTask(-1, new ITask[] { classInfoTask, partitionTask }, getShell());
if (!isSuccess) {
return;
}
dlg.setUserListInfo(userListInfo);
dlg.setDatabase(database);
dlg.setUserName(node.getName());
dlg.setPartitionClassMap(partitionTask.getPartitionClassMap());
dlg.setNewFlag(true);
GetUserAuthorizationsTask privilegeTask = new GetUserAuthorizationsTask(database.getDatabaseInfo(), con);
try {
for (DbUserInfo userInfo : userListInfo.getUserList()) {
if (userInfo.getName().equals(node.getName())) {
userInfo.setUserAuthorizations(privilegeTask.getUserAuthorizations(userInfo.getName()));
}
}
} catch (Exception e) {
LOGGER.error("get user failed", e);
return;
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
QueryUtil.freeQuery(con);
}
if (dlg.open() == IDialogConstants.OK_ID) {
//Don't count the child
if (!folderNode.getLoader().isLoaded()) {
return;
}
CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
if (navigatorView != null) {
TreeViewer treeViewer = navigatorView.getViewer();
if (treeViewer != null) {
CubridNodeChangedEvent event = new CubridNodeChangedEvent(folderNode, CubridNodeChangedEventType.NODE_REFRESH);
CubridNodeManager.getInstance().fireCubridNodeChanged(event);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
} else {
CommonUITool.refreshNavigatorTree(treeViewer, node.getParent());
setEnabled(false);
}
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask in project cubrid-manager by CUBRID.
the class CQBUserEditor method execTask.
/**
* Execute tasks
*
* @param tasks the task array
* @return boolean
*/
public boolean execTask(final ITask[] tasks) {
TaskExecutor taskExecutor = new TaskExecutor() {
public boolean exec(IProgressMonitor monitor) {
for (ITask t : tasks) {
if (t instanceof GetAllClassListTask) {
allClassInfoList = ((GetAllClassListTask) t).getAllClassInfoList();
} else {
t.execute();
}
if (t instanceof GetUserListTask) {
try {
userListInfo = ((GetUserListTask) t).getResultModel();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
if (t instanceof GetAllPartitionClassTask) {
partitionClassMap = ((GetAllPartitionClassTask) t).getPartitionClassMap();
}
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return false;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (ITask task : tasks) {
taskExecutor.addTask(task);
}
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
return taskExecutor.isSuccess();
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask in project cubrid-manager by CUBRID.
the class UserEditor method loadData.
/**
*
* Load data
*
* @return <code>true</code> if it is successfully;<code>false</code>
* otherwise
*/
public boolean loadData() {
final CommonQueryTask<DbUserInfoList> userTask = new CommonQueryTask<DbUserInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbUserInfoList(), database.getDatabaseInfo().getCharSet());
userTask.setDbName(database.getName());
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo());
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo());
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
if (t instanceof GetAllClassListTask) {
allClassInfoList = ((GetAllClassListTask) t).getAllClassInfoList();
} else {
t.execute();
}
if (t instanceof CommonQueryTask) {
userListInfo = ((CommonQueryTask<DbUserInfoList>) t).getResultModel();
}
if (t instanceof GetAllPartitionClassTask) {
partitionClassMap = ((GetAllPartitionClassTask) t).getPartitionClassMap();
}
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
initial();
}
});
return Status.OK_STATUS;
}
};
taskJobExecutor.addTask(userTask);
taskJobExecutor.addTask(classInfoTask);
taskJobExecutor.addTask(partitionTask);
String jobName = Messages.viewUserInfoJobName + " - " + userName + "@" + database.getName() + "@" + database.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
return true;
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask in project cubrid-manager by CUBRID.
the class CQBUserEditor method loadData.
/**
* Load data
*
* @return <code>true</code> if it is successfully;<code>false</code>
* otherwise
*/
public boolean loadData() {
Connection con = null;
try {
con = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
final GetUserListTask task = new GetUserListTask(database.getDatabaseInfo(), con);
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo(), con);
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo(), con);
execTask(new ITask[] { task, classInfoTask, partitionTask });
GetUserAuthorizationsTask privilegeTask = new GetUserAuthorizationsTask(database.getDatabaseInfo(), con);
try {
for (DbUserInfo userInfo : userListInfo.getUserList()) {
if (userInfo.getName().equals(userName)) {
userInfo.setUserAuthorizations(privilegeTask.getUserAuthorizations(userInfo.getName()));
}
}
} catch (Exception e) {
LOGGER.error("get user failed", e);
}
initial();
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
QueryUtil.freeQuery(con);
}
return true;
}
Aggregations