use of org.opennms.web.alarm.AcknowledgeType in project opennms by OpenNMS.
the class AlarmFilterController method getAcknowledgeType.
private AcknowledgeType getAcknowledgeType(HttpServletRequest request) {
// handle the acknowledgment type parameter
String ackTypeString = request.getParameter("acktype");
AcknowledgeType ackType = DEFAULT_ACKNOWLEDGE_TYPE;
// set default ack type to both if alarm flashing enabled in opennms.properties
String unAckFlashStr = System.getProperty("opennms.alarmlist.unackflash");
boolean unAckFlash = (unAckFlashStr == null) ? false : "true".equals(unAckFlashStr.trim());
if (unAckFlash)
ackType = AcknowledgeType.BOTH;
if (ackTypeString != null) {
AcknowledgeType temp = AcknowledgeType.getAcknowledgeType(ackTypeString);
if (temp != null) {
ackType = temp;
}
}
return ackType;
}
use of org.opennms.web.alarm.AcknowledgeType in project opennms by OpenNMS.
the class AlarmFilterController method list.
private ModelAndView list(HttpServletRequest request, OnmsFilterFavorite favorite) {
AcknowledgeType ackType = getAcknowledgeType(request);
ModelAndView modelAndView = createListModelAndView(request, getFilterCallback().parse(request.getParameterValues("filter")), ackType);
modelAndView.addObject("favorite", favorite);
modelAndView.setViewName("alarm/list");
return modelAndView;
}
use of org.opennms.web.alarm.AcknowledgeType 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