use of org.opennms.core.criteria.restrictions.NullRestriction in project opennms by OpenNMS.
the class QueryManagerDaoImpl method closeOutagesForNode.
/**
* <p>closeOutagesForNode</p>
*
* @param closeDate a {@link java.util.Date} object.
* @param eventId a int.
* @param nodeId a int.
*/
@Override
public void closeOutagesForNode(Date closeDate, int eventId, int nodeId) {
Criteria criteria = new Criteria(OnmsOutage.class);
criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN), new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN) }));
criteria.addRestriction(new EqRestriction("node.id", nodeId));
criteria.addRestriction(new NullRestriction("ifRegainedService"));
List<OnmsOutage> outages = m_outageDao.findMatching(criteria);
for (OnmsOutage outage : outages) {
outage.setIfRegainedService(closeDate);
outage.setServiceRegainedEvent(m_eventDao.get(eventId));
m_outageDao.update(outage);
}
}
use of org.opennms.core.criteria.restrictions.NullRestriction in project opennms by OpenNMS.
the class QueryManagerDaoImpl method closeOutagesForService.
/**
* <p>closeOutagesForService</p>
*
* @param closeDate a {@link java.util.Date} object.
* @param eventId a int.
* @param nodeId a int.
* @param ipAddr a {@link java.lang.String} object.
* @param serviceName a {@link java.lang.String} object.
*/
@Override
public void closeOutagesForService(Date closeDate, int eventId, int nodeId, String ipAddr, String serviceName) {
Criteria criteria = new Criteria(OnmsOutage.class);
criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN), new Alias("monitoredService.serviceType", "serviceType", JoinType.LEFT_JOIN), new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN) }));
criteria.addRestriction(new EqRestriction("node.id", nodeId));
criteria.addRestriction(new EqRestriction("ipInterface.ipAddress", addr(ipAddr)));
criteria.addRestriction(new EqRestriction("serviceType.name", serviceName));
criteria.addRestriction(new NullRestriction("ifRegainedService"));
List<OnmsOutage> outages = m_outageDao.findMatching(criteria);
for (OnmsOutage outage : outages) {
outage.setIfRegainedService(closeDate);
outage.setServiceRegainedEvent(m_eventDao.get(eventId));
m_outageDao.update(outage);
LOG.info("Calling closeOutagesForService: {}", outage);
}
}
use of org.opennms.core.criteria.restrictions.NullRestriction in project opennms by OpenNMS.
the class QueryManagerDaoImpl method closeOutagesForInterface.
/**
* <p>closeOutagesForInterface</p>
*
* @param closeDate a {@link java.util.Date} object.
* @param eventId a int.
* @param nodeId a int.
* @param ipAddr a {@link java.lang.String} object.
*/
@Override
public void closeOutagesForInterface(Date closeDate, int eventId, int nodeId, String ipAddr) {
Criteria criteria = new Criteria(OnmsOutage.class);
criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN), new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN) }));
criteria.addRestriction(new EqRestriction("node.id", nodeId));
criteria.addRestriction(new EqRestriction("ipInterface.ipAddress", addr(ipAddr)));
criteria.addRestriction(new NullRestriction("ifRegainedService"));
List<OnmsOutage> outages = m_outageDao.findMatching(criteria);
for (OnmsOutage outage : outages) {
outage.setIfRegainedService(closeDate);
outage.setServiceRegainedEvent(m_eventDao.get(eventId));
m_outageDao.update(outage);
}
}
use of org.opennms.core.criteria.restrictions.NullRestriction 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);
}
}
Aggregations