Search in sources :

Example 1 with IXMLMemento

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

the class NodeFilterManager method saveFilterSetting.

/**
	 * Save filter setting to plug-in preference
	 */
@SuppressWarnings("deprecation")
public void saveFilterSetting() {
    synchronized (this) {
        try {
            XMLMemento memento = XMLMemento.createWriteRoot("filters");
            if (memento == null) {
                LOGGER.error("XMLMemento.createWriteRoot('filters') is a null.");
                return;
            }
            Iterator<String> iterator = idFilterList.iterator();
            while (iterator.hasNext()) {
                String pattern = (String) iterator.next();
                IXMLMemento child = memento.createChild("idFilter");
                child.putString("id", pattern);
            }
            iterator = idGrayFilterList.iterator();
            while (iterator.hasNext()) {
                String pattern = (String) iterator.next();
                IXMLMemento child = memento.createChild("idGrayFilter");
                child.putString("id", pattern);
            }
            iterator = nameFilterList.iterator();
            while (iterator.hasNext()) {
                String pattern = (String) iterator.next();
                IXMLMemento child = memento.createChild("nameFilter");
                child.putString("pattern", pattern);
            }
            String xmlString = memento.saveToString();
            IEclipsePreferences preference = new InstanceScope().getNode(CommonUIPlugin.PLUGIN_ID);
            preference.put(FILTER_XML_CONTENT, xmlString);
            preference.flush();
        } catch (Exception e) {
            LOGGER.error("saveFilterSetting", e);
        }
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with IXMLMemento

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

the class ImportConfigManager method saveConfigs.

/**
	 *
	 * Save the import configs to plug-in preference
	 *
	 */
public void saveConfigs() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("databases");
        Iterator<ImportConfig> iterator = importConfigList.iterator();
        while (iterator.hasNext()) {
            ImportConfig model = (ImportConfig) iterator.next();
            model.setHistory(true);
            IXMLMemento configMemento = memento.createChild("config");
            configMemento.putString("name", model.getName());
            configMemento.putString("id", model.getId());
            configMemento.putInteger("importType", model.getImportType());
            configMemento.putInteger("errorHandle", model.getErrorHandle());
            configMemento.putString("fileCharset", model.getFilesCharset());
            configMemento.putBoolean("isCreateTable", model.isCreateTableAccordingData());
            configMemento.putInteger("threadCount", model.getThreadCount());
            configMemento.putInteger("commitCount", model.getCommitLine());
            configMemento.putString("rowDelimiter", model.getRowDelimiter());
            configMemento.putString("columnDelimiter", model.getColumnDelimiter());
            configMemento.putBoolean("isHaMode", model.isHaMode());
            IXMLMemento nullValuesMemento = configMemento.createChild("nullValues");
            for (String nullValue : model.getNullValueList()) {
                IXMLMemento nullValueMemento = nullValuesMemento.createChild("nullValue");
                nullValueMemento.putTextData(nullValue);
            }
            IXMLMemento tableConfigsMemento = configMemento.createChild("tableConfigs");
            for (TableConfig tableConfig : model.getSelectedMap().values()) {
                IXMLMemento tableConfigMemento = tableConfigsMemento.createChild("tableConfig");
                for (PstmtParameter pstm : tableConfig.getPstmList()) {
                    IXMLMemento pstmMemento = tableConfigMemento.createChild("pstm");
                    pstmMemento.putString("paramName", pstm.getParamName());
                    pstmMemento.putString("paramType", pstm.getDataType());
                    pstmMemento.putString("paramValue", pstm.getStringParamValue());
                    pstmMemento.putInteger("paramIndex", pstm.getParamIndex());
                    pstmMemento.putString("fileColumnName", pstm.getFileColumnName());
                }
                tableConfigMemento.putString("name", tableConfig.getName());
                tableConfigMemento.putString("filePath", tableConfig.getFilePath());
                tableConfigMemento.putString("fileType", tableConfig.getFileType() == null ? "" : tableConfig.getFileType());
                tableConfigMemento.putInteger("lineCount", tableConfig.getLineCount());
                tableConfigMemento.putString("createDDL", tableConfig.getCreateDDL() == null ? "" : tableConfig.getCreateDDL());
                tableConfigMemento.putString("insertDML", tableConfig.getInsertDML() == null ? "" : tableConfig.getInsertDML());
                tableConfigMemento.putBoolean("isFirstRowAsColumn", tableConfig.isFirstRowAsColumn());
            }
        }
        PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_IMPORT_SETTING, memento);
    }
}
Also used : PstmtParameter(com.cubrid.common.ui.cubrid.table.dialog.PstmtParameter) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

Example 3 with IXMLMemento

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

the class ImportConfigManager method loadImportConfigs.

/**
	 *
	 * Load the added import configs from plug-in preference
	 *
	 */
protected void loadImportConfigs() {
    synchronized (this) {
        importConfigList.clear();
        IXMLMemento memento = PersistUtils.getXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_IMPORT_SETTING);
        IXMLMemento[] children = memento == null ? null : memento.getChildren("config");
        for (int i = 0; children != null && i < children.length; i++) {
            String name = children[i].getString("name");
            String id = children[i].getString("id");
            int importType = children[i].getInteger("importType");
            int errorHandle = children[i].getInteger("errorHandle");
            String fileCharset = children[i].getString("fileCharset");
            boolean isCreateTable = children[i].getBoolean("isCreateTable");
            int threadCount = children[i].getInteger("threadCount");
            int commitCount = children[i].getInteger("commitCount");
            String rowDelimiter = children[i].getString("rowDelimiter");
            String columnDelimiter = children[i].getString("columnDelimiter");
            boolean isHaMode = children[i].getBoolean("isHaMode");
            List<String> nullValues = new ArrayList<String>();
            IXMLMemento nullValuesMemento = children[i].getChild("nullValues");
            IXMLMemento[] nullValueArray = nullValuesMemento.getChildren("nullValue");
            for (IXMLMemento nullValueMemento : nullValueArray) {
                if (nullValueMemento.getTextData() != null) {
                    nullValues.add(nullValueMemento.getTextData());
                }
            }
            ImportConfig importConfig = new ImportConfig();
            importConfig.setName(name);
            importConfig.setId(id);
            importConfig.setType(importType);
            importConfig.setErrorHandle(errorHandle);
            importConfig.setFilesCharset(fileCharset);
            importConfig.setCreateTableAccordingData(isCreateTable);
            importConfig.setThreadCount(threadCount);
            importConfig.setCommitLine(commitCount);
            importConfig.setRowDelimiter(rowDelimiter);
            importConfig.setColumnDelimiter(columnDelimiter);
            importConfig.setNullValueList(nullValues);
            importConfig.setHistory(true);
            importConfig.setHaMode(isHaMode);
            IXMLMemento tableConfigsMemento = children[i].getChild("tableConfigs");
            IXMLMemento[] tableConfigArray = tableConfigsMemento.getChildren("tableConfig");
            for (IXMLMemento configMemento : tableConfigArray) {
                String tableName = configMemento.getString("name");
                String filePath = configMemento.getString("filePath");
                String fileType = configMemento.getString("fileType");
                String createDDL = configMemento.getString("createDDL");
                String insertDML = configMemento.getString("insertDML");
                Integer lineCount = configMemento.getInteger("lineCount");
                boolean isFirstRowAsColumn = configMemento.getBoolean("isFirstRowAsColumn");
                List<PstmtParameter> pstmList = new ArrayList<PstmtParameter>();
                IXMLMemento[] pstmArray = configMemento.getChildren("pstm");
                for (IXMLMemento pstmMemento : pstmArray) {
                    String paramName = pstmMemento.getString("paramName");
                    String paramType = pstmMemento.getString("paramType");
                    String paramValue = pstmMemento.getString("paramValue");
                    int paramIndex = pstmMemento.getInteger("paramIndex");
                    String fileColumnName = pstmMemento.getString("fileColumnName");
                    PstmtParameter pstm = new PstmtParameter(paramName, paramIndex, paramType, paramValue);
                    pstm.setFileColumnName(fileColumnName);
                    pstmList.add(pstm);
                }
                TableConfig tableConfig = new TableConfig(tableName);
                tableConfig.setFilePath(filePath);
                tableConfig.setFileType(fileType);
                tableConfig.setCreateDDL(createDDL);
                tableConfig.setInsertDML(insertDML);
                tableConfig.setFirstRowAsColumn(isFirstRowAsColumn);
                tableConfig.setPstmList(pstmList);
                if (lineCount != null) {
                    tableConfig.setLineCount(lineCount);
                }
                importConfig.addTableConfig(tableConfig);
            }
            importConfigList.add(importConfig);
        }
    }
}
Also used : PstmtParameter(com.cubrid.common.ui.cubrid.table.dialog.PstmtParameter) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ArrayList(java.util.ArrayList)

Example 4 with IXMLMemento

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

the class ExportConfigManager method loadExportConfigs.

/**
	 *
	 * Load the added export configs from plug-in preference
	 *
	 */
protected void loadExportConfigs() {
    synchronized (this) {
        exportConfigList.clear();
        IXMLMemento memento = PersistUtils.getXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_EXPORT_SETTING);
        IXMLMemento[] children = memento == null ? null : memento.getChildren("config");
        for (int i = 0; children != null && i < children.length; i++) {
            String historyName = children[i].getString("name");
            int exportType = children[i].getInteger("exportType");
            int fileType = children[i].getInteger("fileType");
            boolean isExportSchema = children[i].getBoolean("exportSchema");
            boolean isExportIndex = children[i].getBoolean("exportIndex");
            boolean isExportData = children[i].getBoolean("exportData");
            boolean isExportSerial = children[i].getBoolean("exportSerial");
            boolean isExportView = children[i].getBoolean("exportView");
            boolean isExportStartValue = children[i].getBoolean("exportStartValue");
            boolean isExportLobData = children[i].getBoolean("exportLob");
            String schemaFilePath = children[i].getString("schemaFile");
            String indexFilePath = children[i].getString("indexFile");
            String dataFilePath = children[i].getString("dataFile");
            String fileCharset = children[i].getString("fileCharset");
            int threadCount = children[i].getInteger("threadCount");
            boolean useFirstAsColumnBtn = children[i].getBoolean("useFirstAsColumn");
            String nullValue = children[i].getString("nullValue");
            String rowDelimiter = children[i].getString("rowDelimiter");
            String colDelimiter = children[i].getString("colDelimiter");
            Map<String, List<String>> exportTableColumnMap = new LinkedHashMap<String, List<String>>();
            Map<String, String> tableWhereConditionMap = new HashMap<String, String>();
            IXMLMemento[] tables = children[i].getChildren("table");
            List<String> tableList = new ArrayList<String>();
            for (int j = 0; tables != null && j < tables.length; j++) {
                String tableName = tables[j].getString("name");
                tableList.add(tableName);
                String whereCondition = tables[j].getString("where");
                if (whereCondition != null && whereCondition.trim().length() > 0) {
                    tableWhereConditionMap.put(tableName, whereCondition);
                }
            }
            ExportConfig model = new ExportConfig();
            model.setHistory(true);
            model.setName(historyName);
            model.setExportType(exportType);
            model.setExportFileType(fileType);
            model.setExportData(isExportData);
            model.setExportIndex(isExportIndex);
            model.setExportSchema(isExportSchema);
            model.setExportSerial(isExportSerial);
            model.setExportView(isExportView);
            model.setExportSerialStartValue(isExportStartValue);
            model.setExportLob(isExportLobData);
            model.setSchemaFilePath(schemaFilePath);
            model.setIndexFilePath(indexFilePath);
            model.setDataFileFolder(dataFilePath);
            model.setFileCharset(fileCharset);
            model.setThreadCount(threadCount);
            model.setFirstRowAsColumnName(useFirstAsColumnBtn);
            model.setNULLValueTranslation(nullValue);
            model.setRowDelimeter(rowDelimiter);
            model.setColumnDelimeter(colDelimiter);
            model.setTableNameList(tableList);
            for (String tableName : tableList) {
                List<String> columnList = exportTableColumnMap.get(tableName);
                model.setColumnNameList(tableName, columnList);
                String whereCondition = tableWhereConditionMap.get(tableName);
                if (StringUtil.isNotEmpty(whereCondition)) {
                    model.setWhereCondition(tableName, whereCondition);
                }
            }
            exportConfigList.add(model);
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with IXMLMemento

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

the class ExportConfigManager method saveConfigs.

/**
	 *
	 * Save the export configs to plug-in preference
	 *
	 */
public void saveConfigs() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("databases");
        Iterator<ExportConfig> iterator = exportConfigList.iterator();
        while (iterator.hasNext()) {
            ExportConfig model = (ExportConfig) iterator.next();
            IXMLMemento configMemento = memento.createChild("config");
            configMemento.putString("name", model.getName());
            configMemento.putInteger("exportType", model.getExportType());
            configMemento.putInteger("fileType", model.getExportFileType());
            configMemento.putBoolean("exportData", model.isExportData());
            configMemento.putBoolean("exportIndex", model.isExportIndex());
            configMemento.putBoolean("exportSchema", model.isExportSchema());
            configMemento.putBoolean("exportSerial", model.isExportSerial());
            configMemento.putBoolean("exportView", model.isExportView());
            configMemento.putBoolean("exportStartValue", model.isExportSerialStartValue());
            configMemento.putBoolean("exportLob", model.isExportLob());
            configMemento.putString("schemaFile", model.getSchemaFilePath());
            configMemento.putString("indexFile", model.getIndexFilePath());
            configMemento.putString("dataFile", model.getDataFileFolder());
            configMemento.putString("fileCharset", model.getFileCharset());
            configMemento.putInteger("threadCount", model.getThreadCount());
            configMemento.putBoolean("useFirstAsColumn", model.isFirstRowAsColumnName());
            configMemento.putString("nullValue", model.getNULLValueTranslation());
            configMemento.putString("rowDelimiter", model.getRowDelimeter());
            configMemento.putString("colDelimiter", model.getColumnDelimeter());
            List<String> tableList = model.getTableNameList();
            for (String tableName : tableList) {
                IXMLMemento tableMemento = configMemento.createChild("table");
                tableMemento.putString("name", tableName);
                String whereCondition = model.getWhereCondition(tableName);
                if (StringUtil.isNotEmpty(whereCondition)) {
                    tableMemento.putString("where", whereCondition);
                }
            }
        }
        PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_EXPORT_SETTING, memento);
    }
}
Also used : XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento)

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