Search in sources :

Example 31 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento 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 32 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class NodeFilterManager method loadFilterSetting.

@SuppressWarnings("deprecation")
private void loadFilterSetting() {
    synchronized (this) {
        IEclipsePreferences preference = new InstanceScope().getNode(CommonUIPlugin.PLUGIN_ID);
        String xmlString = preference.get(FILTER_XML_CONTENT, "");
        if (StringUtil.isEmpty(xmlString)) {
            LOGGER.warn("The preference.get(FILTER_XML_CONTENT) has a empty string.");
            return;
        }
        try {
            ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
            IXMLMemento memento = XMLMemento.loadMemento(in);
            if (memento == null) {
                LOGGER.error("XMLMemento.loadMemento(in) is a null.");
                return;
            }
            IXMLMemento[] children = memento.getChildren("idFilter");
            for (int i = 0; i < children.length; i++) {
                String id = children[i].getString("id");
                idFilterList.add(id);
            }
            children = memento.getChildren("idGrayFilter");
            for (int i = 0; i < children.length; i++) {
                String id = children[i].getString("id");
                idGrayFilterList.add(id);
            }
            children = memento.getChildren("nameFilter");
            for (int i = 0; i < children.length; i++) {
                String pattern = children[i].getString("pattern");
                nameFilterList.add(pattern);
            }
        } catch (UnsupportedEncodingException e) {
            LOGGER.error("loadFilterSetting()", e);
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ByteArrayInputStream(java.io.ByteArrayInputStream) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 33 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class RecentlyUsedSQLDetailPersistUtils method load.

public static void load(CubridDatabase cubridDatabase) {
    String id = getId(cubridDatabase);
    synchronized (LOCK) {
        if (logs.containsKey(id)) {
            return;
        }
        LinkedList<SQLHistoryDetail> sqlHistories = logs.get(id);
        if (sqlHistories == null) {
            sqlHistories = new LinkedList<SQLHistoryDetail>();
            logs.put(id, sqlHistories);
            IXMLMemento memento = PersistUtils.getXMLMemento(RecentlyUsedSQLComposite.ID, id);
            if (memento == null) {
                return;
            }
            try {
                List<SQLHistoryDetail> list = loadFromXML(memento);
                sqlHistories.addAll(list);
            } catch (Exception e) {
                LOGGER.error("parse recently used SQL error", e);
            }
        }
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) SQLHistoryDetail(com.cubrid.common.ui.query.control.SQLHistoryDetail)

Example 34 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class RecentlyUsedSQLDetailPersistUtils method loadFromXML.

/**
	 * read SQLHistoryDetail List 
	 *
	 * @param memento IXMLMemento
	 * @return
	 */
private static List<SQLHistoryDetail> loadFromXML(IXMLMemento memento) throws Exception {
    List<SQLHistoryDetail> recentlyUsedSQLContentsList = new LinkedList<SQLHistoryDetail>();
    try {
        int index = 1;
        for (IXMLMemento xmlDetail : memento.getChildren("SQLHistoryDetail")) {
            SQLHistoryDetail historyDetail = new SQLHistoryDetail();
            historyDetail.setSql(xmlDetail.getString("SQL"));
            historyDetail.setElapseTime(xmlDetail.getString("elapseTime"));
            historyDetail.setExecuteTime(xmlDetail.getString("executeTime"));
            historyDetail.setExecuteInfo(xmlDetail.getString("LOG"));
            historyDetail.setIndex(index++);
            recentlyUsedSQLContentsList.add(historyDetail);
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return recentlyUsedSQLContentsList;
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) SQLHistoryDetail(com.cubrid.common.ui.query.control.SQLHistoryDetail) LinkedList(java.util.LinkedList)

Example 35 with IXMLMemento

use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.

the class DBParameter method loadDatabases.

/**
	 *
	 * Load added databases from xml memento
	 *
	 * @param memento IXMLMemento
	 */
protected void loadDatabases(IXMLMemento memento) {
    IXMLMemento[] children = memento == null ? null : memento.getChildren("database");
    for (int i = 0; children != null && i < children.length; i++) {
        String address = children[i].getString("address");
        String port = children[i].getString("port");
        String dbName = children[i].getString("dbName");
        String dbUser = children[i].getString("dbUser");
        String encryptPassword = children[i].getString("dbPassword");
        String dbPassword = "";
        if (!StringUtil.isEmpty(encryptPassword)) {
            dbPassword = CipherUtils.decrypt(encryptPassword);
        }
        String jdbcAttrs = children[i].getString("jdbcAttrs");
        if (jdbcAttrs == null)
            jdbcAttrs = "";
        boolean savePassword = children[i].getBoolean("savePassword");
        String key = getMapKey(dbUser, dbName, address, port);
        DBParameter dbParameter = databaseMap.get(key);
        if (dbParameter == null) {
            dbParameter = new DBParameter(dbName, address, port, dbUser, dbPassword, jdbcAttrs, savePassword);
            databaseMap.put(key, dbParameter);
        }
        DatabaseEditorConfig editorConfig = null;
        IXMLMemento editorConfigElement = children[i].getChild("editorConfig");
        if (editorConfigElement != null) {
            editorConfig = new DatabaseEditorConfig();
            String strBGPos = editorConfigElement.getString("purpose-code");
            if (strBGPos == null) {
                strBGPos = "0";
            }
            int bgPos = StringUtil.intValue(strBGPos, 0);
            RGB background = EditorConstance.getRGBByPos(bgPos);
            editorConfig.setBackGround(background);
            editorConfig.setDatabaseComment(editorConfigElement.getString("database-comment"));
        }
        QueryOptions.putEditorConfig(dbUser, dbName, address, port, null, editorConfig, true);
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) RGB(org.eclipse.swt.graphics.RGB) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Aggregations

IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)54 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)18 ByteArrayInputStream (java.io.ByteArrayInputStream)10 IOException (java.io.IOException)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)8 ArrayList (java.util.ArrayList)7 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)6 HashMap (java.util.HashMap)6 RGB (org.eclipse.swt.graphics.RGB)6 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)5 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)5 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)5 PreferenceStore (org.eclipse.jface.preference.PreferenceStore)5 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)4 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)4 SQLHistoryDetail (com.cubrid.common.ui.query.control.SQLHistoryDetail)3 QueryRecord (com.cubrid.common.ui.query.tuner.QueryRecord)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)3