Package io.jmix.audit.impl
Class EntityLogImpl
java.lang.Object
io.jmix.audit.impl.EntityLogImpl
- All Implemented Interfaces:
EntityLog
,JpaLifecycleListener
@Component("audit_EntityLog")
public class EntityLogImpl
extends Object
implements EntityLog, JpaLifecycleListener
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected AttributeChangesProvider
protected AuditInfoProvider
protected DatatypeRegistry
protected boolean
protected EntityEventManager
protected ThreadLocal<Boolean>
protected jakarta.persistence.EntityManager
protected EntityStates
protected ExtendedEntities
protected boolean
protected ReentrantReadWriteLock
protected Metadata
protected MetadataTools
protected AuditProperties
protected ReferenceToEntitySupport
static final String
protected Stores
protected TimeSource
protected org.springframework.transaction.support.TransactionTemplate
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncalculateDirtyFields
(Object entity, AttributeChanges changes) protected void
computeChanges
(EntityLogItem itemToSave, List<EntityLogItem> sameEntityList) protected Set<EntityLogAttr>
createLogAttributes
(Object entity, Set<String> attributes, EntityLogItem.Type type, AttributeChanges changes) protected boolean
doNotRegister
(Object entity) protected void
enqueueItem
(EntityLogItem item, String storeName) filterRemovedAttributes
(Object entity, Set<String> attributes) protected String
void
Flush records accumulated by invocations ofEntityLog.registerCreate(Object)
and other registration methods to the database.protected EntityLogItem
generateEntityLogItem
(Object entity, String entityName, Set<String> attributes, EntityLogItem.Type type) getAllAttributes
(Object entity) protected EntityLogAttr
getAttrToSave
(EntityLogAttr entityLogAttr, EntityLogItem itemToSave) protected String
getChanges
(Properties properties) protected EntityLogImpl.EntityLogResourceHolder
protected String
getEntityName
(Object entity) protected String
getIdAttributePath
(MetaPropertyPath propertyPath, String storeName) getLoggedAttributes
(String entity, boolean auto) protected Object
getValueId
(Object value) protected void
protected void
protected EntityLogItem
internalRegisterModify
(Object entity, AttributeChanges changes, MetaClass metaClass, String storeName, Set<String> attributes) void
Invalidates configuration cache.boolean
boolean
protected void
protected void
void
onEntityChange
(Object entity, EntityOp entityOp, AttributeChanges changes) Invoked before entity commit.void
Invoked before committing to data store.protected void
processAttributes
(EntityLogItem itemToSave, List<EntityLogItem> sameEntityList, Set<String> attributes) void
processLoggingForCurrentThread
(boolean enabled) Disables/enables entity logging for current thread.void
registerCreate
(Object entity) Logs creation of an entity which is configured for manual logging (LoggedEntity.auto == false).void
registerCreate
(Object entity, boolean auto) Logs creation of an entity which is configured for auto or manual logging (depending on theauto
parameter).void
registerDelete
(Object entity) Logs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false).void
registerDelete
(Object entity, boolean auto) Logs deletion of an entity which is configured for auto or manual logging (depending on theauto
parameter).void
registerModify
(Object entity) Logs modification of an entity which is configured for manual logging (LoggedEntity.auto == false).void
registerModify
(Object entity, boolean auto) Logs modification of an entity which is configured for auto or manual logging (depending on theauto
parameter).void
registerModify
(Object entity, boolean auto, AttributeChanges changes) Logs modification of an entity which is configured for auto or manual logging (depending on theauto
parameter).protected void
saveItem
(EntityLogItem item) protected void
setAttributeNewValue
(EntityLogAttr entityLogAttr, EntityLogItem itemToSave) protected void
setAttributeOldValue
(EntityLogAttr entityLogAttr, EntityLogItem itemToSave) void
setEnabled
(boolean enabled) void
setProperties
(AuditProperties properties) protected void
setTransactionManager
(org.springframework.transaction.PlatformTransactionManager transactionManager) protected String
stringify
(Object value, MetaProperty metaProperty)
-
Field Details
-
RESOURCE_HOLDER_KEY
-
timeSource
-
metadata
-
metadataTools
-
extendedEntities
-
entityStates
-
auditInfoProvider
-
referenceToEntitySupport
-
stores
-
datatypeRegistry
-
attributeChangesProvider
-
entityEventManager
-
entityManager
protected jakarta.persistence.EntityManager entityManager -
transaction
protected org.springframework.transaction.support.TransactionTemplate transaction -
properties
-
enabled
protected volatile boolean enabled -
loaded
protected volatile boolean loaded -
entitiesManual
-
entitiesAuto
-
lock
-
entityLogSwitchedOn
-
-
Constructor Details
-
EntityLogImpl
public EntityLogImpl()
-
-
Method Details
-
setTransactionManager
@Autowired protected void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) -
setProperties
-
processLoggingForCurrentThread
public void processLoggingForCurrentThread(boolean enabled) Description copied from interface:EntityLog
Disables/enables entity logging for current thread. Enabled by default.- Specified by:
processLoggingForCurrentThread
in interfaceEntityLog
- Parameters:
enabled
- entity logging disabled if false, enabled otherwise.
-
isLoggingForCurrentThread
public boolean isLoggingForCurrentThread()- Specified by:
isLoggingForCurrentThread
in interfaceEntityLog
- Returns:
- whether logging for the current thread is enabled
- See Also:
-
onEntityChange
Description copied from interface:JpaLifecycleListener
Invoked before entity commit.- Specified by:
onEntityChange
in interfaceJpaLifecycleListener
- Parameters:
entity
- entityentityOp
- entity change typechanges
- object describing changes in the entity attributes - null forCREATE
andDELETE
change types
-
onFlush
Description copied from interface:JpaLifecycleListener
Invoked before committing to data store.- Specified by:
onFlush
in interfaceJpaLifecycleListener
- Parameters:
storeName
- name of data store
-
flush
Description copied from interface:EntityLog
Flush records accumulated by invocations ofEntityLog.registerCreate(Object)
and other registration methods to the database. -
computeChanges
-
processAttributes
protected void processAttributes(EntityLogItem itemToSave, List<EntityLogItem> sameEntityList, Set<String> attributes) -
setAttributeOldValue
-
setAttributeNewValue
-
getAttrToSave
-
saveItem
-
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean enabled) - Specified by:
setEnabled
in interfaceEntityLog
-
invalidateCache
public void invalidateCache()Description copied from interface:EntityLog
Invalidates configuration cache. The configuration will be recreated from the database on next lifecycle event.- Specified by:
invalidateCache
in interfaceEntityLog
-
getLoggedAttributes
-
loadEntities
protected void loadEntities() -
getEntityName
-
doNotRegister
-
registerCreate
Description copied from interface:EntityLog
Logs creation of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
registerCreate
in interfaceEntityLog
-
registerCreate
Description copied from interface:EntityLog
Logs creation of an entity which is configured for auto or manual logging (depending on theauto
parameter).- Specified by:
registerCreate
in interfaceEntityLog
-
filterRemovedAttributes
-
internalRegisterCreate
-
findUsername
-
enqueueItem
-
getEntityLogResourceHolder
-
registerModify
Description copied from interface:EntityLog
Logs modification of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
registerModify
in interfaceEntityLog
-
registerModify
Description copied from interface:EntityLog
Logs modification of an entity which is configured for auto or manual logging (depending on theauto
parameter).- Specified by:
registerModify
in interfaceEntityLog
-
registerModify
Description copied from interface:EntityLog
Logs modification of an entity which is configured for auto or manual logging (depending on theauto
parameter).- Specified by:
registerModify
in interfaceEntityLog
changes
- attribute changes provided by caller
-
internalRegisterModify
protected EntityLogItem internalRegisterModify(Object entity, @Nullable AttributeChanges changes, MetaClass metaClass, String storeName, Set<String> attributes) -
createLogAttributes
protected Set<EntityLogAttr> createLogAttributes(Object entity, Set<String> attributes, EntityLogItem.Type type, @Nullable AttributeChanges changes) -
getChanges
-
registerDelete
Description copied from interface:EntityLog
Logs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
registerDelete
in interfaceEntityLog
-
registerDelete
Description copied from interface:EntityLog
Logs deletion of an entity which is configured for auto or manual logging (depending on theauto
parameter).- Specified by:
registerDelete
in interfaceEntityLog
-
internalRegisterDelete
-
generateEntityLogItem
protected EntityLogItem generateEntityLogItem(Object entity, String entityName, Set<String> attributes, EntityLogItem.Type type) -
getAllAttributes
-
getValueId
-
stringify
-
calculateDirtyFields
-
getIdAttributePath
-
logError
-