use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class AlarmsDashlet method addComponents.
/**
* Adds the alarms components to a {@link com.vaadin.ui.AbstractOrderedLayout}
*
* @param component the component to add alarms to
* @param alarms the alarms list
*/
private void addComponents(AbstractOrderedLayout component, List<OnmsAlarm> alarms) {
if (alarms.size() == 0) {
Label label = new Label("No alarms found!");
label.addStyleName("alerts-noalarms-font");
component.addComponent(label);
} else {
for (OnmsAlarm onmsAlarm : alarms) {
OnmsNode onmsNode = null;
if (onmsAlarm.getNodeId() != null) {
CriteriaBuilder nodeCb = new CriteriaBuilder(OnmsNode.class);
nodeCb.eq("id", onmsAlarm.getNodeId());
List<OnmsNode> nodes = m_nodeDao.findMatching(nodeCb.toCriteria());
if (nodes.size() == 1) {
onmsNode = nodes.get(0);
}
}
component.addComponent(createAlarmComponent(onmsAlarm, onmsNode));
OnmsSeverity boostSeverity = OnmsSeverity.valueOf(getDashletSpec().getParameters().get("boostSeverity"));
if (onmsAlarm.getSeverity().isGreaterThanOrEqual(boostSeverity)) {
boosted = true;
}
}
}
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class SummaryDashlet method countBySeverity.
/**
* Searches for alarms with the given criterias and returns the number found.
*
* @param acknowledged search for acknowledged or unacknowledged alarms
* @param age the age of the alarms
* @param onmsSeverity the {@link OnmsSeverity} to search for
* @return number of alarms found
*/
public int countBySeverity(boolean acknowledged, long age, OnmsSeverity onmsSeverity) {
CriteriaBuilder criteriaBuilder = new CriteriaBuilder(OnmsAlarm.class);
if (acknowledged) {
criteriaBuilder.isNotNull("alarmAckUser");
} else {
criteriaBuilder.isNull("alarmAckUser");
}
criteriaBuilder.eq("severity", onmsSeverity);
criteriaBuilder.sql("EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - lastEventTime) < ?", age, Type.LONG);
return m_alarmDao.countMatching(criteriaBuilder.toCriteria());
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class SummaryDashlet method countByUei.
/**
* Searches for alarms with the given criterias and returns the number found.
*
* @param acknowledged search for acknowledged or unacknowledged alarms
* @param age the age of the alarms
* @param uei search for alarms with the specified uei
* @return number of alarms found
*/
public int countByUei(boolean acknowledged, long age, String uei) {
CriteriaBuilder criteriaBuilder = new CriteriaBuilder(OnmsAlarm.class);
if (acknowledged) {
criteriaBuilder.isNotNull("alarmAckUser");
} else {
criteriaBuilder.isNull("alarmAckUser");
}
criteriaBuilder.eq("uei", uei);
criteriaBuilder.sql("EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - lastEventTime) < ?", age, Type.LONG);
return m_alarmDao.countMatching(criteriaBuilder.toCriteria());
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class ApplicationRestService method getCriteriaBuilder.
@Override
protected CriteriaBuilder getCriteriaBuilder(UriInfo uriInfo) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsApplication.class);
// Order by application name by default
builder.orderBy("name").asc();
return builder;
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class IfServiceRestService method getCriteriaBuilder.
@Override
protected CriteriaBuilder getCriteriaBuilder(final UriInfo uriInfo) {
final CriteriaBuilder builder = new CriteriaBuilder(getDaoClass());
// 1st level JOINs
builder.alias("ipInterface", Aliases.ipInterface.toString(), JoinType.LEFT_JOIN);
builder.alias("serviceType", Aliases.serviceType.toString(), JoinType.LEFT_JOIN);
// 2nd level JOINs
builder.alias(Aliases.ipInterface.prop("node"), Aliases.node.toString(), JoinType.LEFT_JOIN);
builder.alias(Aliases.ipInterface.prop("snmpInterface"), Aliases.snmpInterface.toString(), JoinType.LEFT_JOIN);
// 3rd level JOINs
builder.alias(Aliases.node.prop("assetRecord"), Aliases.assetRecord.toString(), JoinType.LEFT_JOIN);
builder.alias(Aliases.node.prop("location"), Aliases.location.toString(), JoinType.LEFT_JOIN);
// TODO: Only add this alias when filtering so that we can specify a join condition
// builder.alias("node.categories", Aliases.category.toString(), JoinType.LEFT_JOIN);
builder.orderBy("id");
return builder;
}
Aggregations