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;
}
}
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));
}
}
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();
}
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;
}
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);
}
}
Aggregations