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 TypeMethodDescriptionvoidaddMapping(String auditDSID, String dsID) Add a mapping between an auditDataSourceand auditedDataSourcestatic IntegerGet the "changed fields" field length configured for the givenDataSource.static StringGet the "changed fields" field name configured for the givenDataSource.static StringGet the serverConstructor configured for the givenDataSourcestatic StringGet the revision field name configured for the givenDataSource.static StringGet the audit schema configured for the givenDataSourcestatic StringGet the timestamp field name configured for the givenDataSource.static StringGet the type field name configured for the givenDataSource.static StringGet the user field name configured for the givenDataSource.booleanhasMappingFor(String auditDSID) Returns true if the specified auditDataSourceis already mapped inside theAuditDSGenerator
-
Method Details
-
getAuditRevisionFieldName
Get the revision field name configured for the givenDataSource.- Parameters:
ds- the auditDataSourcefor which we want to retrieve the revision field name.- Returns:
- the field name representing the revision field configured for the audit
DataSourcepassed as parameter.
-
getAuditChangedFieldsFieldName
Get the "changed fields" field name configured for the givenDataSource.- Parameters:
ds- the auditDataSourcefor which we want to retrieve the "changed fields" field name.- Returns:
- the field name representing the "changed fields" field configured for the audit
DataSourcepassed as parameter.
-
getAuditChangedFieldsFieldLength
Get the "changed fields" field length configured for the givenDataSource.- Parameters:
ds- the auditDataSourcefor 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
DataSourcepassed as parameter.
-
getAuditTimestampFieldName
Get the timestamp field name configured for the givenDataSource.- Parameters:
ds- the auditDataSourcefor which we want to retrieve the timestamp field name.- Returns:
- the field name representing the timestamp field configured for the audit
DataSourcepassed as parameter.
-
getAuditTypeFieldName
Get the type field name configured for the givenDataSource.- Parameters:
ds- the auditDataSourcefor which we want to retrieve the type field name.- Returns:
- the field name representing the type field configured for the audit
DataSourcepassed as parameter.
-
getAuditUserFieldName
Get the user field name configured for the givenDataSource.- Parameters:
ds- the auditDataSourcefor which we want to retrieve the user field name.- Returns:
- the field name representing the user field configured for the audit
DataSourcepassed as parameter.
-
getAuditSchemaName
Get the audit schema configured for the givenDataSource- Parameters:
ds- the auditDataSourcefor which we want to retrieve schema name.- Returns:
- the schema name configured for the audit
DataSourcepassed as parameter.
-
getAuditDSConstructor
Get the serverConstructor configured for the givenDataSource- Parameters:
ds- the auditDataSourcefor which we want to retrieve the serverConstructor.- Returns:
- the serverConstructor configured for the audit
DataSourcepassed as parameter.
-
addMapping
Add a mapping between an auditDataSourceand auditedDataSource- Parameters:
auditDSID- the auditDataSourceto be generateddsID- the auditedDataSourcefor which we need to generate the audit DataSource
-
hasMappingFor
Returns true if the specified auditDataSourceis already mapped inside theAuditDSGenerator- Parameters:
auditDSID- auditDSID the auditDataSourceto be generated- Returns:
- true if the audit
DataSourceis already mapped by theAuditDSGenerator
-