Search in sources :

Example 1 with QueryPlanInfoHelp

use of com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp in project cubrid-manager by CUBRID.

the class EditQueryPlanDialog method initPara.

/**
	 * Sets the queryPlanInfo and selection which is a folder
	 *
	 * @param selection the selection to set
	 */
public void initPara(DefaultSchemaNode selection) {
    childrenLabel = new ArrayList<String>();
    ICubridNode[] childrenNode = null;
    QueryPlanInfo qpi = null;
    if (operation == AddEditType.EDIT) {
        qpi = (QueryPlanInfo) selection.getAdapter(QueryPlanInfo.class);
        childrenNode = selection.getParent().getChildren(new NullProgressMonitor());
    } else {
        qpi = new QueryPlanInfo();
        childrenNode = selection.getChildren(new NullProgressMonitor());
    }
    queryPlanInfo = new QueryPlanInfoHelp();
    queryPlanInfo.setQueryPlanInfo(qpi);
    database = selection.getDatabase();
    for (ICubridNode childNode : childrenNode) {
        childrenLabel.add(childNode.getLabel());
    }
    withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 2 with QueryPlanInfoHelp

use of com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp in project cubrid-manager by CUBRID.

the class SetAndGetQueryPlanListTaskTest method test.

/**
	 * Tests getBackupPlanListTask method
	 * 
	 */
public void test() {
    QueryPlanInfo queryPlan = new QueryPlanInfo();
    queryPlan.setDbname(testDbName);
    queryPlan.setQuery_id("test_set");
    queryPlan.setPeriod("MONTH");
    queryPlan.setDetail("1 02:01");
    List<String> msgList = new ArrayList<String>();
    QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
    qHelp.setQueryPlanInfo(queryPlan);
    msgList.add(qHelp.buildMsg(true));
    //test set query plans
    SetQueryPlanListTask taskSet = new SetQueryPlanListTask(serverInfo);
    taskSet.setDbname(testDbName);
    taskSet.buildMsg(msgList);
    taskSet.execute();
    String errorSet = taskSet.getErrorMsg();
    assertNull(errorSet);
    //get query plan list
    GetQueryPlanListTask taskGet = new GetQueryPlanListTask(serverInfo);
    taskGet.setDbName(testDbName);
    taskGet.execute();
    String errorGet = taskGet.getErrorMsg();
    assertNull(errorGet);
    List<QueryPlanInfo> queryPlanInfoList = taskGet.getQueryPlanInfoList();
    assertNotNull(queryPlanInfoList);
    if (queryPlanInfoList.size() > 0) {
        QueryPlanInfo info = queryPlanInfoList.get(0);
        assertNotNull(info);
    }
    //delete query plan
    taskSet = new SetQueryPlanListTask(serverInfo);
    taskSet.setDbname(testDbName);
    taskSet.buildMsg(new ArrayList<String>());
    taskSet.execute();
    assertTrue(taskSet.isSuccess());
    taskGet.setErrorMsg("err");
    taskGet.getQueryPlanInfoList();
}
Also used : QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ArrayList(java.util.ArrayList) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 3 with QueryPlanInfoHelp

use of com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp in project cubrid-manager by CUBRID.

the class DeleteQueryPlanAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run(ISchemaNode[] nodeArray) {
    List<String> nodeNames = new ArrayList<String>();
    CubridDatabase database = null;
    for (Object obj : nodeArray) {
        if (obj instanceof DefaultSchemaNode) {
            database = ((DefaultSchemaNode) obj).getDatabase();
        }
        ICubridNode selection = (ICubridNode) obj;
        nodeNames.add(selection.getLabel());
    }
    if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delQueryPlanConfirmContent, nodeNames))) {
        return;
    }
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return;
    }
    ICubridNode parentSelection = ((DefaultSchemaNode) nodeArray[0]).getParent();
    boolean withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
    List<ICubridNode> list = parentSelection.getChildren();
    List<String> msgList = new ArrayList<String>();
    QueryPlanInfo queryPlan = null;
    QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
    for (ICubridNode icn : list) {
        if (!icn.isContainer()) {
            boolean isRemove = false;
            for (String nodeName : nodeNames) {
                if (icn.getLabel().equals(nodeName)) {
                    isRemove = true;
                    break;
                }
            }
            if (isRemove) {
                continue;
            }
            queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
            qHelp.setQueryPlanInfo(queryPlan);
            msgList.add(qHelp.buildMsg(withUser));
        }
    }
    ServerInfo serverInfo = database.getServer().getServerInfo();
    SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
    task.setDbname(database.getName());
    task.buildMsg(msgList);
    String taskName = Messages.bind(Messages.delQueryPlanTaskName, nodeNames);
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    for (Object obj : nodeArray) {
        TreeViewer treeViewer = (TreeViewer) getSelectionProvider();
        DefaultSchemaNode delNode = ((DefaultSchemaNode) obj);
        ICubridNode parentNode = delNode.getParent();
        parentNode.removeChild(delNode);
        treeViewer.remove(delNode);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) SetQueryPlanListTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.SetQueryPlanListTask) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 4 with QueryPlanInfoHelp

use of com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp in project cubrid-manager by CUBRID.

the class EditQueryPlanAction method run.

/**
	 * 
	 * Creates a Dialog which is the instance of EditBackupPlanDialog to edit a
	 * query plan
	 * 
	 */
public int run(CubridDatabase database, DefaultSchemaNode schemaNode) {
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return IDialogConstants.CANCEL_ID;
    }
    boolean withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
    boolean isEditAble = false;
    if (CubridNodeType.QUERY_PLAN.equals(schemaNode.getType()) && database != null && database.isLogined()) {
        DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
            isEditAble = true;
        }
    }
    EditQueryPlanDialog editQueryPlanDlg = new EditQueryPlanDialog(getShell(), isEditAble);
    editQueryPlanDlg.setOperation(AddEditType.EDIT);
    editQueryPlanDlg.initPara(schemaNode);
    if (editQueryPlanDlg.open() == Dialog.OK) {
        // Sets the data of task
        List<ICubridNode> list = schemaNode.getParent().getChildren();
        List<String> msgList = new ArrayList<String>();
        QueryPlanInfo queryPlan = null;
        QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
        for (ICubridNode icn : list) {
            if (!icn.isContainer()) {
                queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
                qHelp.setQueryPlanInfo(queryPlan);
                msgList.add(qHelp.buildMsg(withUser));
            }
        }
        ServerInfo serverInfo = database.getServer().getServerInfo();
        SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
        task.setDbname(database.getName());
        task.buildMsg(msgList);
        String taskName = Messages.bind(com.cubrid.cubridmanager.ui.cubrid.jobauto.Messages.editQueryPlanTaskName, schemaNode.getName());
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).exec();
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(schemaNode, CubridNodeChangedEventType.NODE_REFRESH));
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        return IDialogConstants.OK_ID;
    }
    return IDialogConstants.CANCEL_ID;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) EditQueryPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditQueryPlanDialog) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) SetQueryPlanListTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.SetQueryPlanListTask) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 5 with QueryPlanInfoHelp

use of com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp in project cubrid-manager by CUBRID.

the class AddQueryPlanAction method run.

public void run(CubridDatabase database) {
    ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
    DefaultSchemaNode queryPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.QUERY_PLAN_FOLDER_ID);
    boolean withUser = false;
    if (CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo())) {
        withUser = true;
    }
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    EditQueryPlanDialog editQueryPlanDlg = new EditQueryPlanDialog(getShell(), true);
    editQueryPlanDlg.setDatabase(database);
    editQueryPlanDlg.setOperation(AddEditType.ADD);
    editQueryPlanDlg.initPara(queryPlanFolderNode);
    DefaultSchemaNode newNode = null;
    if (editQueryPlanDlg.open() == Dialog.OK) {
        // Sets the data of task
        QueryPlanInfoHelp queryPlanInfoHelp = editQueryPlanDlg.getQueryPlanInfo();
        QueryPlanInfo queryPlanInfo = queryPlanInfoHelp.getQueryPlanInfo();
        String newQueryId = queryPlanInfoHelp.getQuery_id();
        newNode = new DefaultSchemaNode(newQueryId, newQueryId, ICON_PATH);
        newNode.setContainer(false);
        newNode.setType(CubridNodeType.QUERY_PLAN);
        newNode.setModelObj(queryPlanInfo);
        List<ICubridNode> list = queryPlanFolderNode.getChildren();
        List<String> msgList = new ArrayList<String>();
        QueryPlanInfo queryPlan = null;
        QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
        for (ICubridNode icn : list) {
            if (!icn.isContainer()) {
                queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
                qHelp.setQueryPlanInfo(queryPlan);
                msgList.add(qHelp.buildMsg(withUser));
            }
        }
        qHelp.setQueryPlanInfo(queryPlanInfo);
        msgList.add(qHelp.buildMsg(withUser));
        ServerInfo serverInfo = database.getServer().getServerInfo();
        SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
        task.setDbname(database.getName());
        task.buildMsg(msgList);
        String taskName = Messages.bind(com.cubrid.cubridmanager.ui.cubrid.jobauto.Messages.addQueryPlanTaskName, newQueryId);
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (!taskExecutor.isSuccess()) {
            return;
        }
    } else {
        canceledTask = true;
    }
    if (null != newNode) {
        queryPlanFolderNode.addChild(newNode);
        treeViewer.add(queryPlanFolderNode, newNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) EditQueryPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditQueryPlanDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) SetQueryPlanListTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.SetQueryPlanListTask) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Aggregations

QueryPlanInfo (com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)5 QueryPlanInfoHelp (com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 ArrayList (java.util.ArrayList)4 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)3 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)3 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)3 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 SetQueryPlanListTask (com.cubrid.cubridmanager.core.cubrid.jobauto.task.SetQueryPlanListTask)3 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)2 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)2 EditQueryPlanDialog (com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditQueryPlanDialog)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1