use of com.cubrid.cubridmanager.core.cubrid.database.task.RestoreDbTask in project cubrid-manager by CUBRID.
the class RestoreDatabaseDialog method restoreDb.
/**
*
* Restore database
*
*
*/
private void restoreDb() {
if (!valid()) {
return;
}
TaskJobExecutor taskExec = new CommonTaskJobExec(this);
String databaseName = databaseNameText.getText();
ServerInfo serverInfo = database.getServer().getServerInfo();
boolean isLocalServer = serverInfo.isLocalServer();
RestoreDbTask restoreDbTask = new RestoreDbTask(database.getServer().getServerInfo());
restoreDbTask.setDbName(databaseName);
String level = "0";
String path = "none";
if (selectBackupButton.getSelection()) {
if (level0Button.getSelection()) {
level = "0";
path = level0Text.getText();
} else if (level1Button.getSelection()) {
level = "1";
path = level1Text.getText();
} else if (level2Button.getSelection()) {
level = "2";
path = level2Text.getText();
}
if (!isLocalServer) {
CheckFileTask checkFileTask = new CheckFileTask(serverInfo);
checkFileTask.setFile(new String[] { path });
checkFileTask.putData("filePath", path);
taskExec.addTask(checkFileTask);
}
}
if (selectTimeButton.getSelection()) {
if (backupTimeButton.getSelection()) {
restoreDbTask.setDate("backuptime");
} else if (restoredDataTimeButton.getSelection()) {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
String timeStr = nf.format(hourSpn.getSelection()) + ":" + nf.format(minuteSpn.getSelection()) + ":" + nf.format(secondSpn.getSelection());
String dateStr = nf.format(daySpn.getSelection()) + "-" + nf.format(monthSpn.getSelection()) + "-" + yearSpn.getSelection();
dateStr += ":" + timeStr;
restoreDbTask.setDate(dateStr);
}
} else {
restoreDbTask.setDate("none");
}
if (!CompatibleUtil.isSupportRestorePath(database.getServer().getServerInfo())) {
path = "none";
}
restoreDbTask.setLevel(level);
restoreDbTask.setPathName(path);
if (partialButton.getSelection()) {
restoreDbTask.setPartial(true);
} else {
restoreDbTask.setPartial(false);
}
if (dbPathButton == null || !dbPathButton.getSelection()) {
restoreDbTask.setRecoveryPath("none");
} else {
restoreDbTask.setRecoveryPath(dbPathText.getText());
if (!isLocalServer) {
CheckDirTask checkDirTask = new CheckDirTask(serverInfo);
checkDirTask.setDirectory(new String[] { dbPathText.getText() });
taskExec.addTask(checkDirTask);
}
}
taskExec.addTask(restoreDbTask);
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
String jobName = Messages.msgRestoreDBRearJobName + " - " + dbName + "@" + serverName;
taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
}
Aggregations