use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class CubridBrokerFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
//when refresh broker,firstly check whether this broker exist
int ret = checkBrokerExist(parent, monitor);
if (ret == 1 || ret == 2) {
setLoaded(true);
return;
}
if (ret != 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.errBrokerNoExist);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer != null) {
CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
}
}
});
setLoaded(true);
return;
}
// add sql log folder
String sqlLogFolderId = parent.getId() + NODE_SEPARATOR + SQL_LOG_FOLDER_ID;
ICubridNode sqlLogFolder = parent.getChild(sqlLogFolderId);
if (sqlLogFolder == null) {
sqlLogFolder = new DefaultCubridNode(sqlLogFolderId, SQL_LOG_FOLDER_NAME, "icons/navigator/folder.png");
sqlLogFolder.setType(CubridNodeType.BROKER_SQL_LOG_FOLDER);
sqlLogFolder.setContainer(true);
parent.addChild(sqlLogFolder);
}
//add the children of sql log folder
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(parent.getLabel());
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
sqlLogFolder.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
sqlLogFolder.removeAllChild();
brokerLogInfos = task.getResultModel();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfo : logInfoList) {
String id = sqlLogFolder.getId() + NODE_SEPARATOR + logInfo.getName();
ICubridNode logInfoNode = new DefaultCubridNode(id, logInfo.getName(), "icons/navigator/sqllog_item.png");
logInfoNode.setContainer(false);
logInfoNode.setEditorId(LogEditorPart.ID);
logInfoNode.setModelObj(logInfo);
if (LogType.SCRIPT.getText().toLowerCase().equals(logInfo.getType())) {
logInfoNode.setType(CubridNodeType.BROKER_SQL_LOG);
sqlLogFolder.addChild(logInfoNode);
}
}
}
Collections.sort(sqlLogFolder.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class GetBrokerInfoTaskTest method testExecute.
public void testExecute() {
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
task.execute();
task.setUsingSpecialDelimiter(false);
brokerInfos = task.getResultModel();
assertTrue(brokerInfos != null && brokerInfos.getBrokerstatus() != null);
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class CopyDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode schemaNode = (ISchemaNode) obj[0];
final CubridDatabase database = schemaNode.getDatabase();
if (database == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
GetDbSizeTask dbSizeTask = new GetDbSizeTask(database.getServer().getServerInfo());
dbSizeTask.setDbName(database.getName());
final CommonQueryTask<DbSpaceInfoList> dbSpaceInfotask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
dbSpaceInfotask.setDbName(database.getName());
ISelectionProvider provider = getSelectionProvider();
final TreeViewer viewer = (TreeViewer) provider;
final CopyDatabaseDialog dlg = new CopyDatabaseDialog(getShell(), viewer);
dlg.execTask(-1, new SocketTask[] { dbSizeTask, dbSpaceInfotask }, true, getShell());
if (dbSpaceInfotask.getErrorMsg() != null || dbSizeTask.isCancel() || dbSizeTask.getErrorMsg() != null || dbSpaceInfotask.isCancel()) {
return;
}
dlg.setDbSize(dbSizeTask.getDbSize());
dlg.setDbSpaceInfo(dbSpaceInfotask.getResultModel());
dlg.setDatabase(database);
dlg.open();
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class EditStatisticHostDialog method refreshDbVolData.
private void refreshDbVolData(String dbName, boolean isInitial) {
boolean isEmptyData = false;
boolean isNeedInitVolNameValue = isNewHost || !isInitial || dbVolNameValue == null;
if (StringUtil.isEmpty(dbName)) {
isEmptyData = true;
} else {
DbSpaceInfoList dbSpaceInfo = new DbSpaceInfoList();
CommonQueryTask<DbSpaceInfoList> dbSpaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
dbSpaceInfoTask.setDbName(dbName);
dbSpaceInfoTask.execute();
if (dbSpaceInfoTask.isSuccess()) {
dbSpaceInfo = dbSpaceInfoTask.getResultModel();
if (dbSpaceInfo.getSpaceinfo() != null && dbSpaceInfo.getSpaceinfo().size() > 0) {
List<DbSpaceInfo> spaceInfoList = dbSpaceInfo.getSpaceinfo();
itemsVolName = new String[spaceInfoList.size()];
for (int i = 0; i < spaceInfoList.size(); i++) {
itemsVolName[i] = spaceInfoList.get(i).getSpacename();
}
if (isNeedInitVolNameValue) {
dbVolNameValue = itemsVolName[0];
}
} else {
isEmptyData = true;
}
} else {
isEmptyData = true;
}
}
if (isEmptyData) {
itemsVolName = ITEMS_EMPTY;
if (isNeedInitVolNameValue) {
dbVolNameValue = VALUE_DEFAULT;
}
}
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask 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;
}
Aggregations