Package org.cyclos.impl.system
Interface EntityLogHandler<E extends SimpleEntity,DTO extends EntityDTO>
-
public interface EntityLogHandler<E extends SimpleEntity,DTO extends EntityDTO>To enable the log for an entity an implementation of this interface must be created.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidapplyLogFilters(DBQuery<?> query, EntityPropertyLogQuery params)Apply filters to the given query to ensure only the entity log the logged user can view are returnedbooleanareEquals(E oldEntity, E newEntity, PropertyAccess access, Object oldValue, Object newValue)Returns true if the old and new values extracted from its corresponding entities must be considered equals.booleancanViewEntityLog(long entityId)Returns whether the logged user can view the log of the given entity.booleancanViewPropertiesLog(EntityLog entityLog)Returns true if the logged user can view the properties log of the givenEntityLog.Class<E>getEntityClass()The entity class related to this handlerStringgetEntityLogName(E oldEntity, E newEntity, EntityLogEvent event)Return the name of the entity log being generated.StringgetEntityLogNamePrefix(E oldEntity, E newEntity)Return the name prefix of the entity log being generated.LonggetRelatedEntityId(E entity)The related entity is used to resolve a custom filter associated to the type managed by this handler when performing a general search.BasicUsergetRelatedUser(E entity)Subclasses can implement this method to return the related user of the entity.EntityLogTypegetType()The log type this handler manages.Pair<Object,Object>getValues(E oldEntity, E newEntity, PropertyLogDescriptor<DTO> propertyDescriptor)Allows custom logic for a specific property to be logged bypassing the default log generation for it.booleanisAsManager(E entity)booleanisLogEnabled(E entity)Returns true if the log is enabled for this specific entity instance.booleanisPrivateEntity(E entity)Return true if the given entity was marked as privateList<EntityPropertyLog>onBeforeLog(E oldEntity, E newEntity, List<EntityPropertyLog> propertyLogs, EntityLogEvent event)Allows perform custom logic before logging (i.e saving) the given property logs.EntityLogDescriptor<? extends DTO>resolveLogDescriptor(E entity)Return the descriptor with the mappings for each DTO property.
-
-
-
Method Detail
-
applyLogFilters
void applyLogFilters(DBQuery<?> query, EntityPropertyLogQuery params)
Apply filters to the given query to ensure only the entity log the logged user can view are returned
-
areEquals
boolean areEquals(E oldEntity, E newEntity, PropertyAccess access, Object oldValue, Object newValue)
Returns true if the old and new values extracted from its corresponding entities must be considered equals.
-
canViewEntityLog
boolean canViewEntityLog(long entityId)
Returns whether the logged user can view the log of the given entity.
-
canViewPropertiesLog
boolean canViewPropertiesLog(EntityLog entityLog)
Returns true if the logged user can view the properties log of the givenEntityLog. If the given entityLog's entity was removed, it checks if there is an owner entity and if it is visible.
-
getEntityLogName
String getEntityLogName(E oldEntity, E newEntity, EntityLogEvent event)
Return the name of the entity log being generated.
-
getEntityLogNamePrefix
String getEntityLogNamePrefix(E oldEntity, E newEntity)
Return the name prefix of the entity log being generated.
-
getRelatedEntityId
Long getRelatedEntityId(E entity)
The related entity is used to resolve a custom filter associated to the type managed by this handler when performing a general search. E.g. when searching for record changes of a specific record type (see an example implementation in RecordEntityLogHandlerImpl).
-
getRelatedUser
BasicUser getRelatedUser(E entity)
Subclasses can implement this method to return the related user of the entity. Returns the associated user to the given entity.
-
getType
EntityLogType getType()
The log type this handler manages.
-
getValues
Pair<Object,Object> getValues(E oldEntity, E newEntity, PropertyLogDescriptor<DTO> propertyDescriptor)
Allows custom logic for a specific property to be logged bypassing the default log generation for it.- Returns:
- null for the default generation (i.e no custom logic implemented) or a pair of the form
<old_value, new_value> to be saved as-is only if
areEquals(SimpleEntity, SimpleEntity, PropertyAccess, Object, Object)returns false.
-
isAsManager
boolean isAsManager(E entity)
-
isLogEnabled
boolean isLogEnabled(E entity)
Returns true if the log is enabled for this specific entity instance.
-
isPrivateEntity
boolean isPrivateEntity(E entity)
Return true if the given entity was marked as private
-
onBeforeLog
List<EntityPropertyLog> onBeforeLog(E oldEntity, E newEntity, List<EntityPropertyLog> propertyLogs, EntityLogEvent event)
Allows perform custom logic before logging (i.e saving) the given property logs. The returned list will be final logs to be saved (subclasses can add / remove logs). In case ofEntityLogEvent.CREATEevent the result list will contain only one element, this is for that case we only log one line just to indicate when and who created the entity.
-
resolveLogDescriptor
EntityLogDescriptor<? extends DTO> resolveLogDescriptor(E entity)
Return the descriptor with the mappings for each DTO property.
-
-