Search in sources :

Example 1 with AnyRestriction

use of org.opennms.core.criteria.restrictions.AnyRestriction in project opennms by OpenNMS.

the class QueryManagerDaoImpl method closeOutagesForUnmanagedServices.

/**
     * 
     */
@Override
public void closeOutagesForUnmanagedServices() {
    Date closeDate = new java.util.Date();
    Criteria criteria = new Criteria(OnmsOutage.class);
    criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService", "monitoredService", JoinType.LEFT_JOIN) }));
    criteria.addRestriction(new AnyRestriction(new EqRestriction("monitoredService.status", "D"), new EqRestriction("monitoredService.status", "F"), new EqRestriction("monitoredService.status", "U")));
    criteria.addRestriction(new NullRestriction("ifRegainedService"));
    List<OnmsOutage> outages = m_outageDao.findMatching(criteria);
    for (OnmsOutage outage : outages) {
        outage.setIfRegainedService(closeDate);
        m_outageDao.update(outage);
    }
    criteria = new Criteria(OnmsOutage.class);
    criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN) }));
    criteria.addRestriction(new AnyRestriction(new EqRestriction("ipInterface.isManaged", "F"), new EqRestriction("ipInterface.isManaged", "U")));
    criteria.addRestriction(new NullRestriction("ifRegainedService"));
    outages = m_outageDao.findMatching(criteria);
    for (OnmsOutage outage : outages) {
        outage.setIfRegainedService(closeDate);
        m_outageDao.update(outage);
    }
}
Also used : AnyRestriction(org.opennms.core.criteria.restrictions.AnyRestriction) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) Alias(org.opennms.core.criteria.Alias) EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) NullRestriction(org.opennms.core.criteria.restrictions.NullRestriction) Criteria(org.opennms.core.criteria.Criteria) Date(java.util.Date)

Example 2 with AnyRestriction

use of org.opennms.core.criteria.restrictions.AnyRestriction in project opennms by OpenNMS.

the class BeanWrapperRestrictionVisitor method visitAny.

@Override
public void visitAny(final AnyRestriction restriction) {
    boolean matched = false;
    for (final Restriction r : restriction.getRestrictions()) {
        try {
            r.visit(this);
            matched = true;
            break;
        } catch (final Exception e) {
        }
    }
    if (!matched) {
        fail(restriction);
    }
}
Also used : BetweenRestriction(org.opennms.core.criteria.restrictions.BetweenRestriction) NullRestriction(org.opennms.core.criteria.restrictions.NullRestriction) AllRestriction(org.opennms.core.criteria.restrictions.AllRestriction) GeRestriction(org.opennms.core.criteria.restrictions.GeRestriction) AnyRestriction(org.opennms.core.criteria.restrictions.AnyRestriction) IlikeRestriction(org.opennms.core.criteria.restrictions.IlikeRestriction) InRestriction(org.opennms.core.criteria.restrictions.InRestriction) NotNullRestriction(org.opennms.core.criteria.restrictions.NotNullRestriction) Restriction(org.opennms.core.criteria.restrictions.Restriction) SqlRestriction(org.opennms.core.criteria.restrictions.SqlRestriction) GtRestriction(org.opennms.core.criteria.restrictions.GtRestriction) IplikeRestriction(org.opennms.core.criteria.restrictions.IplikeRestriction) EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) NeRestriction(org.opennms.core.criteria.restrictions.NeRestriction) LikeRestriction(org.opennms.core.criteria.restrictions.LikeRestriction) LeRestriction(org.opennms.core.criteria.restrictions.LeRestriction) NotRestriction(org.opennms.core.criteria.restrictions.NotRestriction) AttributeRestriction(org.opennms.core.criteria.restrictions.AttributeRestriction) LtRestriction(org.opennms.core.criteria.restrictions.LtRestriction)

Aggregations

AnyRestriction (org.opennms.core.criteria.restrictions.AnyRestriction)2 EqRestriction (org.opennms.core.criteria.restrictions.EqRestriction)2 NullRestriction (org.opennms.core.criteria.restrictions.NullRestriction)2 Date (java.util.Date)1 Alias (org.opennms.core.criteria.Alias)1 Criteria (org.opennms.core.criteria.Criteria)1 AllRestriction (org.opennms.core.criteria.restrictions.AllRestriction)1 AttributeRestriction (org.opennms.core.criteria.restrictions.AttributeRestriction)1 BetweenRestriction (org.opennms.core.criteria.restrictions.BetweenRestriction)1 GeRestriction (org.opennms.core.criteria.restrictions.GeRestriction)1 GtRestriction (org.opennms.core.criteria.restrictions.GtRestriction)1 IlikeRestriction (org.opennms.core.criteria.restrictions.IlikeRestriction)1 InRestriction (org.opennms.core.criteria.restrictions.InRestriction)1 IplikeRestriction (org.opennms.core.criteria.restrictions.IplikeRestriction)1 LeRestriction (org.opennms.core.criteria.restrictions.LeRestriction)1 LikeRestriction (org.opennms.core.criteria.restrictions.LikeRestriction)1 LtRestriction (org.opennms.core.criteria.restrictions.LtRestriction)1 NeRestriction (org.opennms.core.criteria.restrictions.NeRestriction)1 NotNullRestriction (org.opennms.core.criteria.restrictions.NotNullRestriction)1 NotRestriction (org.opennms.core.criteria.restrictions.NotRestriction)1