Search in sources :

Example 36 with CommonQueryTask

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));
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) BrokerLogInfos(com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) Display(org.eclipse.swt.widgets.Display)

Example 37 with CommonQueryTask

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);
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 38 with CommonQueryTask

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();
}
Also used : CopyDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.CopyDatabaseDialog) GetDbSizeTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbSizeTask) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 39 with CommonQueryTask

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;
        }
    }
}
Also used : DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 40 with CommonQueryTask

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) GetAllPartitionClassTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask)

Aggregations

CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)60 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)19 ITask (com.cubrid.common.core.task.ITask)14 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)12 IStatus (org.eclipse.core.runtime.IStatus)12 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)11 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)7 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)7 ArrayList (java.util.ArrayList)7 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)6 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)6 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5