use of com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo in project cubrid-manager by CUBRID.
the class LoadDatabaseDialog method setTableModel.
/**
*
* Set tableViewer input model of some database
*
* @param dbName the database name
*/
private void setTableModel(String dbName) {
List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
if (dbUnloadInfoList != null && !dbUnloadInfoList.isEmpty()) {
DbUnloadInfo dbUnloadInfo = null;
for (int i = 0; i < dbUnloadInfoList.size(); i++) {
dbUnloadInfo = dbUnloadInfoList.get(i);
if (dbUnloadInfo.getDbName().equals(dbName)) {
break;
}
}
if (dbUnloadInfo != null) {
List<String> pathList = dbUnloadInfo.getSchemaPathList();
List<String> dateList = dbUnloadInfo.getSchemaDateList();
for (int i = 0; i < pathList.size() && i < dateList.size(); i++) {
String path = pathList.get(i);
String date = dateList.get(i);
if (path != null && path.trim().length() > 0) {
Map<String, String> map = new HashMap<String, String>();
path = FileUtil.changeSeparatorByOS(path, database.getServer().getServerInfo().getServerOsInfo());
map.put("0", "schema");
map.put("1", path);
map.put("2", date);
dataList.add(map);
}
}
pathList = dbUnloadInfo.getObjectPathList();
dateList = dbUnloadInfo.getObjectDateList();
for (int i = 0; i < pathList.size() && i < dateList.size(); i++) {
String path = pathList.get(i);
String date = dateList.get(i);
if (path != null && path.trim().length() > 0) {
Map<String, String> map = new HashMap<String, String>();
path = FileUtil.changeSeparatorByOS(path, database.getServer().getServerInfo().getServerOsInfo());
map.put("0", "object");
map.put("1", path);
map.put("2", date);
dataList.add(map);
}
}
pathList = dbUnloadInfo.getIndexPathList();
dateList = dbUnloadInfo.getIndexDateList();
for (int i = 0; i < pathList.size() && i < dateList.size(); i++) {
String path = pathList.get(i);
String date = dateList.get(i);
if (path != null && path.trim().length() > 0) {
Map<String, String> map = new HashMap<String, String>();
path = FileUtil.changeSeparatorByOS(path, database.getServer().getServerInfo().getServerOsInfo());
map.put("0", "index");
map.put("1", path);
map.put("2", date);
dataList.add(map);
}
}
pathList = dbUnloadInfo.getTriggerPathList();
dateList = dbUnloadInfo.getTriggerDateList();
for (int i = 0; i < pathList.size() && i < dateList.size(); i++) {
String path = pathList.get(i);
String date = dateList.get(i);
if (path != null && path.trim().length() > 0) {
Map<String, String> map = new HashMap<String, String>();
path = FileUtil.changeSeparatorByOS(path, database.getServer().getServerInfo().getServerOsInfo());
map.put("0", "trigger");
map.put("1", path);
map.put("2", date);
dataList.add(map);
}
}
}
}
if (!dataList.isEmpty()) {
tableViewer.setInput(dataList);
tableViewer.refresh();
for (int i = 0; i < unloadInfoTable.getColumnCount(); i++) {
unloadInfoTable.getColumn(i).pack();
}
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo in project cubrid-manager by CUBRID.
the class GetDbUnloadInfoTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
//case 1
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getunloaddbinfo_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
GetDbUnloadInfoTask task = new GetDbUnloadInfoTask(serverInfo);
task.setResponse(node);
List<DbUnloadInfo> list = task.getDbUnloadInfoList();
assertTrue(list.size() == 1);
assertEquals(list.get(0).getDbName(), "demodb");
assertTrue(list.get(0).getIndexDateList().size() == 2);
assertTrue(list.get(0).getIndexPathList().size() == 2);
assertTrue(list.get(0).getSchemaDateList().size() == 2);
assertTrue(list.get(0).getSchemaPathList().size() == 2);
assertTrue(list.get(0).getObjectDateList().size() == 2);
assertTrue(list.get(0).getObjectPathList().size() == 2);
assertTrue(list.get(0).getTriggerDateList().size() == 2);
assertTrue(list.get(0).getTriggerPathList().size() == 2);
//exception case
//exception case1
task.setResponse(null);
assertTrue(task.getDbUnloadInfoList() == null);
//exception case2
task.setResponse(node);
task.setErrorMsg("has error");
assertTrue(task.getDbUnloadInfoList() == null);
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getunloaddbinfo_receive2");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
GetDbUnloadInfoTask task2 = new GetDbUnloadInfoTask(serverInfo);
task2.setResponse(node);
task2.getDbUnloadInfoList();
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getunloaddbinfo_receive2");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
GetDbUnloadInfoTask task3 = new GetDbUnloadInfoTask(serverInfo);
task3.setResponse(node);
task3.getDbUnloadInfoList();
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo in project cubrid-manager by CUBRID.
the class GetDbUnloadInfoTaskTest method testUnloadInfo.
public void testUnloadInfo() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.unloadinfo.001.req.txt>");
GetDbUnloadInfoTask task = new GetDbUnloadInfoTask(serverInfo);
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
List<DbUnloadInfo> list = task.getDbUnloadInfoList();
DbUnloadInfo info = list.get(0);
assertEquals("demodb", info.getDbName());
assertEquals(0, info.getIndexDateList().size());
assertEquals(0, info.getIndexPathList().size());
assertEquals("2009.07.05 10:57", info.getObjectDateList().get(0));
assertEquals("/opt/frameworks/cubrid/databases/demodb/demodb_objects", info.getObjectPathList().get(0));
assertEquals("2009.07.05 10:57", info.getSchemaDateList().get(0));
assertEquals("/opt/frameworks/cubrid/databases/demodb/demodb_schema", info.getSchemaPathList().get(0));
assertEquals(0, info.getTriggerDateList().size());
assertEquals(0, info.getTriggerPathList().size());
info = list.get(1);
assertEquals("ndb", info.getDbName());
assertEquals("2009.07.19 13:58", info.getIndexDateList().get(0));
assertEquals("/opt/frameworks/cubrid/databases/ndb/ndb_indexes", info.getIndexPathList().get(0));
assertEquals("2009.07.19 13:58", info.getObjectDateList().get(0));
assertEquals("/opt/frameworks/cubrid/databases/ndb/ndb_objects", info.getObjectPathList().get(0));
assertEquals("2009.07.19 13:58", info.getSchemaDateList().get(0));
assertEquals("/opt/frameworks/cubrid/databases/ndb/ndb_schema", info.getSchemaPathList().get(0));
assertEquals(0, info.getTriggerDateList().size());
assertEquals(0, info.getTriggerPathList().size());
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo in project cubrid-manager by CUBRID.
the class GetDbUnloadInfoTask method getDbUnloadInfoList.
/**
*
* Get database unload information list
*
* @return List<DbUnloadInfo>
*/
public List<DbUnloadInfo> getDbUnloadInfoList() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
List<DbUnloadInfo> dbUnloadInfoList = new ArrayList<DbUnloadInfo>();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode treeNode = response.getChildren().get(i);
if (treeNode != null && treeNode.getValue("open") != null && treeNode.getValue("open").equals("database")) {
DbUnloadInfo dbUnloadInfo = new DbUnloadInfo();
String dbName = treeNode.getValue("dbname");
dbUnloadInfo.setDbName(dbName);
String[] schemaInfoArr = treeNode.getValues("schema");
addSchemaDate(dbUnloadInfo, schemaInfoArr);
String[] objectInfoArr = treeNode.getValues("object");
addObjectDate(dbUnloadInfo, objectInfoArr);
String[] indexInfoArr = treeNode.getValues("index");
addIndexDate(dbUnloadInfo, indexInfoArr);
String[] triggerInfoArr = treeNode.getValues("trigger");
addTriggerDate(dbUnloadInfo, triggerInfoArr);
dbUnloadInfoList.add(dbUnloadInfo);
}
}
return dbUnloadInfoList;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo in project cubrid-manager by CUBRID.
the class LoadDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
final CubridDatabase database = node.getDatabase();
final LoadDatabaseDialog dialog = new LoadDatabaseDialog(getShell());
dialog.setDatabase(database);
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.loadDbUnloadInfoTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (task instanceof GetDbUnloadInfoTask) {
GetDbUnloadInfoTask getDbUnloadInfoTask = (GetDbUnloadInfoTask) task;
List<DbUnloadInfo> dbUnloadInfoList = getDbUnloadInfoTask.getDbUnloadInfoList();
dialog.setDbUnloadInfoList(dbUnloadInfoList);
}
}
return true;
}
};
ServerInfo serverInfo = database.getServer().getServerInfo();
GetDbUnloadInfoTask task = new GetDbUnloadInfoTask(serverInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
dialog.open();
}
}
Aggregations