use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert 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.JpaAlert in project kylo by Teradata.
the class DefaultAlertManager method create.
/* (non-Javadoc)
* @see com.thinkbiganalytics.alerts.spi.AlertManager#create(java.net.URI, com.thinkbiganalytics.alerts.api.Alert.Level, java.lang.String, java.io.Serializable)
*/
@Override
public <C extends Serializable> Alert create(URI type, String subtype, Level level, String description, C content) {
final Principal user = SecurityContextHolder.getContext().getAuthentication() != null ? SecurityContextHolder.getContext().getAuthentication() : null;
// reset the subtype if the content is an Entity
if (subtype == null) {
subtype = "Other";
}
if (content != null && content instanceof EntityIdentificationAlertContent) {
subtype = "Entity";
}
final String finalSubType = subtype;
Alert created = this.metadataAccess.commit(() -> {
JpaAlert alert = new JpaAlert(type, finalSubType, level, user, description, content);
this.repository.save(alert);
return asValue(alert);
}, MetadataAccess.SERVICE);
updateLastUpdatedTime();
notifyReceivers(1);
return created;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class DefaultAlertManager method remove.
/* (non-Javadoc)
* @see com.thinkbiganalytics.alerts.spi.AlertManager#remove(com.thinkbiganalytics.alerts.api.Alert.ID)
*/
@Override
public Alert remove(Alert.ID id) {
JpaAlert.AlertId idImpl = (JpaAlert.AlertId) resolve(id);
JpaAlert jpaAlert = this.metadataAccess.commit(() -> {
JpaAlert alert = repository.findOne(idImpl);
this.repository.delete(id);
return alert;
}, MetadataAccess.SERVICE);
updateLastUpdatedTime();
return jpaAlert;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert in project kylo by Teradata.
the class DefaultAlertManager method updateAlertChangeEntry.
protected <C extends Serializable> Alert updateAlertChangeEntry(JpaAlert.AlertId id, String descr, C content) {
final Principal user = SecurityContextHolder.getContext().getAuthentication() != null ? SecurityContextHolder.getContext().getAuthentication() : null;
Alert changed = this.metadataAccess.commit(() -> {
JpaAlert alert = findAlert(id).orElseThrow(() -> new AlertNotfoundException(id));
List<AlertChangeEvent> events = alert.getEvents();
if (events != null && !events.isEmpty()) {
JpaAlertChangeEvent event = (JpaAlertChangeEvent) events.get(0);
event.setDescription(descr);
event.setContent(content);
event.setChangeTime(DateTime.now());
}
return asValue(alert);
}, MetadataAccess.SERVICE);
updateLastUpdatedTime();
notifyReceivers(1);
return changed;
}
use of com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert 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);
}
Aggregations