Package com.isomorphic.datasource
Class AuditDSGenerator
java.lang.Object
com.isomorphic.datasource.AuditDSGenerator
- All Implemented Interfaces:
DynamicDSGenerator
,com.isomorphic.datasource.FrameworkDynamicDSGenerator
public class AuditDSGenerator extends Object implements com.isomorphic.datasource.FrameworkDynamicDSGenerator
This class implements a
DynamicDSGenerator
which generates an audit DataSource
based on a DataSource
which has auditing enabled. An audit DataSource
is a DataSource
which basically inherits from the original DataSource
and adds some additional metadata which allows storing the timestamp, revision, user and operation type in addition to record field values on each add, update and remove operations.
In order to enable audit for a DataSource
you have to specify the audit=true property.
There are additional properties which can be specified in order to control how the new fields are named:
- auditUserFieldName - specify the field name used to store the user who performed the operation. If empty string is specified as value, then this field won't be created. Default value is user.
- auditRevisionFieldName - specify the field name used to store the revision information. If empty string is specified as value, then this field won't be created. Default value is revision.
- auditTimeStampFieldName - specify the field name used to store the timestamp of the operation. If empty string is specified as value, then this field won't be created. Default value is timestamp.
- auditTypeFieldName - specify the field name used to store the operation type. If empty string is specified as value, then this field won't be created. Default value is type.
- auditDataSourceID - the id of the generated
DataSource
. Default value is audit_[OriginalDSID].
In addition to this, setting audit=false property on a field will disable tracking on that field. In effect, the field won't be stored in the audit DataSource
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapping
(String auditDSID, String dsID) Add a mapping between an auditDataSource
and auditedDataSource
static Integer
Get the "changed fields" field length configured for the givenDataSource
.static String
Get the "changed fields" field name configured for the givenDataSource
.static String
Get the serverConstructor configured for the givenDataSource
static String
Get the revision field name configured for the givenDataSource
.static String
Get the audit schema configured for the givenDataSource
static String
Get the timestamp field name configured for the givenDataSource
.static String
Get the type field name configured for the givenDataSource
.static String
Get the user field name configured for the givenDataSource
.boolean
hasMappingFor
(String auditDSID) Returns true if the specified auditDataSource
is already mapped inside theAuditDSGenerator
-
Method Details
-
getAuditRevisionFieldName
Get the revision field name configured for the givenDataSource
.- Parameters:
ds
- the auditDataSource
for which we want to retrieve the revision field name.- Returns:
- the field name representing the revision field configured for the audit
DataSource
passed as parameter.
-
getAuditChangedFieldsFieldName
Get the "changed fields" field name configured for the givenDataSource
.- Parameters:
ds
- the auditDataSource
for which we want to retrieve the "changed fields" field name.- Returns:
- the field name representing the "changed fields" field configured for the audit
DataSource
passed as parameter.
-
getAuditChangedFieldsFieldLength
Get the "changed fields" field length configured for the givenDataSource
.- Parameters:
ds
- the auditDataSource
for which we want to retrieve the "changed fields" field length.- Returns:
- the configured or default length to use for the "changed fields" field for the audit
DataSource
passed as parameter.
-
getAuditTimestampFieldName
Get the timestamp field name configured for the givenDataSource
.- Parameters:
ds
- the auditDataSource
for which we want to retrieve the timestamp field name.- Returns:
- the field name representing the timestamp field configured for the audit
DataSource
passed as parameter.
-
getAuditTypeFieldName
Get the type field name configured for the givenDataSource
.- Parameters:
ds
- the auditDataSource
for which we want to retrieve the type field name.- Returns:
- the field name representing the type field configured for the audit
DataSource
passed as parameter.
-
getAuditUserFieldName
Get the user field name configured for the givenDataSource
.- Parameters:
ds
- the auditDataSource
for which we want to retrieve the user field name.- Returns:
- the field name representing the user field configured for the audit
DataSource
passed as parameter.
-
getAuditSchemaName
Get the audit schema configured for the givenDataSource
- Parameters:
ds
- the auditDataSource
for which we want to retrieve schema name.- Returns:
- the schema name configured for the audit
DataSource
passed as parameter.
-
getAuditDSConstructor
Get the serverConstructor configured for the givenDataSource
- Parameters:
ds
- the auditDataSource
for which we want to retrieve the serverConstructor.- Returns:
- the serverConstructor configured for the audit
DataSource
passed as parameter.
-
addMapping
Add a mapping between an auditDataSource
and auditedDataSource
- Parameters:
auditDSID
- the auditDataSource
to be generateddsID
- the auditedDataSource
for which we need to generate the audit DataSource
-
hasMappingFor
Returns true if the specified auditDataSource
is already mapped inside theAuditDSGenerator
- Parameters:
auditDSID
- auditDSID the auditDataSource
to be generated- Returns:
- true if the audit
DataSource
is already mapped by theAuditDSGenerator
-