use of org.opennms.web.alarm.AlarmQueryParms in project opennms by OpenNMS.
the class AlarmFilterController method createAlarmQueryParms.
private AlarmQueryParms createAlarmQueryParms(HttpServletRequest request, List<Filter> filterList, AcknowledgeType ackType) {
AlarmQueryParms parms = new AlarmQueryParms();
parms.ackType = ackType;
parms.display = getDisplay(request);
parms.filters = filterList;
parms.limit = getLimit(request);
parms.multiple = getMultiple(request);
parms.sortStyle = getSortStyle(request);
return parms;
}
use of org.opennms.web.alarm.AlarmQueryParms 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.opennms.web.alarm.AlarmQueryParms in project opennms by OpenNMS.
the class NCSAlarmController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String display = request.getParameter("display");
// handle the style sort parameter
String sortStyleString = request.getParameter("sortby");
SortStyle sortStyle = m_defaultSortStyle;
if (sortStyleString != null) {
SortStyle temp = SortStyle.getSortStyle(sortStyleString);
if (temp != null) {
sortStyle = temp;
}
}
// handle the acknowledgment type parameter
String ackTypeString = request.getParameter("acktype");
AcknowledgeType ackType = m_defaultAcknowledgeType;
if (ackTypeString != null) {
AcknowledgeType temp = AcknowledgeType.getAcknowledgeType(ackTypeString);
if (temp != null) {
ackType = temp;
}
}
// handle the filter parameters
String[] filterStrings = request.getParameterValues("filter");
List<Filter> filterList = new ArrayList<>();
if (filterStrings != null) {
for (int i = 0; i < filterStrings.length; i++) {
Filter filter = AlarmUtil.getFilter(filterStrings[i], getServletContext());
if (filter != null) {
filterList.add(filter);
}
}
} else {
filterList.add(AlarmUtil.getFilter("parmmatchany=componentType=Service", getServletContext()));
}
// handle the optional limit parameter
String limitString = request.getParameter("limit");
int limit = "long".equals(display) ? getDefaultLongLimit() : getDefaultShortLimit();
if (limitString != null) {
try {
int newlimit = WebSecurityUtils.safeParseInt(limitString);
if (newlimit > 0) {
limit = newlimit;
}
} catch (NumberFormatException e) {
// do nothing, the default is already set
}
}
// handle the optional multiple parameter
String multipleString = request.getParameter("multiple");
int multiple = DEFAULT_MULTIPLE;
if (multipleString != null) {
try {
multiple = Math.max(0, WebSecurityUtils.safeParseInt(multipleString));
} catch (NumberFormatException e) {
}
}
// put the parameters in a convenient struct
Filter[] filters = filterList.toArray(new Filter[0]);
AlarmQueryParms parms = new AlarmQueryParms();
parms.ackType = ackType;
parms.display = display;
parms.filters = filterList;
parms.limit = limit;
parms.multiple = multiple;
parms.sortStyle = sortStyle;
AlarmCriteria queryCriteria = new AlarmCriteria(filters, sortStyle, ackType, limit, limit * multiple);
AlarmCriteria countCriteria = new AlarmCriteria(filters, ackType);
OnmsAlarm[] alarms = m_webAlarmRepository.getMatchingAlarms(AlarmUtil.getOnmsCriteria(queryCriteria));
// get the total alarm count
int alarmCount = m_webAlarmRepository.countMatchingAlarms(AlarmUtil.getOnmsCriteria(countCriteria));
ModelAndView modelAndView = new ModelAndView(getSuccessView());
modelAndView.addObject("alarms", alarms);
modelAndView.addObject("alarmCount", alarmCount);
modelAndView.addObject("parms", parms);
return modelAndView;
}
Aggregations