if (lineChartJsonPair != null) {
Map<String, Object> lineChartObjs = new HashMap<String, Object>();
lineChartObjs.put("lineCharts", lineChartJsonPair.getKey());
lineChartObjs.put("lineChartDetails", lineChartJsonPair.getValue());
model.setFetchData(new JsonBuilder().toJson(lineChartObjs));
}
break;
case PIECHART:
Pair<PieChart, List<PieChartDetailInfo>> pieChartPair = buildPieChart(model, payload, field);
if (pieChartPair != null) {
model.setPieChart(pieChartPair.getKey());
model.setPieChartDetailInfos(pieChartPair.getValue());
}
break;
case PIECHART_JSON:
Pair<PieChart, List<PieChartDetailInfo>> pieChartJsonPair = buildPieChart(model, payload, field);
if (pieChartJsonPair != null) {
Map<String, Object> pieChartObjs = new HashMap<String, Object>();
pieChartObjs.put("pieCharts", pieChartJsonPair.getKey());
pieChartObjs.put("pieChartDetails", pieChartJsonPair.getValue());
model.setFetchData(new JsonBuilder().toJson(pieChartObjs));
}
break;
case APP_ADD:
String domain = payload.getDomain();
String name = payload.getName();
String title = payload.getTitle();
if (StringUtil.isEmpty(name)) {
setUpdateResult(model, 0);
} else {
try {
Pair<Boolean, Integer> addCommandResult = m_manager.addCommand(domain, title, name);
if (addCommandResult.getKey()) {
setUpdateResult(model, 1);
m_appRuleConfigManager.addDefultRule(name, addCommandResult.getValue());
} else {
setUpdateResult(model, 2);
}
} catch (Exception e) {
setUpdateResult(model, 2);
}
}
break;
case APP_DELETE:
domain = payload.getDomain();
name = payload.getName();
if (StringUtil.isEmpty(name)) {
setUpdateResult(model, 0);
} else {
Pair<Boolean, List<Integer>> deleteCommandResult = m_manager.deleteCommand(domain, name);
if (deleteCommandResult.getKey()) {
setUpdateResult(model, 1);
m_appRuleConfigManager.deleteDefaultRule(name, deleteCommandResult.getValue());
} else {
setUpdateResult(model, 2);
}
}
break;
case APP_CONFIG_FETCH:
String type = payload.getType();
try {
if ("xml".equalsIgnoreCase(type)) {
model.setFetchData(m_manager.getConfig().toString());
} else if (StringUtils.isEmpty(type) || "json".equalsIgnoreCase(type)) {
model.setFetchData(new JsonBuilder().toJson(m_manager.getConfig()));
}
} catch (Exception e) {
Cat.logError(e);
}
break;