Search in sources :

Example 6 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo 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 7 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class DiagStatusMonitorTemplateDialog method init.

/**
	 * Initializes the parameter of this view
	 */
private void init() {
    // Sets the title and message
    if (operation == AddEditType.ADD) {
        setTitle(ADD_TITLE);
        setMessage(ADD_MESSAGE);
        getShell().setText(ADD_TITLE);
        isOkenable[2] = true;
        isOkenable[3] = true;
    } else if (operation == AddEditType.EDIT) {
        setTitle(EDIT_TITLE);
        setMessage(EDIT_MESSAGE);
        getShell().setText(EDIT_TITLE);
        for (int i = 0; i < isOkenable.length; i++) {
            isOkenable[i] = true;
        }
    }
    // Sets contents in controls
    if (null == selection) {
        return;
    }
    StatusTemplateInfo statusTemplateInfo = new StatusTemplateInfo();
    List<String> dbs = null;
    if (CubridNodeType.STATUS_MONITOR_FOLDER.equals(selection.getType())) {
        dbs = selection.getServer().getServerInfo().getAllDatabaseList();
        if (null != targetDbNameCombo) {
            targetDbNameCombo.setItems((String[]) (dbs.toArray(new String[dbs.size()])));
            targetDbNameCombo.setEnabled(false);
        }
        return;
    }
    if (CubridNodeType.STATUS_MONITOR_TEMPLATE.equals(selection.getType())) {
        dbs = selection.getServer().getServerInfo().getAllDatabaseList();
        statusTemplateInfo = (StatusTemplateInfo) selection.getAdapter(StatusTemplateInfo.class);
    }
    if (null != dbs && null != targetDbNameCombo) {
        targetDbNameCombo.setItems((String[]) (dbs.toArray(new String[dbs.size()])));
    }
    String name = statusTemplateInfo.getName();
    nameText.setText(name);
    nameText.setEnabled(false);
    String sampling = statusTemplateInfo.getSampling_term();
    samplingTermscombo.setText(sampling);
    String desc = statusTemplateInfo.getDesc();
    discriptionText.setText(desc);
    if (null != targetDbNameCombo) {
        String dbName = statusTemplateInfo.getDb_name();
        targetDbNameCombo.setText(dbName);
    }
    List<TargetConfigInfo> list = statusTemplateInfo.getTargetConfigInfoList();
    EnumMap<EnumTargetConfig, TargetConfig> group = TargetConfigMap.getInstance().getMap();
    boolean hasServer = false;
    for (TargetConfigInfo tcf : list) {
        for (String[] strings : tcf.getList()) {
            for (Map.Entry<EnumTargetConfig, TargetConfig> entry : group.entrySet()) {
                TargetConfig tc = entry.getValue();
                if (strings[0].equals(tc.getName())) {
                    TableItem newItem = new TableItem(tagetTbl, SWT.NONE);
                    newItem.setText(0, tc.getCategory());
                    newItem.setText(1, tc.getDisplayName());
                    newItem.setData(tc);
                    if (tc.getTopCategory().equals(TargetConfigMap.getInstance().getDbCategory())) {
                        hasServer = true;
                    }
                    break;
                }
            }
        }
    }
    if (null != targetDbNameCombo) {
        if (hasServer) {
            targetDbNameCombo.setEnabled(true);
        } else {
            targetDbNameCombo.setEnabled(false);
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) EnumTargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig) TargetConfigInfo(com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo) TargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfig) EnumTargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) TargetConfigMap(com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfigMap) Map(java.util.Map) EnumMap(java.util.EnumMap)

Example 8 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class AddAndDelStatusTemplateTaskTest method testExec.

public void testExec() {
    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());
}
Also used : StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) TargetConfigInfo(com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo)

Example 9 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class UpdateStatusTemplateTaskTest method testReceive.

public void testReceive() {
    StatusTemplateInfo info = new StatusTemplateInfo();
    info.setDb_name(testDbName);
    info.setDesc("testStatus");
    info.setName("newStatus");
    info.setSampling_term("1");
    AddStatusTemplateTask task = new AddStatusTemplateTask(serverInfo);
    task.setStatusTemplateInfo(info);
    task.buildMsg();
    task.execute();
    assertNull(task.getErrorMsg());
    info.setDesc("updateStatus");
    TargetConfigInfo targetConfig = new TargetConfigInfo();
    targetConfig.setCas_st_query(new String[] { "red", "2.0" });
    info.addTarget_config(targetConfig);
    UpdateStatusTemplateTask updateTask = new UpdateStatusTemplateTask(serverInfo);
    updateTask.setStatusTemplateInfo(info);
    updateTask.buildMsg();
    updateTask.execute();
    assertNull(updateTask.getErrorMsg());
    DelStatusTemplateTask delTsk = new DelStatusTemplateTask(serverInfo);
    delTsk.setTemplateName("newStatus");
    delTsk.execute();
    assertNull(delTsk.getErrorMsg());
}
Also used : StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) TargetConfigInfo(com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo)

Example 10 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class UpdateStatusTemplateTaskTest method testReceive2.

public void testReceive2() {
    StatusTemplateInfo info = new StatusTemplateInfo();
    info.setDb_name(testDbName);
    info.setDesc("testStatus");
    info.setName("newStatus");
    info.setSampling_term("1");
    AddStatusTemplateTask task = new AddStatusTemplateTask(serverInfo);
    task.setStatusTemplateInfo(info);
    task.buildMsg();
    task.execute();
    assertNull(task.getErrorMsg());
    info.setDesc("updateStatus");
    TargetConfigInfo targetConfig = new TargetConfigInfo();
    targetConfig.setCas_st_query(new String[] { "red", "2.0" });
    info.addTarget_config(targetConfig);
    UpdateStatusTemplateTask updateTask = new UpdateStatusTemplateTask(serverInfo);
    updateTask.setStatusTemplateInfo(info);
    updateTask.buildMsg();
    updateTask.execute();
    assertNull(updateTask.getErrorMsg());
    DelStatusTemplateTask delTsk = new DelStatusTemplateTask(serverInfo);
    delTsk.setTemplateName("newStatus");
    delTsk.execute();
    assertNull(delTsk.getErrorMsg());
}
Also used : StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) TargetConfigInfo(com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo)

Aggregations

StatusTemplateInfo (com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo)10 TargetConfigInfo (com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo)6 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)5 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 StatusTemplateInfos (com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)2 DiagStatusMonitorTemplateDialog (com.cubrid.cubridmanager.ui.monitoring.dialog.DiagStatusMonitorTemplateDialog)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 AddStatusTemplateTask (com.cubrid.cubridmanager.core.monitoring.task.AddStatusTemplateTask)1 UpdateStatusTemplateTask (com.cubrid.cubridmanager.core.monitoring.task.UpdateStatusTemplateTask)1 EnumTargetConfig (com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig)1 TargetConfig (com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfig)1 TargetConfigMap (com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfigMap)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1