use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert in project kylo by Teradata.
the class DefaultAlertCriteria method filter.
protected List<Predicate> filter(QJpaAlert alert) {
List<Predicate> preds = new ArrayList<>();
if (getStates().size() > 0) {
preds.add(alert.state.in(getStates()));
}
if (getLevels().size() > 0) {
preds.add(alert.level.in(getLevels()));
}
if (getAfterTime() != null) {
preds.add(alert.createdTime.gt(getAfterTime()));
}
if (getBeforeTime() != null) {
preds.add(alert.createdTime.lt(getBeforeTime()));
}
if (getAfterTime() != null) {
preds.add(alert.createdTime.gt(getAfterTime()));
}
if (getBeforeTime() != null) {
preds.add(alert.createdTime.lt(getBeforeTime()));
}
if (!isIncludeCleared()) {
preds.add(alert.cleared.isFalse());
}
if (getTypes().size() > 0) {
BooleanBuilder likes = new BooleanBuilder();
getTypes().stream().map(uri -> alert.typeString.like(uri.toASCIIString().concat("%"))).forEach(pred -> likes.or(pred));
preds.add(likes);
}
if (getSubtypes().size() > 0) {
preds.add(alert.subtype.in(getSubtypes()));
}
return preds;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert in project kylo by Teradata.
the class DefaultAlertCriteria method orFilter.
protected BooleanBuilder orFilter(QJpaAlert alert) {
BooleanBuilder globalFilter = new BooleanBuilder();
if (StringUtils.isNotBlank(getOrFilter())) {
Lists.newArrayList(StringUtils.split(getOrFilter(), ",")).stream().forEach(filter -> {
filter = StringUtils.trim(filter);
if (filter != null) {
BooleanBuilder booleanBuilder = new BooleanBuilder();
List<Predicate> preds = new ArrayList<>();
try {
Alert.State state = Alert.State.valueOf(filter.toUpperCase());
preds.add(alert.state.eq(state));
} catch (IllegalArgumentException e) {
}
preds.add(alert.typeString.like(filter.concat("%")));
preds.add(alert.subtype.like(filter.concat("%")));
booleanBuilder.andAnyOf(preds.toArray(new Predicate[preds.size()]));
globalFilter.and(booleanBuilder);
}
});
}
return globalFilter;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert in project kylo by Teradata.
the class KyloEntityAwareAlertCriteria method createSummaryQuery.
public JPAQuery<AlertSummary> createSummaryQuery() {
QJpaAlert alert = QJpaAlert.jpaAlert;
QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
QJpaOpsManagerFeed slaFeed = new QJpaOpsManagerFeed("slaFeed");
QJpaServiceLevelAgreementDescription sla = QJpaServiceLevelAgreementDescription.jpaServiceLevelAgreementDescription;
JPAQuery query = queryFactory.select(Projections.bean(KyloEntityAwareAlertSummary.class, alert.typeString.as("type"), alert.subtype.as("subtype"), alert.level.as("level"), feed.id.as("feedId"), feed.name.as("feedName"), sla.slaId.as("slaId"), sla.name.as("slaName"), alert.count().as("count"), alert.createdTimeMillis.max().as("lastAlertTimestamp"))).from(alert).leftJoin(feed).on(feed.id.uuid.eq(alert.entityId.value).and(alert.entityType.eq(Expressions.stringPath("'FEED'")))).leftJoin(sla).on(sla.slaId.uuid.eq(alert.entityId.value).and(alert.entityType.eq(Expressions.stringPath("'SLA'")))).leftJoin(sla.feeds, slaFeed).groupBy(alert.typeString, alert.subtype, feed.id, feed.name, sla.slaId, sla.name, alert.level);
List<Predicate> preds = filter(alert);
boolean entityAccessControlled = !isAsServiceAccount() && controller.isEntityAccessControlled();
preds.add(feed.isNull().or(feed.isNotNull().and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, entityAccessControlled))));
preds.add(slaFeed.isNull().or(slaFeed.isNotNull().and(FeedAclIndexQueryAugmentor.generateExistsExpression(slaFeed.id, entityAccessControlled))));
BooleanBuilder orFilter = orFilter(alert, feed, sla);
addEntityFilter(alert, preds);
return (JPAQuery<AlertSummary>) super.addWhere(query, preds, orFilter);
}
Aggregations