use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CubridDatabasesFolderLoader 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;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
final GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
monitorCancel(monitor, new ITask[] { getUserInfoTask, getDatabaseListTask });
getUserInfoTask.execute();
final String msg1 = getUserInfoTask.getErrorMsg();
if (!monitor.isCanceled() && msg1 != null && msg1.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(msg1);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
List<DatabaseInfo> oldDatabaseInfoList = null;
if (serverInfo.getLoginedUserInfo() != null) {
oldDatabaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
}
for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
ServerUserInfo userInfo = serverUserInfoList.get(i);
if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
serverInfo.setLoginedUserInfo(userInfo);
break;
}
}
getDatabaseListTask.execute();
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
final String msg2 = getDatabaseListTask.getErrorMsg();
if (!monitor.isCanceled() && msg2 != null && msg2.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(msg2);
setLoaded(true);
return;
}
List<DatabaseInfo> newDatabaseInfoList = getDatabaseListTask.loadDatabaseInfo();
List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
oldNodeList.addAll(parent.getChildren());
parent.removeAllChild();
//Construct the database folder children
buildDatabasesFolder(parent, monitor, serverInfo, oldDatabaseInfoList, newDatabaseInfoList, oldNodeList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CubridDatabasesFolderLoader method filterDatabaseList.
/**
*
* Add or delete database for author database list
*
* @param serverInfo the server information
* @param databaseInfoList the database information list
* @param authorDatabaseList the authorize database list
* @return whether this authorDatabaseList is updated
*/
public static boolean filterDatabaseList(ServerInfo serverInfo, List<DatabaseInfo> databaseInfoList, List<DatabaseInfo> authorDatabaseList) {
if (databaseInfoList == null || authorDatabaseList == null) {
return false;
}
boolean isUpdated = false;
//Check the authorization database whether already deleted
List<DatabaseInfo> deletedDbList = new ArrayList<DatabaseInfo>();
for (int i = 0; i < authorDatabaseList.size(); i++) {
DatabaseInfo databaseInfo = authorDatabaseList.get(i);
if (databaseInfo == null) {
continue;
}
DatabaseInfo dbInfo = getDatabaseInfo(databaseInfoList, databaseInfo.getDbName());
if (dbInfo == null) {
deletedDbList.add(databaseInfo);
isUpdated = true;
} else {
databaseInfo.setDbDir(dbInfo.getDbDir());
databaseInfo.setRunningType(dbInfo.getRunningType());
}
}
List<DatabaseInfo> addedDbList = new ArrayList<DatabaseInfo>();
boolean isAdminLogin = serverInfo.getLoginedUserInfo().isAdmin();
//if user is admin,add all database to authorization database list
if (isAdminLogin) {
for (int i = 0; i < databaseInfoList.size(); i++) {
DatabaseInfo databaseInfo = databaseInfoList.get(i);
if (databaseInfo != null && getDatabaseInfo(authorDatabaseList, databaseInfo.getDbName()) == null) {
addedDbList.add(databaseInfo);
isUpdated = true;
}
}
}
authorDatabaseList.removeAll(deletedDbList);
authorDatabaseList.addAll(addedDbList);
// update the admin user the latest access broker port and IP
if (isAdminLogin) {
String defaultBrokerPort = getDefaultPort(serverInfo);
for (int i = 0; i < authorDatabaseList.size(); i++) {
DatabaseInfo databaseInfo = authorDatabaseList.get(i);
String serverBrokerPort = databaseInfo.getBrokerPort();
if (serverBrokerPort == null || serverBrokerPort.trim().length() == 0 || !isExistPort(serverInfo, serverBrokerPort)) {
serverBrokerPort = defaultBrokerPort;
isUpdated = true;
}
databaseInfo.setBrokerPort(serverBrokerPort);
String localBrokerPort = QueryOptions.getBrokerPort(databaseInfo);
if (localBrokerPort != null && localBrokerPort.trim().length() > 0 && !serverBrokerPort.equals(localBrokerPort) && isExistPort(serverInfo, localBrokerPort)) {
databaseInfo.setBrokerPort(localBrokerPort);
isUpdated = true;
}
String serverBrokerIp = databaseInfo.getBrokerIP();
String localBrokerIp = QueryOptions.getBrokerIp(databaseInfo);
if (!localBrokerIp.equals(serverBrokerIp)) {
databaseInfo.setBrokerIP(localBrokerIp);
isUpdated = true;
}
if (databaseInfo.getAuthLoginedDbUserInfo() == null) {
DbUserInfo userInfo = new DbUserInfo(databaseInfo.getDbName(), "dba", "", "", true);
databaseInfo.setAuthLoginedDbUserInfo(userInfo);
isUpdated = true;
}
}
}
//Set charset and database ip from local preference file
for (DatabaseInfo databaseInfo : authorDatabaseList) {
databaseInfo.setCharSet(QueryOptions.getCharset(databaseInfo));
DbUserInfo dbUserInfo = databaseInfo.getAuthLoginedDbUserInfo();
if (dbUserInfo != null) {
String password = CMDBNodePersistManager.getInstance().getDbPassword(serverInfo.getHostAddress(), String.valueOf(serverInfo.getHostMonPort()), databaseInfo.getDbName(), dbUserInfo.getName());
dbUserInfo.setNoEncryptPassword(password);
}
}
return isUpdated;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CubridDbSpaceFolderLoader 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();
HashMap<String, FolderInformationContainer> foldersInformation;
HashMap<String, ICubridNode> foldersHashMap = new HashMap<String, ICubridNode>();
DatabaseInfo databaseInfo = database.getDatabaseInfo();
CommonQueryTask<? extends DbSpaceInfoList> task;
DbSpaceInfoList dbSpaceInfoList;
if (DbSpaceInfoList.useOld(database.getDatabaseInfo().getServerInfo().getEnvInfo())) {
foldersInformation = foldersInformationOldFormat;
task = new CommonQueryTask<DbSpaceInfoListOld>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld());
} else {
foldersInformation = foldersInformationNewFormat;
task = new CommonQueryTask<DbSpaceInfoListNew>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
}
for (Map.Entry<String, FolderInformationContainer> entry : foldersInformation.entrySet()) {
String key = entry.getKey();
FolderInformationContainer value = entry.getValue();
ICubridNode folder = addFolder(parent, key, value.volumeFolderName, value.volumeFolder, value.type);
foldersHashMap.put(value.volumeType, folder);
}
ICubridNode logFolder = addFolder(parent, LOG_VOLUME_FOLDER_ID, LOG_VOLUME_FOLDER_NAME, CubridNodeType.LOG_VOLUEM_FOLDER, null);
foldersHashMap.put(VolumeType.ACTIVE_LOG.getText(), addFolder(logFolder, ACTIVE_LOG_FOLDER_ID, ACTIVE_LOG_FOLDER_NAME, CubridNodeType.ACTIVE_LOG_FOLDER, CubridNodeType.ACTIVE_LOG));
foldersHashMap.put(VolumeType.ARCHIVE_LOG.getText(), addFolder(logFolder, ARCHIVE_LOG_FOLDER_ID, ARCHIVE_LOG_FOLDER_NAME, CubridNodeType.ARCHIVE_LOG_FOLDER, CubridNodeType.ARCHIVE_LOG));
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) {
for (ICubridNode folder : foldersHashMap.values()) {
folder.removeAllChild();
}
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(null, errorMsg);
}
});
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
for (ICubridNode folder : foldersHashMap.values()) {
folder.removeAllChild();
}
dbSpaceInfoList = task.getResultModel();
List<DbSpaceInfo> spaceInfoList = dbSpaceInfoList == null ? null : dbSpaceInfoList.getSpaceinfo();
for (int i = 0; spaceInfoList != null && i < spaceInfoList.size(); i++) {
DbSpaceInfo spaceInfo = spaceInfoList.get(i);
ICubridNode volumeNode = new DefaultSchemaNode("", spaceInfo.getShortVolumeName(), "");
volumeNode.setContainer(false);
volumeNode.setModelObj(spaceInfo);
volumeNode.setEditorId(VolumeInformationEditor.ID);
String key = null;
String type = spaceInfo.getType();
if (spaceInfo.getPurpose() != null) {
key = type + "_" + spaceInfo.getPurpose();
} else {
key = type;
}
if (type == null) {
continue;
}
ICubridNode folder = foldersHashMap.get(key);
if (folder != null) {
String id = folder.getId() + NODE_SEPARATOR + spaceInfo.getShortVolumeName();
volumeNode.setId(id);
volumeNode.setType(folder.getType());
volumeNode.setIconPath("icons/navigator/volume_item.png");
folder.addChild(volumeNode);
}
}
if (spaceInfoList != null && !spaceInfoList.isEmpty()) {
for (ICubridNode folder : foldersHashMap.values()) {
Collections.sort(folder.getChildren());
}
}
databaseInfo.setDbSpaceInfoList(dbSpaceInfoList);
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo 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.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CubridDatabaseLogFolderLoader 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;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
List<DatabaseInfo> databaseInfoList = userInfo.getDatabaseInfoList();
if (databaseInfoList == null || databaseInfoList.size() <= 0) {
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
oldNodeList.addAll(parent.getChildren());
parent.removeAllChild();
for (int i = 0; i < databaseInfoList.size() && !monitor.isCanceled(); i++) {
DatabaseInfo databaseInfo = databaseInfoList.get(i);
String id = parent.getId() + NODE_SEPARATOR + databaseInfo.getDbName();
ICubridNode logDatabaseNode = isContained(oldNodeList, id);
if (logDatabaseNode == null) {
logDatabaseNode = new DefaultCubridNode(id, databaseInfo.getDbName(), "icons/navigator/folder.png");
logDatabaseNode.setType(CubridNodeType.LOGS_SERVER_DATABASE_FOLDER);
logDatabaseNode.setModelObj(databaseInfo);
logDatabaseNode.setContainer(true);
ICubridNodeLoader loader = new CubridDatabaseLogLoader();
loader.setLevel(getLevel());
logDatabaseNode.setLoader(loader);
parent.addChild(logDatabaseNode);
if (getLevel() == DEFINITE_LEVEL) {
logDatabaseNode.getChildren(monitor);
}
} else {
parent.addChild(logDatabaseNode);
if (logDatabaseNode.getLoader() != null && logDatabaseNode.getLoader().isLoaded()) {
logDatabaseNode.getLoader().setLoaded(false);
logDatabaseNode.getChildren(monitor);
}
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations