Search in sources :

Example 6 with BackupPlanInfo

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

the class AddBackupPlanAction method run.

/**
	 * Creates a Dialog which is the instance of EditBackupPlanDialog to add a backup plan
	 *
	 * @param database
	 */
public void run(CubridDatabase database) {
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
    DefaultSchemaNode buckupPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID);
    EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), true);
    editBackupPlanDlg.setOperation(AddEditType.ADD);
    editBackupPlanDlg.initPara(buckupPlanFolderNode);
    if (editBackupPlanDlg.open() == Dialog.OK) {
        BackupPlanInfo backupPlanInfo = editBackupPlanDlg.getBackupPlanInfo();
        String newBackupId = backupPlanInfo.getBackupid();
        DefaultSchemaNode newNode = new DefaultSchemaNode(newBackupId, newBackupId, ICON_PATH);
        newNode.setContainer(false);
        newNode.setType(CubridNodeType.BACKUP_PLAN);
        newNode.setModelObj(backupPlanInfo);
        buckupPlanFolderNode.addChild(newNode);
        treeViewer.add(buckupPlanFolderNode, newNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    } else {
        canceledTask = true;
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) EditBackupPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Example 7 with BackupPlanInfo

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

the class CubridBackupPlanFolderLoader 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();
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetBackupPlanListTask task = new GetBackupPlanListTask(parent.getServer().getServerInfo());
        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();
        List<BackupPlanInfo> backupPlanInfoList = task.getBackupPlanInfoList();
        if (backupPlanInfoList != null && !backupPlanInfoList.isEmpty()) {
            for (BackupPlanInfo backupPlanInfo : backupPlanInfoList) {
                String id = parent.getId() + NODE_SEPARATOR + backupPlanInfo.getBackupid();
                ICubridNode backupPlanInfoNode = new DefaultSchemaNode(id, backupPlanInfo.getBackupid(), "icons/navigator/auto_backup_item.png");
                backupPlanInfoNode.setContainer(false);
                backupPlanInfoNode.setType(CubridNodeType.BACKUP_PLAN);
                backupPlanInfoNode.setModelObj(backupPlanInfo);
                parent.addChild(backupPlanInfoNode);
            }
        }
        databaseInfo.setBackupPlanInfoList(backupPlanInfoList);
        Collections.sort(parent.getChildren());
        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) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo) GetBackupPlanListTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.GetBackupPlanListTask)

Example 8 with BackupPlanInfo

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

the class DatabaseInfoTest method testRemoveBackupPlanInfo.

public void testRemoveBackupPlanInfo() {
    bean.removeBackupPlanInfo(new BackupPlanInfo());
    bean.setBackupPlanInfoList(new ArrayList<BackupPlanInfo>());
    bean.removeBackupPlanInfo(new BackupPlanInfo());
    bean.removeAllBackupPlanInfo();
}
Also used : BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Example 9 with BackupPlanInfo

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

the class GetBackupPlanListTask method getBackupPlanInfoList.

/**
	 * Get a list that includes the instances of BackupPlanInfo
	 *
	 * @return List<BackupPlanInfo> a list that includes the instances of
	 *         BackupPlanInfo
	 */
public List<BackupPlanInfo> getBackupPlanInfoList() {
    List<BackupPlanInfo> backupPlanInfoList = new ArrayList<BackupPlanInfo>();
    if (null != getErrorMsg()) {
        return null;
    }
    TreeNode result = getResponse();
    if (result == null) {
        return null;
    }
    // start
    // Since the original data format is wrong, therefore the data requires
    // special handling
    List<TreeNode> children = result.getChildren();
    if (children != null) {
        for (TreeNode child : children) {
            for (Entry<String, String> data : child.getValueByMap().entrySet()) {
                result.add(data.getKey(), data.getValue());
            }
        }
    }
    // end
    boolean supportBkNum = CompatibleUtil.isBackupNumSupports(getServerInfo());
    String dbname = result.getValue("dbname");
    String[] backupidArr = result.getValues("backupid");
    String[] pathArr = result.getValues("path");
    String[] periodTypeArr = result.getValues("period_type");
    String[] periodDateArr = result.getValues("period_date");
    String[] timeArr = result.getValues("time");
    String[] levelArr = result.getValues("level");
    String[] archiveDelArr = result.getValues("archivedel");
    String[] updatestatusArr = result.getValues("updatestatus");
    String[] storeoldArr = result.getValues("storeold");
    String[] onoffArr = result.getValues("onoff");
    String[] zipArr = result.getValues("zip");
    String[] checkArr = result.getValues("check");
    String[] mtArr = result.getValues("mt");
    String[] bknumArr = null;
    if (supportBkNum) {
        bknumArr = result.getValues("bknum");
    }
    if (null == backupidArr) {
        return null;
    }
    for (int i = 0; i < backupidArr.length; i++) {
        BackupPlanInfo backupPlanInfo = new BackupPlanInfo();
        backupPlanInfo.setDbname(dbname);
        backupPlanInfo.setBackupid(backupidArr[i]);
        backupPlanInfo.setPath(pathArr[i]);
        backupPlanInfo.setPeriod_type(periodTypeArr[i]);
        backupPlanInfo.setPeriod_date(periodDateArr[i]);
        backupPlanInfo.setTime(timeArr[i]);
        backupPlanInfo.setLevel(levelArr[i]);
        backupPlanInfo.setArchivedel(archiveDelArr[i]);
        backupPlanInfo.setUpdatestatus(updatestatusArr[i]);
        backupPlanInfo.setStoreold(storeoldArr[i]);
        backupPlanInfo.setOnoff(onoffArr[i]);
        backupPlanInfo.setZip(zipArr[i]);
        backupPlanInfo.setCheck(checkArr[i]);
        backupPlanInfo.setMt(mtArr[i]);
        if (supportBkNum) {
            backupPlanInfo.setBknum(bknumArr[i]);
        }
        backupPlanInfoList.add(backupPlanInfo);
    }
    return backupPlanInfoList;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Example 10 with BackupPlanInfo

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

the class JobAutoDashboardEditorPart method editBackupPlan.

public void editBackupPlan() {
    TableItem[] items = backupPlanInfoTable.getTable().getSelection();
    if (items.length != 0) {
        TableItem item = items[0];
        BackupPlanInfo backupPlanInfo = (BackupPlanInfo) item.getData();
        ICubridNode backupPlanNode = findAutoJobInfoNode(CubridNodeType.BACKUP_PLAN, backupPlanInfo.getBackupid());
        if (backupPlanNode != null) {
            EditBackupPlanAction action = (EditBackupPlanAction) ActionManager.getInstance().getAction(EditBackupPlanAction.ID);
            if (action.run(database, (DefaultSchemaNode) backupPlanNode) == IDialogConstants.OK_ID) {
                refreshBackupPlan();
            }
        }
    } else {
        CommonUITool.openWarningBox(Messages.errJobAutoNoSelection);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) EditBackupPlanAction(com.cubrid.cubridmanager.ui.cubrid.jobauto.action.EditBackupPlanAction) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Aggregations

BackupPlanInfo (com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)5 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)3 ArrayList (java.util.ArrayList)3 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 QueryPlanInfo (com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)2 GetBackupPlanListTask (com.cubrid.cubridmanager.core.cubrid.jobauto.task.GetBackupPlanListTask)2 TableItem (org.eclipse.swt.widgets.TableItem)2 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 DbSpaceInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)1 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)1 GetQueryPlanListTask (com.cubrid.cubridmanager.core.cubrid.jobauto.task.GetQueryPlanListTask)1 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)1 DbUserInfoList (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)1 DeleteBackupPlanAction (com.cubrid.cubridmanager.ui.cubrid.jobauto.action.DeleteBackupPlanAction)1 EditBackupPlanAction (com.cubrid.cubridmanager.ui.cubrid.jobauto.action.EditBackupPlanAction)1