Search in sources :

Example 1 with AcknowledgeType

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

Example 2 with AcknowledgeType

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

Example 3 with AcknowledgeType

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;
}
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

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