Search in sources :

Example 1 with NullRestriction

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);
    }
}
Also used : 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)

Example 2 with NullRestriction

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);
    }
}
Also used : 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)

Example 3 with NullRestriction

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);
    }
}
Also used : 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)

Example 4 with NullRestriction

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

Aggregations

Alias (org.opennms.core.criteria.Alias)4 Criteria (org.opennms.core.criteria.Criteria)4 EqRestriction (org.opennms.core.criteria.restrictions.EqRestriction)4 NullRestriction (org.opennms.core.criteria.restrictions.NullRestriction)4 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)4 Date (java.util.Date)1 AnyRestriction (org.opennms.core.criteria.restrictions.AnyRestriction)1