use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class NotificationRestService method getCriteriaBuilder.
private static CriteriaBuilder getCriteriaBuilder(final MultivaluedMap<String, String> params) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsNotification.class);
builder.alias("node", "node", JoinType.LEFT_JOIN);
builder.alias("node.snmpInterfaces", "snmpInterface", JoinType.LEFT_JOIN);
builder.alias("node.ipInterfaces", "ipInterface", JoinType.LEFT_JOIN);
builder.alias("event", "event", JoinType.LEFT_JOIN);
builder.alias("usersNotified", "usersNotified", JoinType.LEFT_JOIN);
applyQueryFilters(params, builder);
return builder;
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class NetworkElementFactory method getIpPrimaryAddress.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getIpPrimaryAddress(int)
*/
@Override
public String getIpPrimaryAddress(int nodeId) {
final CriteriaBuilder cb = new CriteriaBuilder(OnmsIpInterface.class);
cb.and(new EqRestriction("node.id", nodeId), new EqRestriction("isSnmpPrimary", PrimaryType.PRIMARY));
final List<OnmsIpInterface> ifaces = m_ipInterfaceDao.findMatching(cb.toCriteria());
if (ifaces.size() > 0) {
final OnmsIpInterface iface = ifaces.get(0);
return InetAddressUtils.str(iface.getIpAddress());
} else {
return null;
}
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class NetworkElementFactory method getNodeLabel.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getNodeLabel(int)
*/
@Override
public String getNodeLabel(int nodeId) {
final CriteriaBuilder cb = new CriteriaBuilder(OnmsNode.class);
cb.eq("id", nodeId);
final List<OnmsNode> nodes = m_nodeDao.findMatching(cb.toCriteria());
if (nodes.size() > 0) {
final OnmsNode node = nodes.get(0);
return node.getLabel();
} else {
return null;
}
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class NetworkElementFactory method getNodesFromPhysaddr.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getNodesFromPhysaddr(java.lang.String)
*/
@Override
public List<OnmsNode> getNodesFromPhysaddr(final String physAddr) {
if (physAddr == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
final CriteriaBuilder builder = new CriteriaBuilder(OnmsNode.class);
builder.alias("snmpInterfaces", "iface").ilike("iface.physAddr", physAddr.replaceAll("[:-]", "")).ne("type", NodeType.DELETED).distinct();
return m_nodeDao.findMatching(builder.toCriteria());
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class BeanWrapperVisitorTest method testFailedGreaterThanWithLessComparison.
@Test
public void testFailedGreaterThanWithLessComparison() {
new CriteriaBuilder(TestBean.class).gt("four", 17d).toCriteria().visit(m_visitor);
assertEquals(0, m_visitor.getMatches().size());
}
Aggregations