use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class BackupErrLogDialog method loadData.
/**
* load the data
*
* @param shell Shell
* @return boolean
*/
public boolean loadData(Shell shell) {
CommonQueryTask<BackUpErrorLogList> task = new CommonQueryTask<BackUpErrorLogList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonSimpleSendMsg(), new BackUpErrorLogList());
connect(-1, new SocketTask[] { task }, true, shell);
if (task.getErrorMsg() != null) {
return false;
}
List<BackUpErrorLog> allErrLogList = task.getResultModel().getErrorLogList();
if (allErrLogList != null) {
for (BackUpErrorLog backUpErrorLog : allErrLogList) {
if (backUpErrorLog.getDbname().equals(database.getName())) {
errorLogList.addError(backUpErrorLog);
}
}
}
return true;
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class GetDbSpaceInfoTaskTest method testNotExistDb.
public void testNotExistDb() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
task.setDbName("notexistdb");
task.setUsingSpecialDelimiter(false);
task.execute();
assertFalse(task.isSuccess());
DbSpaceInfoList bean = task.getResultModel();
assertNotNull(task.getErrorMsg());
assertEquals("{\"dbname\":\"notexistdb\",\"freespace\":\"0\",\"pagesize\":\"-1\",\"spaceInfoMap\":{},\"spaceinfo\":\"\",\"taskName\":\"dbspaceinfo\"}", JsonObjectUtil.object2json(bean));
// I expect failure result perfectly. But, fragment result attributes are exists. This may be the cmserver bug.
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class GetDbSpaceInfoTaskTest method testExistDb.
public void testExistDb() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
task.setDbName("demodb");
task.setUsingSpecialDelimiter(false);
task.execute();
assertTrue(task.isSuccess());
DbSpaceInfoList bean = task.getResultModel();
assertNull(task.getErrorMsg());
assertEquals(true, bean.getSpaceinfo().size() > 0);
assertEquals("{\"dbname\":\"demodb\",\"freespace\":\"15216\",\"pagesize\":\"4096\",\"spaceInfoMap\":{\"\":{\"date\":\"\",\"freepage\":\"0\",\"location\":\"\",\"spacename\":\"\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"0\",\"type\":\"\",\"volumeCount\":\"1\"},\"ACTIVE_LOG\":{\"date\":\"20090703\",\"freepage\":\"0\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"Active_log\",\"volumeCount\":\"1\"},\"ARCHIVE_LOG\":{\"date\":\"20090620\",\"freepage\":\"0\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"4839\",\"type\":\"Archive_log\",\"volumeCount\":\"3\"},\"DATA\":{\"date\":\"20090702\",\"freepage\":\"2020\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"DATA\",\"volumeCount\":\"1\"},\"GENERIC\":{\"date\":\"20090703\",\"freepage\":\"1836\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"GENERIC\",\"volumeCount\":\"1\"}},\"spaceinfo\":[{\"date\":\"20090703\",\"freepage\":\"1836\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"demodb\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"GENERIC\",\"volumeCount\":\"0\"},{\"date\":\"20090702\",\"freepage\":\"2020\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"demodb_data_x001\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"DATA\",\"volumeCount\":\"0\"},{\"date\":\"20090620\",\"freepage\":\"0\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"demodb_lgar001\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2188\",\"type\":\"Archive_log\",\"volumeCount\":\"0\"},{\"date\":\"20090703\",\"freepage\":\"0\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"demodb_lgat\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"Active_log\",\"volumeCount\":\"0\"},{\"date\":\"20090626\",\"freepage\":\"0\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"demodb_lgar002\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"91\",\"type\":\"Archive_log\",\"volumeCount\":\"0\"},{\"date\":\"20090614\",\"freepage\":\"0\",\"location\":\"\\/opt\\/frameworks\\/cubrid2\\/databases\\/demodb\",\"spacename\":\"demodb_lgar000\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"2560\",\"type\":\"Archive_log\",\"volumeCount\":\"0\"},{\"date\":\"\",\"freepage\":\"0\",\"location\":\"\",\"spacename\":\"Total\",\"totalPageStr\":\"\",\"totalSizeStr\":\"\",\"totalpage\":\"0\",\"type\":\"\",\"volumeCount\":\"0\"}],\"taskName\":\"dbspaceinfo\"}", JsonObjectUtil.object2json(bean));
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class AddAndDelStatusTemplateTaskTest method testExec2.
public void testExec2() {
StatusTemplateInfo info = new StatusTemplateInfo();
info.setDb_name(testDbName);
info.setDesc("testStatus");
info.setName("newStatus");
TargetConfigInfo targetConfigInfo = new TargetConfigInfo();
targetConfigInfo.setCas_st_long_tran(new String[] { "aaa", "dd", "dd" });
info.addTarget_config(targetConfigInfo);
info.setSampling_term("1");
AddStatusTemplateTask task = new AddStatusTemplateTask(serverInfo);
task.setStatusTemplateInfo(info);
task.buildMsg();
task.execute();
assertNull(task.getErrorMsg());
StatusTemplateInfos bean = new StatusTemplateInfos();
final CommonQueryTask<StatusTemplateInfos> showTask = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), bean);
showTask.execute();
bean.getStatusTemplateInfoList();
assertEquals(bean.getTaskName(), "getstatustemplate");
DelStatusTemplateTask delTsk = new DelStatusTemplateTask(serverInfo);
delTsk.setTemplateName("newStatus");
delTsk.execute();
assertNull(delTsk.getErrorMsg());
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class DeleteDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISelectionProvider provider = this.getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
if (database == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
task.setDbName(database.getName());
TaskExecutor taskExcutor = new CommonTaskExec(Messages.getDbSpaceInfoTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
DeleteDatabaseDialog dlg = new DeleteDatabaseDialog(getShell());
dlg.setDbSpaceInfo(task.getResultModel());
dlg.setDatabase(database);
ICubridNode parent = database.getParent();
if (dlg.open() == DeleteDatabaseDialog.DELETE_ID) {
boolean isContinue = DatabaseUtils.processDatabaseDeleted(database);
if (isContinue) {
TreeViewer viewer = (TreeViewer) provider;
parent.removeChild(database);
viewer.remove(parent, obj);
viewer.setSelection(new StructuredSelection(parent));
}
}
}
Aggregations