Search in sources :

Example 91 with CriteriaBuilder

use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.

the class EnLinkdElementFactory method getFromPhysAddress.

private OnmsSnmpInterface getFromPhysAddress(String physAddress) {
    final CriteriaBuilder builder = new CriteriaBuilder(OnmsSnmpInterface.class);
    builder.eq("physAddr", physAddress);
    final List<OnmsSnmpInterface> nodes = m_snmpInterfaceDao.findMatching(builder.toCriteria());
    if (nodes.size() == 1)
        return nodes.get(0);
    return null;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Example 92 with CriteriaBuilder

use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.

the class NodeTableCellStyleGenerator method getAlarm.

public OnmsAlarm getAlarm(int nodeId) {
    CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class);
    builder.alias("node", "node");
    builder.ne("severity", OnmsSeverity.CLEARED);
    builder.orderBy("severity").desc();
    builder.eq("node.id", nodeId);
    builder.limit(Integer.valueOf(1));
    List<OnmsAlarm> alarms = alarmDao.findMatching(builder.toCriteria());
    return alarms == null || alarms.isEmpty() ? null : alarms.get(0);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm)

Example 93 with CriteriaBuilder

use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.

the class MockNodeDao method findAllByVarCharAssetColumn.

@Override
public List<OnmsNode> findAllByVarCharAssetColumn(final String columnName, final String columnValue) {
    final CriteriaBuilder builder = new CriteriaBuilder(OnmsNode.class);
    builder.alias("assetRecord", "assets");
    builder.eq("assets." + columnName, columnValue);
    return findMatching(builder.toCriteria());
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder)

Example 94 with CriteriaBuilder

use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.

the class BeanWrapperVisitorTest method testLessThan.

@Test
public void testLessThan() {
    new CriteriaBuilder(TestBean.class).lt("one", 2.0f).toCriteria().visit(m_visitor);
    assertEquals(1, m_visitor.getMatches().size());
    m_visitor.reset();
    new CriteriaBuilder(TestBean.class).lt("one", 2.99999d).toCriteria().visit(m_visitor);
    assertEquals(1, m_visitor.getMatches().size());
    m_visitor.reset();
    new CriteriaBuilder(TestBean.class).lt("four", 5.9999f).toCriteria().visit(m_visitor);
    assertEquals(1, m_visitor.getMatches().size());
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) Test(org.junit.Test)

Example 95 with CriteriaBuilder

use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.

the class BeanWrapperVisitorTest method testNullFromNotNullRestriction.

@Test
public void testNullFromNotNullRestriction() {
    new CriteriaBuilder(TestBean.class).isNotNull("nullValue").toCriteria().visit(m_visitor);
    assertEquals(0, m_visitor.getMatches().size());
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) Test(org.junit.Test)

Aggregations

CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)155 Test (org.junit.Test)60 Criteria (org.opennms.core.criteria.Criteria)31 OnmsNode (org.opennms.netmgt.model.OnmsNode)25 Transactional (org.springframework.transaction.annotation.Transactional)23 Date (java.util.Date)20 GET (javax.ws.rs.GET)13 ArrayList (java.util.ArrayList)12 Produces (javax.ws.rs.Produces)12 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)11 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)11 InetSocketAddress (java.net.InetSocketAddress)9 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)7 HibernateDaoFactory (org.opennms.smoketest.utils.HibernateDaoFactory)7 OnmsMinion (org.opennms.netmgt.model.minion.OnmsMinion)6 RateLimiter (com.google.common.util.concurrent.RateLimiter)4 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)4 EventDao (org.opennms.netmgt.dao.api.EventDao)4 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)4 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)4