use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class CubridJdbcManager method resetCubridJdbcSetting.
/**
* Add or delete CUBRID JDBC driver
*
* @param map the CUBRID JDBC driver
*/
public void resetCubridJdbcSetting(Map<String, String> map) {
synchronized (CubridJdbcManager.class) {
XMLMemento memento = XMLMemento.createWriteRoot("cubridJdbcSetting");
Iterator<Entry<String, String>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
IXMLMemento child = memento.createChild("cubridJdbcSetting");
Entry<String, String> next = iterator.next();
child.putString("jdbcURL", next.getValue());
}
// register the jdbc to the jdbc factory
Map<String, String> loaderMap = getSortedMap();
loaderMap.putAll(defaultVersion2FileMap);
loaderMap.putAll(externalVersion2FileMap);
Map<String, String> noLoadedMap = new HashMap<String, String>();
iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, String> next = iterator.next();
String key = next.getKey();
String value = next.getValue();
//delete the loader that already loaded
if (loaderMap.containsKey(key) && StringUtil.isEqual(loaderMap.get(key), value)) {
loaderMap.remove(key);
} else {
noLoadedMap.put(key, value);
}
}
for (String version : loaderMap.keySet()) {
if (externalVersion2FileMap.containsKey(version)) {
String driverFile = externalVersion2FileMap.get(version);
externalVersion2FileMap.remove(version);
JdbcClassLoaderFactory.removeClassLoader(version);
fireRemoveJdbcDriver(driverFile);
}
}
for (Entry<String, String> entry : noLoadedMap.entrySet()) {
externalVersion2FileMap.put(entry.getKey(), entry.getValue());
JdbcClassLoaderFactory.registerClassLoader(entry.getValue());
fireAddJdbcDriver(entry.getValue());
}
PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, CUBRID_JDBC_SETTING, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class FavoriteQueryPersistUtil method saveBatchRunList.
public void saveBatchRunList() {
XMLMemento memento = XMLMemento.createWriteRoot("BatchRunList");
for (Iterator<Map<String, String>> it = listData.iterator(); it.hasNext(); ) {
IXMLMemento batchRunXMLMemento = memento.createChild("BatchRun");
Map<String, String> data = it.next();
batchRunXMLMemento.putString("filename", StringUtil.nvl(data.get("1")));
batchRunXMLMemento.putString("memo", StringUtil.nvl(data.get("2")));
batchRunXMLMemento.putString("regdate", StringUtil.nvl(data.get("3")));
batchRunXMLMemento.putString("directory", StringUtil.nvl(data.get("4")));
batchRunXMLMemento.putString("charset", StringUtil.nvl(data.get("5")));
batchRunXMLMemento.putString("managed", StringUtil.nvl(data.get("6")));
}
PersistUtils.saveXMLMemento(BatchRunComposite.ID, LIST_ID, memento);
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class BatchRunComposite method saveBatchRunList.
public void saveBatchRunList() {
XMLMemento memento = XMLMemento.createWriteRoot("BatchRunList");
for (Iterator<Map<String, String>> it = listData.iterator(); it.hasNext(); ) {
IXMLMemento batchRunXMLMemento = memento.createChild("BatchRun");
Map<String, String> data = it.next();
batchRunXMLMemento.putString("filename", data.get("1"));
batchRunXMLMemento.putString("memo", data.get("2"));
batchRunXMLMemento.putString("regdate", data.get("3"));
batchRunXMLMemento.putString("directory", data.get("4"));
}
PersistUtils.saveXMLMemento(BatchRunComposite.ID, LIST_ID, memento);
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class DBParameter method saveDatabases.
/**
*
* Save added database to plug-in preference
*
*/
public void saveDatabases() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("databases");
for (DBParameter dbParameter : databaseMap.values()) {
String dbName = StringUtils.defaultString(dbParameter.getDbName());
String address = StringUtils.defaultString(dbParameter.getHostAddress());
String port = StringUtils.defaultString(dbParameter.getMonPort());
String dbUser = StringUtils.defaultString(dbParameter.getDBUser());
String password = StringUtils.defaultString(dbParameter.getPassword());
String jdbcAttrs = StringUtils.defaultString(dbParameter.getJdbcAttrs());
boolean savePassword = dbParameter.isSavePassword();
IXMLMemento child = memento.createChild("database");
child.putString("dbUser", dbUser);
child.putString("dbName", dbName);
child.putString("address", address);
child.putString("port", port);
child.putString("dbPassword", CipherUtils.encrypt(password));
child.putString("savePassword", String.valueOf(savePassword));
child.putString("jdbcAttrs", jdbcAttrs);
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(dbUser, dbName, address, port, null, true);
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.CM_UI_PLUGIN_ID, DATABASE_XML_CONTENT, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.XMLMemento in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method saveServers.
/**
*
* Save added server to plug-in preference
*
*/
public void saveServers() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("hosts");
memento.putBoolean("alreadyAddedLocalhostDefault", true);
Iterator<CubridServer> iterator = serverList.iterator();
while (iterator.hasNext()) {
CubridServer server = (CubridServer) iterator.next();
IXMLMemento child = memento.createChild("host");
child.putString("id", server.getId());
child.putString("name", server.getLabel());
child.putString("port", String.valueOf(server.getMonPort()));
child.putString("address", server.getHostAddress());
child.putString("user", server.getUserName());
String pwd = server.isAutoSavePassword() ? CipherUtils.encrypt(server.getPassword()) : "";
child.putString("password", pwd);
child.putBoolean("savePassword", server.isAutoSavePassword());
child.putString("jdbcDriver", server.getJdbcDriverVersion());
if (server.getServerInfo() != null) {
child.putInteger("soTimeOut", server.getServerInfo().getSoTimeOut());
child.putString("isCheckCert", String.valueOf(server.getServerInfo().isCheckCertStatus()));
}
}
PersistUtils.saveXMLMemento(ApplicationUtil.CM_UI_PLUGIN_ID, SERVER_XML_CONTENT, memento);
}
}
Aggregations