Search in sources :

Example 1 with EventDisplayFilter

use of org.opennms.web.event.filter.EventDisplayFilter in project opennms by OpenNMS.

the class DaoWebEventRepository method getOnmsCriteria.

private OnmsCriteria getOnmsCriteria(final EventCriteria eventCriteria) {
    final OnmsCriteria criteria = new OnmsCriteria(OnmsEvent.class);
    criteria.createAlias("alarm", "alarm", OnmsCriteria.LEFT_JOIN);
    criteria.createAlias("node", "node", OnmsCriteria.LEFT_JOIN);
    criteria.createAlias("serviceType", "serviceType", OnmsCriteria.LEFT_JOIN);
    criteria.createAlias("distPoller", "distPoller", OnmsCriteria.LEFT_JOIN);
    criteria.add(new EventDisplayFilter("Y").getCriterion());
    eventCriteria.visit(new EventCriteriaVisitor<RuntimeException>() {

        @Override
        public void visitAckType(AcknowledgeType ackType) throws RuntimeException {
            if (ackType == AcknowledgeType.ACKNOWLEDGED) {
                criteria.add(Restrictions.isNotNull("eventAckUser"));
            } else if (ackType == AcknowledgeType.UNACKNOWLEDGED) {
                criteria.add(Restrictions.isNull("eventAckUser"));
            }
        }

        @Override
        public void visitFilter(Filter filter) throws RuntimeException {
            criteria.add(filter.getCriterion());
        }

        @Override
        public void visitLimit(int limit, int offset) throws RuntimeException {
            criteria.setMaxResults(limit);
            criteria.setFirstResult(offset);
        }

        @Override
        public void visitSortStyle(SortStyle sortStyle) throws RuntimeException {
            switch(sortStyle) {
                case ID:
                    criteria.addOrder(Order.desc("id"));
                    break;
                case INTERFACE:
                    criteria.addOrder(Order.desc("ipAddr"));
                    break;
                case NODE:
                    criteria.addOrder(Order.desc("node.label"));
                    break;
                case POLLER:
                    criteria.addOrder(Order.desc("distPoller"));
                    break;
                case SERVICE:
                    criteria.addOrder(Order.desc("serviceType.name"));
                    break;
                case SEVERITY:
                    criteria.addOrder(Order.desc("eventSeverity"));
                    break;
                case TIME:
                    criteria.addOrder(Order.desc("eventTime"));
                    break;
                case LOCATION:
                    criteria.addOrder(Order.desc("distPoller.location"));
                    break;
                case SYSTEMID:
                    criteria.addOrder(Order.desc("distPoller.id"));
                    break;
                case REVERSE_ID:
                    criteria.addOrder(Order.asc("id"));
                    break;
                case REVERSE_INTERFACE:
                    criteria.addOrder(Order.asc("ipAddr"));
                    break;
                case REVERSE_NODE:
                    criteria.addOrder(Order.asc("node.label"));
                    break;
                case REVERSE_POLLER:
                    criteria.addOrder(Order.asc("distPoller"));
                    break;
                case REVERSE_SERVICE:
                    criteria.addOrder(Order.desc("serviceType.name"));
                    break;
                case REVERSE_SEVERITY:
                    criteria.addOrder(Order.asc("eventSeverity"));
                    break;
                case REVERSE_TIME:
                    criteria.addOrder(Order.asc("eventTime"));
                    break;
                case REVERSE_LOCATION:
                    criteria.addOrder(Order.asc("distPoller.location"));
                    break;
                case REVERSE_SYSTEMID:
                    criteria.addOrder(Order.asc("distPoller.id"));
                    break;
            }
        }
    });
    return criteria;
}
Also used : EventDisplayFilter(org.opennms.web.event.filter.EventDisplayFilter) Filter(org.opennms.web.filter.Filter) OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria) EventDisplayFilter(org.opennms.web.event.filter.EventDisplayFilter)

Aggregations

OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)1 EventDisplayFilter (org.opennms.web.event.filter.EventDisplayFilter)1 Filter (org.opennms.web.filter.Filter)1