MetricsDisplayForm displayForm = (MetricsDisplayForm) form;
Map forwardParams = displayForm.getForwardParams();
Integer id = displayForm.getId();
WebUser user = SessionUtils.getWebUser(request.getSession());
MeasurementPreferences preferences = user.getMeasurementPreferences();
Subject subject = RequestUtils.getSubject(request);
MeasurementBaselineManagerLocal baselineManager = LookupUtil.getMeasurementBaselineManager();
if (displayForm.isCompareClicked()) {
return returnCompare(request, mapping, forwardParams);
} else if (displayForm.isChartClicked()) {
forwardParams.put(ParamConstants.METRIC_ID_PARAM, displayForm.getM());
return returnChart(request, mapping, forwardParams);
} else if (displayForm.isThresholdClicked()) {
Integer threshold = displayForm.getT();
preferences.setMetricThresholdPreference(threshold);
log.trace("saving threshold pref [" + threshold + "]");
LogFactory.getLog("user.preferences").trace(
"Invoking setUserPrefs" + " in MetricsDisplayAction " + " for " + user.getId() + " at "
+ System.currentTimeMillis() + " user.prefs = " + user.getWebPreferences());
} else if (displayForm.isUsersetClicked()) {
Integer[] m = displayForm.getM();
if ((m != null) && (m.length > 0)) {
MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences();
Long begin = rangePreferences.begin;
Long end = rangePreferences.end;
Integer[] resourceIds = displayForm.getR();
Resource[] resources = null; // TODO hwr: fix this
// TODO what do we really want here?
// this looks like users want to see old baselines at display time
// bb.saveBaselines(sessionId.intValue(), resources, m,
// begin.longValue(), end.longValue());
log.trace("Set baselines in MetricsDisplayAction " + " for " + id + ": " + StringUtil.arrayToString(m));
}
RequestUtils.setConfirmation(request, Constants.CNF_METRICS_BASELINE_SET);
} else if (displayForm.isEnableClicked()) {
Integer[] m = displayForm.getM();
if ((m != null) && (m.length > 0)) {
Integer[] resources = displayForm.getR();
baselineManager.enableAutoBaselineCalculation(subject, resources, m);
log.trace("Enable auto baselines in MetricsDisplayAction " + " for " + id + ": "
+ StringUtil.arrayToString(m));
}
RequestUtils.setConfirmation(request, Constants.CNF_AUTO_BASELINE_SET);
} else if (displayForm.isAddClicked()) {
Integer[] m = displayForm.getM();
if ((m != null) && (m.length > 0)) {
//addFavoriteMetrics(m, user, id.getTypeName());
LogFactory.getLog("user.preferences").trace(
"Invoking setUserPrefs" + " in MetricsDisplayAction " + " for " + user.getId() + " at "
+ System.currentTimeMillis() + " user.prefs = " + user.getWebPreferences());
}
RequestUtils.setConfirmation(request, Constants.CNF_FAVORITE_METRICS_ADDED);
} else if (displayForm.isRemoveClicked()) {
Integer[] m = displayForm.getM();
if ((m != null) && (m.length > 0)) {
//removeFavoriteMetrics(m, user, entityId.getTypeName());
LogFactory.getLog("user.preferences").trace(
"Invoking setUserPrefs" + " in MetricsDisplayAction " + " for " + user.getId() + " at "
+ System.currentTimeMillis() + " user.prefs = " + user.getWebPreferences());
}
RequestUtils.setConfirmation(request, Constants.CNF_FAVORITE_METRICS_REMOVED);
}