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);
}
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);
}
}
}
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);
}
}
}
}
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;
}
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);
}
}
Aggregations