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