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 SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AttributeChangesProviderprotected AuditInfoProviderprotected 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 SummaryConstructors
- 
Method SummaryModifier 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 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
- 
entityManagerprotected jakarta.persistence.EntityManager entityManager
- 
transactionprotected org.springframework.transaction.support.TransactionTemplate transaction
- 
properties
- 
enabledprotected volatile boolean enabled
- 
loadedprotected volatile boolean loaded
- 
entitiesManual
- 
entitiesAuto
- 
lock
- 
entityLogSwitchedOn
 
- 
- 
Constructor Details- 
EntityLogImplpublic EntityLogImpl()
 
- 
- 
Method Details- 
setTransactionManager@Autowired protected void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) 
- 
setProperties
- 
processLoggingForCurrentThreadpublic void processLoggingForCurrentThread(boolean enabled) Description copied from interface:EntityLogDisables/enables entity logging for current thread. Enabled by default.- Specified by:
- processLoggingForCurrentThreadin interface- EntityLog
- Parameters:
- enabled- entity logging disabled if false, enabled otherwise.
 
- 
isLoggingForCurrentThreadpublic boolean isLoggingForCurrentThread()- Specified by:
- isLoggingForCurrentThreadin interface- EntityLog
- Returns:
- whether logging for the current thread is enabled
- See Also:
 
- 
onEntityChangeDescription copied from interface:JpaLifecycleListenerInvoked before entity commit.- Specified by:
- onEntityChangein interface- JpaLifecycleListener
- Parameters:
- entity- entity
- entityOp- entity change type
- changes- object describing changes in the entity attributes - null for- CREATEand- DELETEchange types
 
- 
onFlushDescription copied from interface:JpaLifecycleListenerInvoked before committing to data store.- Specified by:
- onFlushin interface- JpaLifecycleListener
- Parameters:
- storeName- name of data store
 
- 
flushDescription copied from interface:EntityLogFlush records accumulated by invocations ofEntityLog.registerCreate(Object)and other registration methods to the database.
- 
computeChanges
- 
processAttributesprotected void processAttributes(EntityLogItem itemToSave, List<EntityLogItem> sameEntityList, Set<String> attributes) 
- 
setAttributeOldValue
- 
setAttributeNewValue
- 
getAttrToSave
- 
saveItem
- 
isEnabledpublic boolean isEnabled()
- 
setEnabledpublic void setEnabled(boolean enabled) - Specified by:
- setEnabledin interface- EntityLog
 
- 
invalidateCachepublic void invalidateCache()Description copied from interface:EntityLogInvalidates configuration cache. The configuration will be recreated from the database on next lifecycle event.- Specified by:
- invalidateCachein interface- EntityLog
 
- 
getLoggedAttributes
- 
loadEntitiesprotected void loadEntities()
- 
getEntityName
- 
doNotRegister
- 
registerCreateDescription copied from interface:EntityLogLogs creation of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
- registerCreatein interface- EntityLog
 
- 
registerCreateDescription copied from interface:EntityLogLogs creation of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
- registerCreatein interface- EntityLog
 
- 
filterRemovedAttributes
- 
internalRegisterCreate
- 
findUsername
- 
enqueueItem
- 
getEntityLogResourceHolder
- 
registerModifyDescription copied from interface:EntityLogLogs modification of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
- registerModifyin interface- EntityLog
 
- 
registerModifyDescription copied from interface:EntityLogLogs modification of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
- registerModifyin interface- EntityLog
 
- 
registerModifyDescription copied from interface:EntityLogLogs modification of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
- registerModifyin interface- EntityLog
- changes- attribute changes provided by caller
 
- 
internalRegisterModifyprotected EntityLogItem internalRegisterModify(Object entity, @Nullable AttributeChanges changes, MetaClass metaClass, String storeName, Set<String> attributes) 
- 
createLogAttributesprotected Set<EntityLogAttr> createLogAttributes(Object entity, Set<String> attributes, EntityLogItem.Type type, @Nullable AttributeChanges changes) 
- 
getChanges
- 
registerDeleteDescription copied from interface:EntityLogLogs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false).- Specified by:
- registerDeletein interface- EntityLog
 
- 
registerDeleteDescription copied from interface:EntityLogLogs deletion of an entity which is configured for auto or manual logging (depending on theautoparameter).- Specified by:
- registerDeletein interface- EntityLog
 
- 
internalRegisterDelete
- 
generateEntityLogItemprotected EntityLogItem generateEntityLogItem(Object entity, String entityName, Set<String> attributes, EntityLogItem.Type type) 
- 
getAllAttributes
- 
getValueId
- 
stringify
- 
calculateDirtyFields
- 
getIdAttributePath
- 
logError
 
-