use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupHistoryInfo in project cubrid-manager by CUBRID.
the class BackupDatabaseDialog method getBackupHistoryInfoList.
/**
*
* Get backup history information list
*
* @return the backup history information list
*/
private List<Map<String, String>> getBackupHistoryInfoList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
if (dbBackupInfo != null) {
List<DbBackupHistoryInfo> dbBackupHistoryInfoList = dbBackupInfo.getBackupHistoryList();
if (dbBackupHistoryInfoList != null) {
int size = dbBackupHistoryInfoList.size();
for (int i = 0; i < size; i++) {
DbBackupHistoryInfo historyInfo = dbBackupHistoryInfoList.get(i);
Map<String, String> map = new HashMap<String, String>();
map.put("0", historyInfo.getLevel());
String dateStr = historyInfo.getDate();
if (dateStr != null && dateStr.trim().length() > 0) {
String[] dateStrArr = dateStr.split("\\.");
if (dateStrArr.length == 5) {
dateStr = dateStrArr[0] + "." + dateStrArr[1] + "." + dateStrArr[2] + " " + dateStrArr[3] + ":" + dateStrArr[4];
}
map.put("1", dateStr);
}
String sizeStr = historyInfo.getSize();
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
if (sizeStr != null && sizeStr.matches("^\\d+$")) {
map.put("2", nf.format(Integer.parseInt(sizeStr) / (1024 * 1024)));
}
String path = FileUtil.changeSeparatorByOS(historyInfo.getPath(), database.getServer().getServerInfo().getServerOsInfo());
map.put("3", path);
list.add(map);
}
}
}
return list;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupHistoryInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTask method getDbBackupInfo.
/**
*
* Get database backup information
*
* @return DbBackupInfo the instance of DbBackupInfo
*/
public DbBackupInfo getDbBackupInfo() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
DbBackupInfo dbBackupInfo = new DbBackupInfo();
String dbDir = response.getValue("dbdir");
dbBackupInfo.setDbDir(dbDir);
String freeSpace = response.getValue("freespace");
dbBackupInfo.setFreeSpace(freeSpace);
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node == null) {
continue;
}
String levelName = node.getValue("open");
if (levelName == null || levelName.trim().length() <= 0) {
continue;
}
if (levelName.indexOf("level") >= 0) {
String path = node.getValue("path");
String size = node.getValue("size");
String date = node.getValue("data");
DbBackupHistoryInfo dbBackupHistoryInfo = new DbBackupHistoryInfo(levelName, path, size, date);
dbBackupInfo.addDbBackupHistoryInfo(dbBackupHistoryInfo);
}
}
return dbBackupInfo;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupHistoryInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTaskTest method testBackupExist.
public void testBackupExist() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.backupdbinfo.001.req.txt>");
GetDbBackupInfoTask task = new GetDbBackupInfoTask(serverInfo);
task.setDbName("demodb");
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
DbBackupInfo info = task.getDbBackupInfo();
assertNotNull(info);
assertEquals("/opt/frameworks/cubrid2/databases/demodb/backup", info.getDbDir());
assertEquals("15216", info.getFreeSpace());
List<DbBackupHistoryInfo> list = info.getBackupHistoryList();
assertNotNull(list);
assertEquals(1, list.size());
DbBackupHistoryInfo his = list.get(0);
assertEquals("level0", his.getLevel());
assertEquals("/opt/frameworks/cubrid2/databases/demodb/backup/demodb_backup_lv0", his.getPath());
assertEquals("5256192", his.getSize());
assertEquals("2009.06.26.22.37", his.getDate());
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupHistoryInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTaskTest method testNoBackup.
public void testNoBackup() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.backupdbinfo.002.req.txt>");
GetDbBackupInfoTask task = new GetDbBackupInfoTask(serverInfo);
task.setDbName("nobackupdb");
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
DbBackupInfo info = task.getDbBackupInfo();
assertNotNull(info);
assertEquals("/opt/frameworks/cubrid2/databases/nobackupdb/backup", info.getDbDir());
assertEquals("15216", info.getFreeSpace());
List<DbBackupHistoryInfo> list = info.getBackupHistoryList();
assertNotNull(list);
assertEquals(0, list.size());
}
Aggregations