use of com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription in project kylo by Teradata.
the class KyloEntityAwareAlertCriteria method createQuery.
public JPAQuery<JpaAlert> createQuery() {
QJpaAlert alert = QJpaAlert.jpaAlert;
QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
QJpaOpsManagerFeed slaFeed = new QJpaOpsManagerFeed("slaFeed");
QJpaServiceLevelAgreementDescription sla = QJpaServiceLevelAgreementDescription.jpaServiceLevelAgreementDescription;
JPAQuery<JpaAlert> query = queryFactory.select(alert).distinct().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).limit(getLimit());
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);
// In all other cases sort descending. The results will be ordered correctly when aggregated by the provider.
if (getLimit() != Integer.MAX_VALUE && getAfterTime() != null && getBeforeTime() == null) {
query.orderBy(alert.createdTime.asc());
} else {
query.orderBy(alert.createdTime.desc());
}
return super.addWhere(query, preds, orFilter);
}
use of com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription 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