use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.
the class ApplicationPersistUtil method saveToXmlFile.
private void saveToXmlFile(IXMLMemento parent) {
if (editorStatusList == null) {
return;
}
DateFormat formater = DateUtil.getDateFormat(DATE_PATTERN, Locale.ENGLISH);
for (List<RestorableQueryEditorInfo> statusList : editorStatusList) {
IXMLMemento memento = parent.createChild("editor_status");
for (RestorableQueryEditorInfo status : statusList) {
IXMLMemento tabItem = memento.createChild("sql_tabItem");
tabItem.putString("content", status.getQueryContents());
tabItem.putString("create_time", formater.format(status.getCreatedTime()));
tabItem.putString("database", status.getDatabaseName() == null ? "" : status.getDatabaseName());
tabItem.putString("server", status.getServerName() == null ? "" : status.getServerName());
}
}
IXMLMemento queryListDataMemento = parent.createChild("query_record_list_data");
for (Entry<String, List<QueryRecordProject>> entry : queryRecordMap.entrySet()) {
String key = entry.getKey();
List<QueryRecordProject> list = entry.getValue();
for (QueryRecordProject queryRecordList : list) {
IXMLMemento queryListMemento = queryListDataMemento.createChild("query_redord_list");
String createDate = formater.format(queryRecordList.getCreateDate());
queryListMemento.putString("database_key", key);
queryListMemento.putString("create_date", createDate);
queryListMemento.putString("name", queryRecordList.getName());
for (QueryRecord queryRecord : queryRecordList.getQueryRecordList()) {
IXMLMemento queryRecordMemento = queryListMemento.createChild("query_record");
queryRecordMemento.putString("name", queryRecord.getName());
queryRecordMemento.putString("create_date", formater.format(queryRecord.getCreateDate()));
queryRecordMemento.putString("start_time", String.valueOf(queryRecord.getStartTime()));
queryRecordMemento.putString("stop_time", String.valueOf(queryRecord.getStopTime()));
queryRecordMemento.putString("query", queryRecord.getQuery());
if (queryRecord.getQueryPlan() != null) {
StructQueryPlan queryPlan = queryRecord.getQueryPlan();
IXMLMemento queryPlanMemento = queryRecordMemento.createChild("query_plan");
queryPlanMemento.putString("query", queryPlan.getSql());
queryPlanMemento.putString("plan", queryPlan.getPlanRaw());
queryPlanMemento.putString("create_date", formater.format(queryPlan.getCreated()));
}
if (queryRecord.getStatistics() != null) {
IXMLMemento statisticsMemento = queryRecordMemento.createChild("statistics");
for (Entry<String, String> prop : queryRecord.getStatistics().entrySet()) {
statisticsMemento.putString(prop.getKey(), prop.getValue());
}
}
}
}
}
}
use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.
the class ApplicationPersistUtil method getQueryRecordProject.
public List<QueryRecordProject> getQueryRecordProject(DatabaseInfo databaseInfo) {
List<QueryRecordProject> list = queryRecordMap.get(getDBMapKey(databaseInfo));
if (list == null) {
list = new ArrayList<QueryRecordProject>();
queryRecordMap.put(getDBMapKey(databaseInfo), list);
}
List<QueryRecordProject> result = new ArrayList<QueryRecordProject>();
for (QueryRecordProject project : list) {
result.add(project.clone());
}
return result;
}
use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.
the class ApplicationPersistUtil method loadQueryRecordList.
/**
* Load query record list
*
* @param element
*/
private void loadQueryRecordList(IXMLMemento element) {
DateFormat formater = DateUtil.getDateFormat(DATE_PATTERN, Locale.ENGLISH);
IXMLMemento[] dataArray = element.getChildren("query_redord_list");
if (dataArray != null && dataArray.length > 0) {
for (int i = 0; i < dataArray.length; i++) {
IXMLMemento child = dataArray[i];
String key = child.getString("database_key");
String dateStr = child.getString("create_date");
String name = child.getString("name");
QueryRecordProject recordList = new QueryRecordProject();
recordList.setDatabaseKey(key);
recordList.setName(name);
try {
recordList.setCreateDate(formater.parse(dateStr));
} catch (ParseException e) {
recordList.setCreateDate(new Date());
}
IXMLMemento[] queryRecordArray = child.getChildren("query_record");
if (queryRecordArray != null && queryRecordArray.length > 0) {
for (int j = 0; j < queryRecordArray.length; j++) {
IXMLMemento memen = queryRecordArray[j];
QueryRecord queryRecord = loadQueryRecord(memen);
recordList.addQueryRecord(queryRecord);
}
}
List<QueryRecordProject> list = queryRecordMap.get(key);
if (list == null) {
list = new ArrayList<QueryRecordProject>();
queryRecordMap.put(key, list);
}
list.add(recordList);
}
}
}
use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.
the class AddQueryRecordProjectDialog method validate.
private boolean validate() {
setErrorMessage(null);
getButton(IDialogConstants.OK_ID).setEnabled(false);
name = newText.getText();
if (StringUtil.isEmpty(name)) {
setErrorMessage(Messages.msgQueryTunerNameEmpty);
}
List<QueryRecordProject> queryRecordProjectList = ApplicationPersistUtil.getInstance().getQueryRecordProject(databaseInfo);
if (newFlag) {
for (QueryRecordProject list : queryRecordProjectList) {
if (StringUtil.isEqual(name, list.getName())) {
setErrorMessage(Messages.bind(Messages.msgQueryTunerNameExist, name));
return false;
}
}
} else {
for (QueryRecordProject list : queryRecordProjectList) {
if (StringUtil.isEqual(name, list.getName()) && list != queryRecordProect) {
setErrorMessage(Messages.msgQueryTunerNameExist);
return false;
}
}
}
getButton(IDialogConstants.OK_ID).setEnabled(true);
return true;
}
use of com.cubrid.common.ui.query.tuner.QueryRecordProject in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method renameQueryRecordProject.
/**
* Rename selected query record list
*
*/
private void renameQueryRecordProject() {
String name = historyCombo.getText();
QueryRecordProject queryRecordProject = ApplicationPersistUtil.getInstance().findQueryRecordProject(database.getDatabaseInfo(), name);
if (queryRecordProject != null) {
AddQueryRecordProjectDialog dialog = new AddQueryRecordProjectDialog(getShell(), queryRecordProject, false, database.getDatabaseInfo());
if (dialog.open() == IDialogConstants.OK_ID) {
/*Remove old list*/
ApplicationPersistUtil.getInstance().removeQueryRecordProject(database.getDatabaseInfo(), name);
/*Add new list*/
queryRecordProject.setName(dialog.getName());
ApplicationPersistUtil.getInstance().addQueryRecordProject(database.getDatabaseInfo(), queryRecordProject);
/*Save*/
ApplicationPersistUtil.getInstance().save();
switchQueryRecordProject(queryRecordProject.getName());
}
}
}
Aggregations