Search in sources :

Example 1 with AcknowledgedByFilter

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

the class DaoWebEventRepositoryIT method testAcknowledgeUnacknowledgeMatchingAlarms.

@Test
// Relies on specific IDs so we need a fresh database
@JUnitTemporaryDatabase
public void testAcknowledgeUnacknowledgeMatchingAlarms() {
    m_daoEventRepo.acknowledgeMatchingEvents("TestUser", new Date(), new EventCriteria(new EventIdFilter(1)));
    int matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(1, matchingEventCount);
    m_daoEventRepo.unacknowledgeMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(0, matchingEventCount);
}
Also used : AcknowledgedByFilter(org.opennms.web.event.filter.AcknowledgedByFilter) EventCriteria(org.opennms.web.event.filter.EventCriteria) EventIdFilter(org.opennms.web.event.filter.EventIdFilter) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 2 with AcknowledgedByFilter

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

the class DaoWebEventRepositoryIT method testAcknowledgeUnacknowledgeAllAlarms.

@Test
@Transactional
public void testAcknowledgeUnacknowledgeAllAlarms() {
    m_daoEventRepo.acknowledgeAll("TestUser", new Date());
    int matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(2, matchingEventCount);
    m_daoEventRepo.unacknowledgeAll();
    matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(0, matchingEventCount);
}
Also used : AcknowledgedByFilter(org.opennms.web.event.filter.AcknowledgedByFilter) EventCriteria(org.opennms.web.event.filter.EventCriteria) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with AcknowledgedByFilter

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

the class EventUtil method getFilter.

/**
     * <p>getFilter</p>
     *
     * @param filterString a {@link java.lang.String} object.
     * @return a org$opennms$web$filter$Filter object.
     */
public static Filter getFilter(String filterString, ServletContext servletContext) {
    if (filterString == null) {
        throw new IllegalArgumentException("Cannot take null parameters.");
    }
    Filter filter = null;
    StringTokenizer tokens = new StringTokenizer(filterString, "=");
    String type;
    String value;
    try {
        type = tokens.nextToken();
        value = tokens.nextToken();
    } catch (NoSuchElementException e) {
        throw new IllegalArgumentException("Could not tokenize filter string: " + filterString);
    }
    if (type.equals(SeverityFilter.TYPE)) {
        filter = new SeverityFilter(WebSecurityUtils.safeParseInt(value));
    } else if (type.equals(NodeFilter.TYPE)) {
        filter = new NodeFilter(WebSecurityUtils.safeParseInt(value), servletContext);
    } else if (type.equals(NodeNameLikeFilter.TYPE)) {
        filter = new NodeNameLikeFilter(value);
    } else if (type.equals(InterfaceFilter.TYPE)) {
        filter = new InterfaceFilter(value);
    } else if (type.equals(ServiceFilter.TYPE)) {
        filter = new ServiceFilter(WebSecurityUtils.safeParseInt(value), servletContext);
    } else if (type.equals(IfIndexFilter.TYPE)) {
        filter = new IfIndexFilter(WebSecurityUtils.safeParseInt(value));
    } else if (type.equals(PartialUEIFilter.TYPE)) {
        filter = new PartialUEIFilter(value);
    } else if (type.equals(ExactUEIFilter.TYPE)) {
        filter = new ExactUEIFilter(value);
    } else if (type.equals(AcknowledgedByFilter.TYPE)) {
        filter = new AcknowledgedByFilter(value);
    } else if (type.equals(NegativeSeverityFilter.TYPE)) {
        filter = new NegativeSeverityFilter(WebSecurityUtils.safeParseInt(value));
    } else if (type.equals(NegativeNodeFilter.TYPE)) {
        filter = new NegativeNodeFilter(WebSecurityUtils.safeParseInt(value), servletContext);
    } else if (type.equals(NegativeInterfaceFilter.TYPE)) {
        filter = new NegativeInterfaceFilter(value);
    } else if (type.equals(NegativeServiceFilter.TYPE)) {
        filter = new NegativeServiceFilter(WebSecurityUtils.safeParseInt(value), servletContext);
    } else if (type.equals(NegativePartialUEIFilter.TYPE)) {
        filter = new NegativePartialUEIFilter(value);
    } else if (type.equals(NegativeExactUEIFilter.TYPE)) {
        filter = new NegativeExactUEIFilter(value);
    } else if (type.equals(NegativeAcknowledgedByFilter.TYPE)) {
        filter = new NegativeAcknowledgedByFilter(value);
    } else if (type.equals(EventIdFilter.TYPE)) {
        filter = new EventIdFilter(WebSecurityUtils.safeParseInt(value));
    } else if (type.equals(EventIdFilter.TYPE)) {
        filter = new EventIdFilter(WebSecurityUtils.safeParseInt(value));
    } else if (type.equals(IPAddrLikeFilter.TYPE)) {
        filter = new IPAddrLikeFilter(value);
    } else if (type.equals(LogMessageSubstringFilter.TYPE)) {
        filter = new LogMessageSubstringFilter(value);
    } else if (type.equals(LogMessageMatchesAnyFilter.TYPE)) {
        filter = new LogMessageMatchesAnyFilter(value);
    } else if (type.equals(BeforeDateFilter.TYPE)) {
        filter = new BeforeDateFilter(WebSecurityUtils.safeParseLong(value));
    } else if (type.equals(AfterDateFilter.TYPE)) {
        filter = new AfterDateFilter(WebSecurityUtils.safeParseLong(value));
    } else if (type.equals(AlarmIDFilter.TYPE)) {
        filter = new AlarmIDFilter(WebSecurityUtils.safeParseInt(value));
    } else if (type.equals(LocationFilter.TYPE)) {
        filter = new LocationFilter(WebSecurityUtils.sanitizeString(value));
    } else if (type.equals(SystemIdFilter.TYPE)) {
        filter = new SystemIdFilter(WebSecurityUtils.sanitizeString(value));
    } else if (type.equals(NegativeLocationFilter.TYPE)) {
        filter = new NegativeLocationFilter(WebSecurityUtils.sanitizeString(value));
    } else if (type.equals(NegativeSystemIdFilter.TYPE)) {
        filter = new NegativeSystemIdFilter(WebSecurityUtils.sanitizeString(value));
    } else if (type.equals(NodeLocationFilter.TYPE)) {
        filter = new NodeLocationFilter(WebSecurityUtils.sanitizeString(value));
    } else if (type.equals(NegativeNodeLocationFilter.TYPE)) {
        filter = new NegativeNodeLocationFilter(WebSecurityUtils.sanitizeString(value));
    }
    return filter;
}
Also used : NegativeServiceFilter(org.opennms.web.event.filter.NegativeServiceFilter) ServiceFilter(org.opennms.web.event.filter.ServiceFilter) InterfaceFilter(org.opennms.web.event.filter.InterfaceFilter) NegativeInterfaceFilter(org.opennms.web.event.filter.NegativeInterfaceFilter) NegativePartialUEIFilter(org.opennms.web.event.filter.NegativePartialUEIFilter) LogMessageSubstringFilter(org.opennms.web.event.filter.LogMessageSubstringFilter) PartialUEIFilter(org.opennms.web.event.filter.PartialUEIFilter) NegativePartialUEIFilter(org.opennms.web.event.filter.NegativePartialUEIFilter) LogMessageMatchesAnyFilter(org.opennms.web.event.filter.LogMessageMatchesAnyFilter) NegativeSeverityFilter(org.opennms.web.event.filter.NegativeSeverityFilter) SystemIdFilter(org.opennms.web.event.filter.SystemIdFilter) NegativeSystemIdFilter(org.opennms.web.event.filter.NegativeSystemIdFilter) NegativeServiceFilter(org.opennms.web.event.filter.NegativeServiceFilter) NegativeAcknowledgedByFilter(org.opennms.web.event.filter.NegativeAcknowledgedByFilter) EventIdFilter(org.opennms.web.event.filter.EventIdFilter) NodeNameLikeFilter(org.opennms.web.event.filter.NodeNameLikeFilter) IPAddrLikeFilter(org.opennms.web.event.filter.IPAddrLikeFilter) NegativeNodeFilter(org.opennms.web.event.filter.NegativeNodeFilter) AlarmIDFilter(org.opennms.web.event.filter.AlarmIDFilter) AcknowledgedByFilter(org.opennms.web.event.filter.AcknowledgedByFilter) NegativeAcknowledgedByFilter(org.opennms.web.event.filter.NegativeAcknowledgedByFilter) NegativeExactUEIFilter(org.opennms.web.event.filter.NegativeExactUEIFilter) ExactUEIFilter(org.opennms.web.event.filter.ExactUEIFilter) NegativeInterfaceFilter(org.opennms.web.event.filter.NegativeInterfaceFilter) BeforeDateFilter(org.opennms.web.event.filter.BeforeDateFilter) NegativeSeverityFilter(org.opennms.web.event.filter.NegativeSeverityFilter) SeverityFilter(org.opennms.web.event.filter.SeverityFilter) NodeLocationFilter(org.opennms.web.event.filter.NodeLocationFilter) NegativeNodeLocationFilter(org.opennms.web.event.filter.NegativeNodeLocationFilter) StringTokenizer(java.util.StringTokenizer) NegativeLocationFilter(org.opennms.web.event.filter.NegativeLocationFilter) NegativeNodeLocationFilter(org.opennms.web.event.filter.NegativeNodeLocationFilter) PartialUEIFilter(org.opennms.web.event.filter.PartialUEIFilter) EventIdFilter(org.opennms.web.event.filter.EventIdFilter) NegativeSeverityFilter(org.opennms.web.event.filter.NegativeSeverityFilter) AcknowledgedByFilter(org.opennms.web.event.filter.AcknowledgedByFilter) NodeLocationFilter(org.opennms.web.event.filter.NodeLocationFilter) SeverityFilter(org.opennms.web.event.filter.SeverityFilter) SystemIdFilter(org.opennms.web.event.filter.SystemIdFilter) NegativeAcknowledgedByFilter(org.opennms.web.event.filter.NegativeAcknowledgedByFilter) InterfaceFilter(org.opennms.web.event.filter.InterfaceFilter) IPAddrLikeFilter(org.opennms.web.event.filter.IPAddrLikeFilter) NegativeExactUEIFilter(org.opennms.web.event.filter.NegativeExactUEIFilter) NegativeServiceFilter(org.opennms.web.event.filter.NegativeServiceFilter) NodeFilter(org.opennms.web.event.filter.NodeFilter) ExactUEIFilter(org.opennms.web.event.filter.ExactUEIFilter) NodeNameLikeFilter(org.opennms.web.event.filter.NodeNameLikeFilter) LocationFilter(org.opennms.web.event.filter.LocationFilter) NegativeSystemIdFilter(org.opennms.web.event.filter.NegativeSystemIdFilter) ServiceFilter(org.opennms.web.event.filter.ServiceFilter) BeforeDateFilter(org.opennms.web.event.filter.BeforeDateFilter) IfIndexFilter(org.opennms.web.event.filter.IfIndexFilter) AfterDateFilter(org.opennms.web.event.filter.AfterDateFilter) NegativeInterfaceFilter(org.opennms.web.event.filter.NegativeInterfaceFilter) AlarmIDFilter(org.opennms.web.event.filter.AlarmIDFilter) NegativeLocationFilter(org.opennms.web.event.filter.NegativeLocationFilter) Filter(org.opennms.web.filter.Filter) LogMessageMatchesAnyFilter(org.opennms.web.event.filter.LogMessageMatchesAnyFilter) NegativeNodeLocationFilter(org.opennms.web.event.filter.NegativeNodeLocationFilter) NegativeNodeFilter(org.opennms.web.event.filter.NegativeNodeFilter) NegativePartialUEIFilter(org.opennms.web.event.filter.NegativePartialUEIFilter) LogMessageSubstringFilter(org.opennms.web.event.filter.LogMessageSubstringFilter) NodeLocationFilter(org.opennms.web.event.filter.NodeLocationFilter) LocationFilter(org.opennms.web.event.filter.LocationFilter) NegativeLocationFilter(org.opennms.web.event.filter.NegativeLocationFilter) NegativeNodeLocationFilter(org.opennms.web.event.filter.NegativeNodeLocationFilter) NegativeExactUEIFilter(org.opennms.web.event.filter.NegativeExactUEIFilter) IfIndexFilter(org.opennms.web.event.filter.IfIndexFilter) NegativeSystemIdFilter(org.opennms.web.event.filter.NegativeSystemIdFilter) NoSuchElementException(java.util.NoSuchElementException) AfterDateFilter(org.opennms.web.event.filter.AfterDateFilter) NodeFilter(org.opennms.web.event.filter.NodeFilter) NegativeNodeFilter(org.opennms.web.event.filter.NegativeNodeFilter)

Aggregations

AcknowledgedByFilter (org.opennms.web.event.filter.AcknowledgedByFilter)3 Date (java.util.Date)2 Test (org.junit.Test)2 EventCriteria (org.opennms.web.event.filter.EventCriteria)2 EventIdFilter (org.opennms.web.event.filter.EventIdFilter)2 NoSuchElementException (java.util.NoSuchElementException)1 StringTokenizer (java.util.StringTokenizer)1 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)1 AfterDateFilter (org.opennms.web.event.filter.AfterDateFilter)1 AlarmIDFilter (org.opennms.web.event.filter.AlarmIDFilter)1 BeforeDateFilter (org.opennms.web.event.filter.BeforeDateFilter)1 ExactUEIFilter (org.opennms.web.event.filter.ExactUEIFilter)1 IPAddrLikeFilter (org.opennms.web.event.filter.IPAddrLikeFilter)1 IfIndexFilter (org.opennms.web.event.filter.IfIndexFilter)1 InterfaceFilter (org.opennms.web.event.filter.InterfaceFilter)1 LocationFilter (org.opennms.web.event.filter.LocationFilter)1 LogMessageMatchesAnyFilter (org.opennms.web.event.filter.LogMessageMatchesAnyFilter)1 LogMessageSubstringFilter (org.opennms.web.event.filter.LogMessageSubstringFilter)1 NegativeAcknowledgedByFilter (org.opennms.web.event.filter.NegativeAcknowledgedByFilter)1 NegativeExactUEIFilter (org.opennms.web.event.filter.NegativeExactUEIFilter)1