Class AuditSearchQuery


  • public class AuditSearchQuery
    extends java.lang.Object

    The AuditSearchQuery object keeps all necessary information to perform query against audit tables via ReadAuditGateway. It allows to search in standard type related audit tables as well as in link related audit tables.

    Underlying implementation of ReadAuditGateway is not known, in other words it may or may not be backed by JDBC storage, thus AuditSearchQuery object keeps only information about Type to be searched and collection of SearchRule objects which are defining which fields in audit table or which attributes/values in audit payload must be searched. Audit data is divided into two parts - standard metadata and payload data which contains exact state of all attributes of audited item. SearchRule object contains method SearchRule.isForPayload() which gives implementor of underlying ReadAuditGateway information about how to search audit records.

    Although this class allows to craft a query which in result reads entire audit table into memory it is highly not recommended. Keep in mind it may causes out of memory errors.

    Examples:

    Query for all audit records for type and pk:
    final AuditSearchQuery query = AuditSearchQuery.forType("MyTypeCode").withSearchRule(ItemPkSearchRule.withPk(pk)).build();

    Simplified version of query for all audit records for type and pk:
    final AuditSearchQuery query = AuditSearchQuery.forType("MyTypeCode").withPkSearchRules(pk).build();

    Query for all audit records for type and several pk's (resulting search must do logical OR):
    final AuditSearchQuery query = AuditSearchQuery.forType("MyTypeCode").withPkSearchRules(pk1, pk2, pk3).build();

    Query for all audit records for type, pk and particular attribute/value in audit payload:
    final AuditSearchQuery query = AuditSearchQuery.forType("MyTypeCode") .withPkSearchRules(pk) .withSearchRule(new PayloadSearchRule("fieldInPayload", "someValue")) .build();

    Simplified version of query for all audit records for type, pk and particular attribute/value in audit payload:
    final AuditSearchQuery query = AuditSearchQuery.forType("MyTypeCode") .withPkSearchRules(pk) .withPayloadSearchRule("fieldInPayload", "someValue") .build();