Search in sources :

Example 1 with NormalizedQueryParameters

use of org.opennms.web.filter.NormalizedQueryParameters 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 2 with NormalizedQueryParameters

use of org.opennms.web.filter.NormalizedQueryParameters in project opennms by OpenNMS.

the class EventController method createListModelAndView.

private ModelAndView createListModelAndView(HttpServletRequest request, List<Filter> filterList, AcknowledgeType ackType) {
    final EventQueryParms parms = createEventQueryParms(request, filterList, ackType);
    final EventCriteria queryCriteria = new EventCriteria(parms);
    final Event[] events = m_webEventRepository.getMatchingEvents(queryCriteria);
    final ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("events", events);
    modelAndView.addObject("parms", new NormalizedQueryParameters(parms));
    modelAndView.addObject("callback", getFilterCallback());
    modelAndView.addObject("favorites", favoriteService.getFavorites(request.getRemoteUser(), OnmsFilterFavorite.Page.EVENT).toArray());
    if (m_showEventCount) {
        EventCriteria countCriteria = new EventCriteria(filterList, ackType);
        modelAndView.addObject("eventCount", m_webEventRepository.countMatchingEvents(countCriteria));
    } else {
        modelAndView.addObject("eventCount", Integer.valueOf(-1));
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) EventCriteria(org.opennms.web.event.filter.EventCriteria) NormalizedQueryParameters(org.opennms.web.filter.NormalizedQueryParameters)

Example 3 with NormalizedQueryParameters

use of org.opennms.web.filter.NormalizedQueryParameters in project opennms by OpenNMS.

the class FiltersTag method getLeading.

private String getLeading() {
    StringBuffer leadingString = new StringBuffer();
    if (isShowAcknowledgeFilter()) {
        NormalizedQueryParameters params = new NormalizedQueryParameters(parameters);
        if (isAcknowledgeType()) {
            params.setAckType(NormalizedAcknowledgeType.UNACKNOWLEDGED);
            leadingString.append(FILTER_TEMPLATE.replaceAll("\\{FILTER_DESCRIPTION\\}", getAcknowledgeFilterPrefix() + " acknowledged").replaceAll("\\{REMOVE_LINK\\}", isShowRemoveLink() ? filterCallback.createLink(getUrlBase(), params, favorite) : "").replaceAll("\\{REMOVE_LINK_TITLE\\}", isShowRemoveLink() ? "Show outstanding " + getAcknowledgeFilterSuffix() : ""));
        } else if (isUnacknowledgeType()) {
            params.setAckType(NormalizedAcknowledgeType.ACKNOWLEDGED);
            leadingString.append(FILTER_TEMPLATE.replaceAll("\\{FILTER_DESCRIPTION\\}", getAcknowledgeFilterPrefix() + " outstanding").replaceAll("\\{REMOVE_LINK\\}", isShowRemoveLink() ? filterCallback.createLink(getUrlBase(), params, favorite) : "").replaceAll("\\{REMOVE_LINK_TITLE\\}", isShowRemoveLink() ? "Show acknowledged " + getAcknowledgeFilterSuffix() : ""));
        }
    }
    return leadingString.toString();
}
Also used : NormalizedQueryParameters(org.opennms.web.filter.NormalizedQueryParameters)

Example 4 with NormalizedQueryParameters

use of org.opennms.web.filter.NormalizedQueryParameters in project opennms by OpenNMS.

the class FiltersTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    final String leadingString = getLeading();
    final StringBuffer filterBuffer = new StringBuffer();
    for (Filter eachFilter : getFilters()) {
        NormalizedQueryParameters params = new NormalizedQueryParameters(parameters);
        params.getFilters().remove(eachFilter);
        filterBuffer.append(FILTER_TEMPLATE.replaceAll("\\{FILTER_DESCRIPTION\\}", WebSecurityUtils.sanitizeString(eachFilter.getTextDescription())).replaceAll("\\{REMOVE_LINK\\}", isShowRemoveLink() ? filterCallback.createLink(getUrlBase(), params, favorite) : "").replaceAll("\\{REMOVE_LINK_TITLE\\}", isShowRemoveLink() ? "Remove filter" : ""));
    }
    out(TEMPLATE.replaceAll("\\{LEADING\\}", leadingString).replaceAll("\\{FILTERS\\}", filterBuffer.toString()));
    return EVAL_BODY_INCLUDE;
}
Also used : Filter(org.opennms.web.filter.Filter) NormalizedQueryParameters(org.opennms.web.filter.NormalizedQueryParameters)

Aggregations

NormalizedQueryParameters (org.opennms.web.filter.NormalizedQueryParameters)4 ModelAndView (org.springframework.web.servlet.ModelAndView)2 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)1 AlarmQueryParms (org.opennms.web.alarm.AlarmQueryParms)1 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)1 EventCriteria (org.opennms.web.event.filter.EventCriteria)1 Filter (org.opennms.web.filter.Filter)1