Search in sources :

Example 46 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridMonitorFolderLoader method loadStatusTempInfoTask.

/**
	 * load sub node by the task of getStatusTemplateInfos
	 *
	 * @param parent the parent node
	 * @param monitor the instance of IProgressMonitor
	 * @param serverInfo the instance of serverInfo
	 * @return boolean false if error occur, true if succeed
	 */
private boolean loadStatusTempInfoTask(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo) {
    StatusTemplateInfos statusTemplateInfos = new StatusTemplateInfos();
    final CommonQueryTask<StatusTemplateInfos> task = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), statusTemplateInfos);
    monitorCancel(monitor, new ITask[] { task });
    task.execute();
    final String errorMsg = task.getErrorMsg();
    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
        //parent.removeAllChild();
        removeAllStatusTemp(parent);
        openErrorBox(errorMsg);
        setLoaded(true);
        return false;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return false;
    }
    //parent.removeAllChild();
    removeAllStatusTemp(parent);
    statusTemplateInfos = task.getResultModel();
    if (statusTemplateInfos != null) {
        List<StatusTemplateInfo> list = statusTemplateInfos.getStatusTemplateInfoList().getStatusTemplateInfoList();
        if (list != null) {
            for (StatusTemplateInfo statusTemplateInfo : list) {
                String id = parent.getId() + NODE_SEPARATOR + statusTemplateInfo.getName();
                ICubridNode logInfoNode = new DefaultCubridNode(id, statusTemplateInfo.getName(), "icons/navigator/status_item.png");
                logInfoNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
                logInfoNode.setModelObj(statusTemplateInfo);
                logInfoNode.setViewId(StatusMonitorViewPart.ID);
                logInfoNode.setContainer(false);
                parent.addChild(logInfoNode);
            }
        }
    }
    return true;
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 47 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridStatusMonitorFolderLoader method loadStatusTempInfoTask.

/**
	 * load sub node by the task of getStatusTemplateInfos
	 * 
	 * @param parent the parent node
	 * @param monitor the instance of IProgressMonitor
	 * @param serverInfo the instance of serverInfo
	 * @return boolean false if error occur, true if succeed
	 */
private boolean loadStatusTempInfoTask(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo) {
    StatusTemplateInfos statusTemplateInfos = new StatusTemplateInfos();
    final CommonQueryTask<StatusTemplateInfos> task = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), statusTemplateInfos);
    monitorCancel(monitor, new ITask[] { task });
    task.execute();
    final String errorMsg = task.getErrorMsg();
    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
        parent.removeAllChild();
        openErrorBox(errorMsg);
        setLoaded(true);
        return false;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return false;
    }
    parent.removeAllChild();
    statusTemplateInfos = task.getResultModel();
    if (statusTemplateInfos != null) {
        List<StatusTemplateInfo> list = statusTemplateInfos.getStatusTemplateInfoList().getStatusTemplateInfoList();
        if (list != null) {
            for (StatusTemplateInfo statusTemplateInfo : list) {
                String id = parent.getId() + NODE_SEPARATOR + statusTemplateInfo.getName();
                ICubridNode logInfoNode = new DefaultCubridNode(id, statusTemplateInfo.getName(), "icons/navigator/status_item.png");
                logInfoNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
                logInfoNode.setModelObj(statusTemplateInfo);
                logInfoNode.setViewId(StatusMonitorViewPart.ID);
                logInfoNode.setContainer(false);
                parent.addChild(logInfoNode);
            }
        }
    }
    return true;
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 48 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridDbUsersFolderLoader 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.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        DbUserInfoList dbUserInfoList = new DbUserInfoList();
        final CommonQueryTask<DbUserInfoList> task = new CommonQueryTask<DbUserInfoList>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbUserInfoList, database.getDatabaseInfo().getCharSet());
        task.setDbName(database.getLabel());
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        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();
        dbUserInfoList = task.getResultModel();
        DbUserInfo latestDLoginedbUserInfo = databaseInfo.getAuthLoginedDbUserInfo();
        List<DbUserInfo> dbUserList = dbUserInfoList == null ? null : dbUserInfoList.getUserList();
        formatUserList(dbUserList);
        for (int i = 0; dbUserList != null && dbUserList.size() > i; i++) {
            DbUserInfo dbUserInfo = dbUserList.get(i);
            if (dbUserInfo.getName().equals(latestDLoginedbUserInfo.getName())) {
                dbUserInfo.setDbaAuthority(latestDLoginedbUserInfo.isDbaAuthority());
            // databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
            }
            String id = parent.getId() + NODE_SEPARATOR + dbUserInfo.getName();
            ICubridNode dbUserInfoNode = new DefaultSchemaNode(id, dbUserInfo.getName(), "icons/navigator/user_item.png");
            dbUserInfoNode.setType(CubridNodeType.USER);
            dbUserInfoNode.setModelObj(dbUserInfo);
            dbUserInfoNode.setContainer(false);
            dbUserInfoNode.setEditorId(UserEditor.ID);
            parent.addChild(dbUserInfoNode);
        }
        databaseInfo.setDbUserInfoList(dbUserInfoList);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 49 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridShardFolderLoader 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;
        }
        // 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.getName());
        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) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 50 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class GetLockInfoTaskTest method testSendMessage.

public void testSendMessage() {
    CommonQueryTask<DatabaseLockInfo> task = new CommonQueryTask<DatabaseLockInfo>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DatabaseLockInfo());
    task.setDbName("111ddd");
    task.setUsingSpecialDelimiter(false);
    task.execute();
    DatabaseLockInfo bean = task.getResultModel();
    //		task.get
    assertEquals(null, task.getErrorMsg());
    System.out.println(task.getErrorMsg());
    // test children
    System.out.println("------------the result of task:dbspaceinfo in JSON-----------------");
    System.out.println(JsonObjectUtil.object2json(bean));
    System.out.println("-------------------------------------------------------------------");
}
Also used : DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

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