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