use of com.walmartlabs.concord.server.jooq.tables.AuditLog in project concord by walmartlabs.
the class AuditDao method list.
public List<AuditLogEntry> list(AuditLogFilter filter) {
return txResult(tx -> {
AuditLog l = AUDIT_LOG.as("l");
Users u = USERS.as("u");
SelectOnConditionStep<Record9<OffsetDateTime, String, String, JSONB, UUID, String, String, String, String>> q = tx.select(l.ENTRY_DATE, l.ENTRY_ACTION, l.ENTRY_OBJECT, l.ENTRY_DETAILS, u.USER_ID, u.USERNAME, u.DOMAIN, u.USER_TYPE, u.DISPLAY_NAME).from(l).leftJoin(u).on(u.USER_ID.eq(l.USER_ID));
AuditObject object = filter.object();
if (object != null) {
q.where(l.ENTRY_OBJECT.eq(object.name()));
}
AuditAction action = filter.action();
if (action != null) {
q.where(l.ENTRY_ACTION.eq(action.name()));
}
UUID userId = filter.userId();
if (userId != null) {
q.where(l.USER_ID.eq(userId));
}
Map<String, Object> details = filter.details();
if (details != null) {
q.where(PgUtils.jsonbContains(l.ENTRY_DETAILS, objectMapper.toJSONB(details)));
}
OffsetDateTime after = filter.after();
if (after != null) {
q.where(l.ENTRY_DATE.greaterThan(after));
}
OffsetDateTime before = filter.before();
if (before != null) {
q.where(l.ENTRY_DATE.lessThan(before));
}
Integer limit = filter.limit();
if (limit != null) {
q.limit(limit);
}
Integer offset = filter.offset();
if (offset != null) {
q.offset(offset);
}
q.orderBy(l.ENTRY_DATE.desc(), l.ENTRY_SEQ.desc());
return q.fetch(this::toEntry);
});
}
Aggregations