public class ValidityAuditStrategy extends Object implements AuditStrategy
This algorithm works as follows:
This has a few important consequences that need to be judged against against each other:
Constructor and Description |
---|
ValidityAuditStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder,
Parameters parameters,
String revisionProperty,
String revisionEndProperty,
boolean addAlias,
MiddleIdData referencingIdData,
String versionsMiddleEntityName,
String eeOriginalIdPropertyPath,
String revisionPropertyPath,
String originalIdPropertyName,
String alias1,
boolean inclusive,
MiddleComponentData... componentDatas)
Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a middle-entity
association.
|
void |
addEntityAtRevisionRestriction(GlobalConfiguration globalCfg,
QueryBuilder rootQueryBuilder,
Parameters parameters,
String revisionProperty,
String revisionEndProperty,
boolean addAlias,
MiddleIdData idData,
String revisionPropertyPath,
String originalIdPropertyName,
String alias1,
String alias2,
boolean inclusive)
Update the rootQueryBuilder with an extra WHERE clause to restrict the revision for a two-entity relation.
|
void |
perform(Session session,
String entityName,
EnversService enversService,
Serializable id,
Object data,
Object revision)
Perform the persistence of audited data for regular entities.
|
void |
performCollectionChange(Session session,
String entityName,
String propertyName,
EnversService enversService,
PersistentCollectionChangeData persistentCollectionChangeData,
Object revision)
Perform the persistence of audited data for collection ("middle") entities.
|
void |
setRevisionTimestampGetter(Getter revisionTimestampGetter) |
public void perform(Session session, String entityName, EnversService enversService, Serializable id, Object data, Object revision)
AuditStrategy
perform
in interface AuditStrategy
session
- Session, which can be used to persist the data.entityName
- Name of the entity, in which the audited change happensenversService
- The EnversServiceid
- Id of the entity.data
- Audit data to persistrevision
- Current revision datapublic void performCollectionChange(Session session, String entityName, String propertyName, EnversService enversService, PersistentCollectionChangeData persistentCollectionChangeData, Object revision)
AuditStrategy
performCollectionChange
in interface AuditStrategy
session
- Session, which can be used to persist the data.entityName
- Name of the entity, in which the audited change happens.propertyName
- The name of the property holding the persistent collectionenversService
- The EnversServicepersistentCollectionChangeData
- Collection change data to be persisted.revision
- Current revision datapublic void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg, QueryBuilder rootQueryBuilder, Parameters parameters, String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData idData, String revisionPropertyPath, String originalIdPropertyName, String alias1, String alias2, boolean inclusive)
AuditStrategy
DefaultAuditStrategy
a subquery is created:
e.revision = (SELECT max(...) ...)
ValidityAuditStrategy
the revision-end column is used:
e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)
addEntityAtRevisionRestriction
in interface AuditStrategy
globalCfg
- the GlobalConfiguration
rootQueryBuilder
- the QueryBuilder
that will be updatedparameters
- root parameters to which restrictions shall be addedrevisionProperty
- property of the revision columnrevisionEndProperty
- property of the revisionEnd column (only used for ValidityAuditStrategy
)addAlias
- boolean
indicator if a left alias is neededidData
- id-information for the two-entity relation (only used for DefaultAuditStrategy
)revisionPropertyPath
- path of the revision property (only used for ValidityAuditStrategy
)originalIdPropertyName
- name of the id property (only used for ValidityAuditStrategy
)alias1
- an alias used for subquery (only used for ValidityAuditStrategy
)alias2
- an alias used for subquery (only used for ValidityAuditStrategy
)inclusive
- indicates whether revision number shall be treated as inclusive or exclusivepublic void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder, Parameters parameters, String revisionProperty, String revisionEndProperty, boolean addAlias, MiddleIdData referencingIdData, String versionsMiddleEntityName, String eeOriginalIdPropertyPath, String revisionPropertyPath, String originalIdPropertyName, String alias1, boolean inclusive, MiddleComponentData... componentDatas)
AuditStrategy
DefaultAuditStrategy
a subquery is created:
e.revision = (SELECT max(...) ...)
ValidityAuditStrategy
the revision-end column is used:
e.revision <= :revision and (e.endRevision > :revision or e.endRevision is null)
addAssociationAtRevisionRestriction
in interface AuditStrategy
rootQueryBuilder
- the QueryBuilder
that will be updatedparameters
- root parameters to which restrictions shall be addedrevisionProperty
- property of the revision columnrevisionEndProperty
- property of the revisionEnd column (only used for ValidityAuditStrategy
)addAlias
- boolean
indicator if a left alias is neededreferencingIdData
- id-information for the middle-entity association (only used for DefaultAuditStrategy
)versionsMiddleEntityName
- name of the middle-entityeeOriginalIdPropertyPath
- name of the id property (only used for ValidityAuditStrategy
)revisionPropertyPath
- path of the revision property (only used for ValidityAuditStrategy
)originalIdPropertyName
- name of the id property (only used for ValidityAuditStrategy
)alias1
- an alias used for subqueries (only used for DefaultAuditStrategy
)inclusive
- indicates whether revision number shall be treated as inclusive or exclusivecomponentDatas
- information about the middle-entity relationpublic void setRevisionTimestampGetter(Getter revisionTimestampGetter)
Copyright © 2001-2017 Red Hat, Inc. All Rights Reserved.