use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.
the class AlarmFilterController method createListModelAndView.
private ModelAndView createListModelAndView(HttpServletRequest request, List<Filter> filterList, AcknowledgeType ackType) {
final AlarmQueryParms parms = createAlarmQueryParms(request, filterList, ackType);
AlarmCriteria queryCriteria = new AlarmCriteria(parms);
AlarmCriteria countCriteria = new AlarmCriteria(filterList, ackType);
final OnmsAlarm[] alarms = m_webAlarmRepository.getMatchingAlarms(AlarmUtil.getOnmsCriteria(queryCriteria));
final long alarmCount = m_webAlarmRepository.countMatchingAlarms(AlarmUtil.getOnmsCriteria(countCriteria));
final ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("alarms", alarms);
modelAndView.addObject("alarmCount", alarmCount);
modelAndView.addObject("parms", new NormalizedQueryParameters(parms));
modelAndView.addObject("callback", getFilterCallback());
modelAndView.addObject("favorites", favoriteService.getFavorites(request.getRemoteUser(), OnmsFilterFavorite.Page.ALARM).toArray());
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.
the class ThresholdController method gotoEditThreshold.
private ModelAndView gotoEditThreshold(String thresholdIndexString, String groupName) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
if (thresholdIndexString == null) {
throw new ServletException("thresholdIndex parameter required to edit a threshold");
}
int thresholdIndex = WebSecurityUtils.safeParseInt(thresholdIndexString);
Threshold threshold = configFactory.getGroup(groupName).getThresholds().get(thresholdIndex);
modelAndView = new ModelAndView("admin/thresholds/editThreshold");
modelAndView.addObject("threshold", threshold);
modelAndView.addObject("thresholdIndex", thresholdIndex);
modelAndView.addObject("groupName", groupName);
modelAndView.addObject("isNew", false);
addStandardEditingBits(modelAndView);
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.
the class AlarmDetailController method removeStickyMemo.
public ModelAndView removeStickyMemo(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
int alarmId;
String alarmIdString = "";
// Try to parse alarm ID from string to integer
try {
alarmIdString = httpServletRequest.getParameter("alarmId");
alarmId = Integer.parseInt(alarmIdString);
m_webAlarmRepository.removeStickyMemo(alarmId);
return new ModelAndView(new RedirectView("detail.htm", true), "id", alarmId);
} catch (NumberFormatException e) {
logger.error("Could not parse alarm ID '{}' to integer.", httpServletRequest.getParameter("alarmId"));
throw new ServletException("Could not parse alarm ID " + httpServletRequest.getParameter("alarmId") + " to integer.");
}
}
use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.
the class ThresholdController method finishThresholdFilterEdit.
private ModelAndView finishThresholdFilterEdit(HttpServletRequest request, Basethresholddef threshold) throws ServletException {
boolean isExpression = threshold instanceof Expression;
int thresholdIndex;
if (isExpression) {
thresholdIndex = WebSecurityUtils.safeParseInt(request.getParameter("expressionIndex"));
} else {
thresholdIndex = WebSecurityUtils.safeParseInt(request.getParameter("thresholdIndex"));
}
ModelAndView modelAndView;
if (isExpression) {
modelAndView = new ModelAndView("admin/thresholds/editExpression");
} else {
modelAndView = new ModelAndView("admin/thresholds/editThreshold");
}
List<ResourceFilter> saved = getFilterList(request, true);
if (saved == null || saved.size() == 0) {
saved = new ArrayList<ResourceFilter>(threshold.getResourceFilters());
setFilterList(request, saved);
}
String stringIndex = request.getParameter("filterSelected");
int filterIndex = stringIndex != null && !stringIndex.equals("") ? WebSecurityUtils.safeParseInt(stringIndex) - 1 : 0;
/*
* Save Threshold Filters on HTTP Session in order to restore the original list if user clicks on "Cancel"
*/
String submitAction = request.getParameter("submitAction");
if (ADDFILTER_BUTTON_TITLE.equals(submitAction)) {
String field = request.getParameter("filterField");
String content = request.getParameter("filterRegexp");
if (field != null && !field.equals("") && content != null && !content.equals("")) {
ResourceFilter filter = new ResourceFilter();
filter.setField(field);
filter.setContent(content);
threshold.addResourceFilter(filter);
}
} else if (DELETE_BUTTON_TITLE.equals(submitAction)) {
threshold.getResourceFilters().remove(filterIndex);
} else if (EDIT_BUTTON_TITLE.equals(submitAction)) {
modelAndView.addObject("filterSelected", request.getParameter("filterSelected"));
} else if (UPDATE_BUTTON_TITLE.equals(submitAction)) {
ResourceFilter filter = (ResourceFilter) threshold.getResourceFilters().get(filterIndex);
filter.setField(request.getParameter("updateFilterField"));
filter.setContent(request.getParameter("updateFilterRegexp"));
} else if (MOVEUP_BUTTON_TITLE.equals(submitAction)) {
moveThresholdFilter(threshold, filterIndex, filterIndex - 1);
} else if (MOVEDOWN_BUTTON_TITLE.equals(submitAction)) {
moveThresholdFilter(threshold, filterIndex, filterIndex + 1);
}
commonFinishEdit(request, threshold);
if (isExpression) {
((Expression) threshold).setExpression(request.getParameter("expression"));
} else {
((Threshold) threshold).setDsName(request.getParameter("dsName"));
}
String isNew = request.getParameter("isNew");
if ("true".equals(isNew)) {
modelAndView.addObject("isNew", true);
}
if (isExpression) {
modelAndView.addObject("expression", threshold);
modelAndView.addObject("expressionIndex", thresholdIndex);
} else {
modelAndView.addObject("threshold", threshold);
modelAndView.addObject("thresholdIndex", thresholdIndex);
}
modelAndView.addObject("groupName", request.getParameter("groupName"));
addStandardEditingBits(modelAndView);
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.
the class ThresholdController method gotoEditExpression.
private ModelAndView gotoEditExpression(String expressionIndexString, String groupName) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
if (expressionIndexString == null) {
throw new ServletException("expressionIndex parameter required to edit a threshold");
}
int expressionIndex = WebSecurityUtils.safeParseInt(expressionIndexString);
Expression expression = configFactory.getGroup(groupName).getExpressions().get(expressionIndex);
modelAndView = new ModelAndView("admin/thresholds/editExpression");
modelAndView.addObject("expression", expression);
modelAndView.addObject("expressionIndex", expressionIndex);
modelAndView.addObject("groupName", groupName);
modelAndView.addObject("isNew", false);
addStandardEditingBits(modelAndView);
return modelAndView;
}
Aggregations