use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CQBDbUsersFolderLoader 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();
if (database.getRunningType() == DbRunningType.STANDALONE) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
DbUserInfoList dbUserInfoList = new DbUserInfoList();
GetUserListTask task = new GetUserListTask(database.getDatabaseInfo());
parent.removeAllChild();
try {
dbUserInfoList = task.getResultModel();
} catch (Exception e) {
LOGGER.error("load user failed", e);
}
DbUserInfo latestDLoginedbUserInfo = databaseInfo.getAuthLoginedDbUserInfo();
List<DbUserInfo> dbUserList = dbUserInfoList == null ? null : dbUserInfoList.getUserList();
formatUserList(dbUserList);
for (int i = 0; dbUserList != null && dbUserList.size() > i; i++) {
DbUserInfo dbUserInfo = dbUserList.get(i);
if (dbUserInfo.getName().equals(latestDLoginedbUserInfo.getName())) {
dbUserInfo.setDbaAuthority(latestDLoginedbUserInfo.isDbaAuthority());
// databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
}
String id = parent.getId() + NODE_SEPARATOR + dbUserInfo.getName();
ICubridNode dbUserInfoNode = new DefaultSchemaNode(id, dbUserInfo.getName(), "icons/navigator/user_item.png");
dbUserInfoNode.setType(NodeType.USER);
dbUserInfoNode.setModelObj(dbUserInfo);
dbUserInfoNode.setContainer(false);
dbUserInfoNode.setEditorId(CQBUserEditor.ID);
parent.addChild(dbUserInfoNode);
}
databaseInfo.setDbUserInfoList(dbUserInfoList);
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 ChangeShardAction method isSupported.
/**
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @param obj the Object
* @return <code>true</code> if support this obj;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof ICubridNode)) {
return false;
}
ICubridNode cubridNode = (ICubridNode) obj;
String nodeType = cubridNode.getType();
if (!NodeType.DATABASE.equals(nodeType)) {
return false;
}
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
DatabaseInfo dbInfo = schemaNode.getDatabase().getDatabaseInfo();
if (!schemaNode.getDatabase().isLogined()) {
return false;
}
if (!dbInfo.isShard()) {
return false;
}
return true;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CQBDBNodePersistManager method saveDatabases.
/**
*
* Save added database to plug-in preference
*
*/
public void saveDatabases() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("databases");
Iterator<CubridDatabase> iterator = databaseList.iterator();
while (iterator.hasNext()) {
CubridDatabase database = (CubridDatabase) iterator.next();
DatabaseInfo dbInfo = database.getDatabaseInfo();
ServerInfo serverInfo = dbInfo.getServerInfo();
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
IXMLMemento child = memento.createChild("database");
child.putString("name", database.getLabel());
child.putString("dbName", dbInfo.getDbName());
child.putString("dbUser", dbUserInfo.getName());
if (database.isAutoSavePassword()) {
child.putString("dbPassword", CipherUtils.encrypt(dbUserInfo.getNoEncryptPassword()));
} else {
child.putString("dbPassword", "");
}
child.putString("savePassword", String.valueOf(database.isAutoSavePassword()));
// [TOOLS-2425]Support shard broker
child.putString("isShard", String.valueOf(dbInfo.isShard()));
child.putString("shardQueryType", String.valueOf(dbInfo.getShardQueryType()));
child.putString("jdbcDriver", serverInfo.getJdbcDriverVersion());
child.putString("brokerIp", dbInfo.getBrokerIP());
child.putString("brokerPort", dbInfo.getBrokerPort());
child.putString("charset", dbInfo.getCharSet());
child.putString("jdbcAttrs", dbInfo.getJdbcAttrs());
/*Save the database editor config*/
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
if (editorConfig != null) {
IXMLMemento editorConfigChild = child.createChild("editorConfig");
editorConfigChild.putString("database-comment", editorConfig.getDatabaseComment() == null ? "" : editorConfig.getDatabaseComment());
if (editorConfig.getBackGround() != null) {
RGB background = editorConfig.getBackGround();
int bgPos = EditorConstance.getBGPos(background);
editorConfigChild.putInteger("purpose-code", bgPos);
}
}
}
PersistUtils.saveXMLMemento(ApplicationUtil.CQB_UI_PLUGIN_ID, DATABASE_XML_CONTENT, memento);
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CQBDBNodePersistManager method isContainedByHostAddress.
/**
*
* Return whether this server has been existed and exclude this server
*
* @param address the ip address
* @param port the port
* @param server the CubridServer object
* @return <code>true</code> if contain this server;<code>false</code>
* otherwise
*/
public boolean isContainedByHostAddress(String address, String port, CubridDatabase server) {
// FIXME extract
for (int i = 0; i < databaseList.size(); i++) {
CubridDatabase serv = databaseList.get(i);
if (server != null && server.getId().equals(serv.getId())) {
continue;
}
DatabaseInfo serverInfo = serv.getDatabaseInfo();
if (serverInfo.getBrokerIP().equals(address) && serverInfo.getBrokerPort().equals(port)) {
return true;
}
}
return false;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CQBDBNodePersistManager method getConnectionInfo.
/**
* Retrives a connection information instance.
*
* @param database CubridDatabase
* @return ConnectionInfo
*/
public ConnectionInfo getConnectionInfo(CubridDatabase database) {
// FIXME extract
DatabaseInfo dbInfo = database.getDatabaseInfo();
String user = "";
String password = "";
if (dbInfo.getAuthLoginedDbUserInfo() != null) {
user = dbInfo.getAuthLoginedDbUserInfo().getName();
password = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
}
String version = dbInfo.getServerInfo() == null ? "" : dbInfo.getServerInfo().getJdbcDriverVersion();
String driverFileName = CubridJdbcManager.getInstance().getDriverFileByVersion(version);
ConnectionInfo ci = new ConnectionInfo(database.getName(), dbInfo.getBrokerIP(), StringUtil.intValue(dbInfo.getBrokerPort(), -1), dbInfo.getDbName(), user, password, driverFileName, dbInfo.getCharSet());
return ci;
}
Aggregations