Search in sources :

Example 1 with AlarmQueryParms

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;
}
Also used : AlarmQueryParms(org.opennms.web.alarm.AlarmQueryParms)

Example 2 with AlarmQueryParms

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;
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmQueryParms(org.opennms.web.alarm.AlarmQueryParms) ModelAndView(org.springframework.web.servlet.ModelAndView) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) NormalizedQueryParameters(org.opennms.web.filter.NormalizedQueryParameters)

Example 3 with AlarmQueryParms

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;
}
Also used : SortStyle(org.opennms.web.alarm.SortStyle) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) ArrayList(java.util.ArrayList) AlarmQueryParms(org.opennms.web.alarm.AlarmQueryParms) ModelAndView(org.springframework.web.servlet.ModelAndView) AcknowledgeType(org.opennms.web.alarm.AcknowledgeType) Filter(org.opennms.web.filter.Filter) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AlarmQueryParms (org.opennms.web.alarm.AlarmQueryParms)3 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)2 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ArrayList (java.util.ArrayList)1 AcknowledgeType (org.opennms.web.alarm.AcknowledgeType)1 SortStyle (org.opennms.web.alarm.SortStyle)1 Filter (org.opennms.web.filter.Filter)1 NormalizedQueryParameters (org.opennms.web.filter.NormalizedQueryParameters)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1