Search in sources :

Example 1 with QJpaServiceLevelAgreementDescription

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);
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) BooleanBuilder(com.querydsl.core.BooleanBuilder) QJpaServiceLevelAgreementDescription(com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription) JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert) QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) Predicate(com.querydsl.core.types.Predicate)

Example 2 with QJpaServiceLevelAgreementDescription

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);
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) BooleanBuilder(com.querydsl.core.BooleanBuilder) QJpaServiceLevelAgreementDescription(com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription) JPAQuery(com.querydsl.jpa.impl.JPAQuery) Predicate(com.querydsl.core.types.Predicate)

Aggregations

BooleanBuilder (com.querydsl.core.BooleanBuilder)2 Predicate (com.querydsl.core.types.Predicate)2 QJpaAlert (com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert)2 QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)2 QJpaServiceLevelAgreementDescription (com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription)2 JPAQuery (com.querydsl.jpa.impl.JPAQuery)1 JpaAlert (com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert)1