use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert in project kylo by Teradata.
the class DefaultAlertCriteria method createQuery.
public JPAQuery<JpaAlert> createQuery() {
QJpaAlert alert = QJpaAlert.jpaAlert;
JPAQuery<JpaAlert> query = queryFactory.select(alert).from(alert).limit(getLimit());
List<Predicate> preds = filter(alert);
BooleanBuilder orFilter = orFilter(alert);
// 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 addWhere(query, preds, orFilter);
}
use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert in project kylo by Teradata.
the class DefaultAlertCriteria method createSummaryQuery.
public JPAQuery<AlertSummary> createSummaryQuery() {
QJpaAlert alert = QJpaAlert.jpaAlert;
JPAQuery query = queryFactory.select(Projections.bean(DefaultAlertSummary.class, alert.typeString.as("type"), alert.subtype.as("subtype"), alert.level.as("level"), alert.count().as("count"), alert.createdTimeMillis.max().as("lastAlertTimestamp"))).from(alert).groupBy(alert.typeString, alert.subtype, alert.level);
List<Predicate> preds = filter(alert);
BooleanBuilder orFilter = orFilter(alert);
return (JPAQuery<AlertSummary>) addWhere(query, preds, orFilter);
}
use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert 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.alerts.QJpaAlert in project kylo by Teradata.
the class KyloEntityAwareAlertCriteria method createEntityQuery.
public JPAQuery<JpaAlert> createEntityQuery() {
QJpaAlert alert = QJpaAlert.jpaAlert;
JPAQuery<JpaAlert> query = queryFactory.select(alert).from(alert).limit(getLimit());
List<Predicate> preds = filter(alert);
addEntityFilter(alert, preds);
if (entityCriteria == null || entityCriteria.isEmpty()) {
log.warn("Unable to apply Entity Query. No Entity Criteria was specified!");
preds.add(Expressions.stringTemplate("1").eq(Expressions.stringTemplate("2")));
}
return super.addWhere(query, preds, new BooleanBuilder());
}
use of com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert in project kylo by Teradata.
the class KyloEntityAwareAlertCriteria method orFilter.
private BooleanBuilder orFilter(QJpaAlert alert, QJpaOpsManagerFeed feed, QJpaServiceLevelAgreementDescription sla) {
BooleanBuilder globalFilter = new BooleanBuilder();
if (StringUtils.isNotBlank(getOrFilter())) {
Lists.newArrayList(StringUtils.split(getOrFilter(), ",")).stream().forEach(filter -> {
filter = StringUtils.trim(filter);
if (filter != null) {
List<String> in = null;
if (filter.contains("||")) {
// replace the OR || with commas for IN clause
in = Arrays.asList(StringUtils.split(filter, "||")).stream().map(f -> StringUtils.trim(f)).collect(Collectors.toList());
filter = in.stream().collect(Collectors.joining(","));
}
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) {
}
if (in != null) {
preds.add(alert.description.in(in));
preds.add(alert.entityType.in(in));
preds.add(alert.typeString.in(in));
preds.add(alert.subtype.in(in));
// add in joins on the feed or sla name
addOrFilter(feed, CommonFilterTranslations.feedFilters, preds, filter);
addOrFilter(sla, KyloEntityAwareAlertManager.alertSlaFilters, preds, filter);
} else {
preds.add(alert.description.likeIgnoreCase(filter.concat("%")));
preds.add(alert.entityType.likeIgnoreCase(filter.concat("%")));
preds.add(alert.typeString.likeIgnoreCase(filter.concat("%")));
preds.add(alert.subtype.like(filter.concat("%")));
// add in joins on the feed or sla name
addOrFilter(feed, CommonFilterTranslations.feedFilters, preds, filter);
addOrFilter(sla, KyloEntityAwareAlertManager.alertSlaFilters, preds, filter);
}
booleanBuilder.andAnyOf(preds.toArray(new Predicate[preds.size()]));
globalFilter.and(booleanBuilder);
}
});
}
return globalFilter;
}
Aggregations