Search in sources :

Example 11 with XMLMemento

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);
    }
}
Also used : Entry(java.util.Map.Entry) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) HashMap(java.util.HashMap) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 12 with XMLMemento

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);
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with XMLMemento

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);
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with XMLMemento

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);
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) RGB(org.eclipse.swt.graphics.RGB) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 15 with XMLMemento

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);
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)19 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)19 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 HashMap (java.util.HashMap)3 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)3 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)3 RGB (org.eclipse.swt.graphics.RGB)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 Map (java.util.Map)2 PstmtParameter (com.cubrid.common.ui.cubrid.table.dialog.PstmtParameter)1 ExportConfig (com.cubrid.common.ui.cubrid.table.progress.ExportConfig)1 SQLHistoryDetail (com.cubrid.common.ui.query.control.SQLHistoryDetail)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1