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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AttributeChangesProviderprotected AuditInfoProviderprotected CurrentUserSubstitutionprotected DatatypeRegistryprotected booleanprotected EntityEventManagerprotected ThreadLocal<Boolean>protected jakarta.persistence.EntityManagerprotected EntityStatesprotected ExtendedEntitiesprotected booleanprotected ReentrantReadWriteLockprotected Metadataprotected MetadataToolsprotected AuditPropertiesprotected ReferenceToEntitySupportstatic final Stringprotected Storesprotected TimeSourceprotected org.springframework.transaction.support.TransactionTemplate -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalculateDirtyFields(Object entity, AttributeChanges changes) protected voidcomputeChanges(EntityLogItem itemToSave, List<EntityLogItem> sameEntityList) protected Set<EntityLogAttr>createLogAttributes(Object entity, Set<String> attributes, EntityLogItem.Type type, AttributeChanges changes) protected booleandoNotRegister(Object entity) protected voidenqueueItem(EntityLogItem item, String storeName) filterRemovedAttributes(Object entity, Set<String> attributes) protected Stringprotected StringvoidFlush records accumulated by invocations ofEntityLog.registerCreate(Object)and other registration methods to the database.protected EntityLogItemgenerateEntityLogItem(Object entity, String entityName, Set<String> attributes, EntityLogItem.Type type) getAllAttributes(Object entity) protected EntityLogAttrgetAttrToSave(EntityLogAttr entityLogAttr, EntityLogItem itemToSave) protected StringgetChanges(Properties properties) protected EntityLogImpl.EntityLogResourceHolderprotected StringgetEntityName(Object entity) protected StringgetIdAttributePath(MetaPropertyPath propertyPath, String storeName) getLoggedAttributes(String entity, boolean auto) protected ObjectgetValueId(Object value) protected voidprotected voidprotected EntityLogIteminternalRegisterModify(Object entity, AttributeChanges changes, MetaClass metaClass, String storeName, Set<String> attributes) voidInvalidates configuration cache.booleanbooleanprotected voidprotected voidvoidonEntityChange(Object entity, EntityOp entityOp, AttributeChanges changes) Invoked before entity commit.voidInvoked before committing to data store.protected voidprocessAttributes(EntityLogItem itemToSave, List<EntityLogItem> sameEntityList, Set<String> attributes) voidprocessLoggingForCurrentThread(boolean enabled) Disables/enables entity logging for current thread.voidregisterCreate(Object entity) Logs creation of an entity which is configured for manual logging (LoggedEntity.auto == false).voidregisterCreate(Object entity, boolean auto) Logs creation of an entity which is configured for auto or manual logging (depending on theautoparameter).voidregisterDelete(Object entity) Logs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false).voidregisterDelete(Object entity, boolean auto) Logs deletion of an entity which is configured for auto or manual logging (depending on theautoparameter).voidregisterModify(Object entity) Logs modification of an entity which is configured for manual logging (LoggedEntity.auto == false).voidregisterModify(Object entity, boolean auto) Logs modification of an entity which is configured for auto or manual logging (depending on theautoparameter).voidregisterModify(Object entity, boolean auto, AttributeChanges changes) Logs modification of an entity which is configured for auto or manual logging (depending on theautoparameter).protected voidsaveItem(EntityLogItem item) protected voidsetAttributeNewValue(EntityLogAttr entityLogAttr, EntityLogItem itemToSave) protected voidsetAttributeOldValue(EntityLogAttr entityLogAttr, EntityLogItem itemToSave) voidsetEnabled(boolean enabled) voidsetProperties(AuditProperties properties) protected voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) protected Stringstringify(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 -
currentUserSubstitution
-
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:EntityLogDisables/enables entity logging for current thread. Enabled by default.- Specified by:
processLoggingForCurrentThreadin interfaceEntityLog- Parameters:
enabled- entity logging disabled if false, enabled otherwise.
-
isLoggingForCurrentThread
public boolean isLoggingForCurrentThread()- Specified by:
isLoggingForCurrentThreadin interfaceEntityLog- Returns:
- whether logging for the current thread is enabled
- See Also:
-
onEntityChange
Description copied from interface:JpaLifecycleListenerInvoked before entity commit.- Specified by:
onEntityChangein interfaceJpaLifecycleListener- Parameters:
entity- entityentityOp- entity change typechanges- object describing changes in the entity attributes - null forCREATEandDELETEchange types
-
onFlush
Description copied from interface:JpaLifecycleListenerInvoked before committing to data store.- Specified by:
onFlushin interfaceJpaLifecycleListener- Parameters:
storeName- name of data store
-
flush
Description copied from interface:EntityLogFlush 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:
setEnabledin interfaceEntityLog
-
invalidateCache
public void invalidateCache()Description copied from interface:EntityLogInvalidates configuration cache. The configuration will be recreated from the database on next lifecycle event.- Specified by:
invalidateCachein interfaceEntityLog
-
getLoggedAttributes
-
loadEntities
protected void loadEntities() -
getEntityName
-
doNotRegister
-
registerCreate
Description copied from interface:EntityLogLogs creation of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
registerCreatein interfaceEntityLog
-
registerCreate
Description copied from interface:EntityLogLogs creation of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
registerCreatein interfaceEntityLog
-
filterRemovedAttributes
-
internalRegisterCreate
-
findUsername
-
findSubstitutedUsername
-
enqueueItem
-
getEntityLogResourceHolder
-
registerModify
Description copied from interface:EntityLogLogs modification of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
registerModifyin interfaceEntityLog
-
registerModify
Description copied from interface:EntityLogLogs modification of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
registerModifyin interfaceEntityLog
-
registerModify
Description copied from interface:EntityLogLogs modification of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
registerModifyin interfaceEntityLogchanges- 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:EntityLogLogs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
registerDeletein interfaceEntityLog
-
registerDelete
Description copied from interface:EntityLogLogs deletion of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
registerDeletein interfaceEntityLog
-
internalRegisterDelete
-
generateEntityLogItem
protected EntityLogItem generateEntityLogItem(Object entity, String entityName, Set<String> attributes, EntityLogItem.Type type) -
getAllAttributes
-
getValueId
-
stringify
-
calculateDirtyFields
-
getIdAttributePath
-
logError
-