Package io.jmix.audit.snapshot.impl
Class EntitySnapshotManagerImpl
java.lang.Object
io.jmix.audit.snapshot.impl.EntitySnapshotManagerImpl
- All Implemented Interfaces:
EntitySnapshotManager
@Component("audit_EntitySnapshotManager")
public class EntitySnapshotManagerImpl
extends Object
implements EntitySnapshotManager
-
Constructor Summary
ConstructorDescriptionEntitySnapshotManagerImpl
(ExtendedEntities extendedEntities, UnconstrainedDataManager unconstrainedDataManager, FetchPlans fetchPlans, MetadataTools metadataTools, Metadata metadata, ReferenceToEntitySupport referenceToEntitySupport, TimeSource timeSource, CurrentAuthentication currentAuthentication, EntitySerialization entitySerialization, FetchPlanSerialization fetchPlanSerialization, EntitySnapshotDataStore entitySnapshotDataStore) -
Method Summary
Modifier and TypeMethodDescriptioncreateSnapshot
(Object entity, FetchPlan fetchPlan) Create snapshot for Entity and store it to databasecreateSnapshot
(Object entity, FetchPlan fetchPlan, Date snapshotDate) Create snapshot for Entity with specific date and store it to databasecreateSnapshot
(Object entity, FetchPlan fetchPlan, Date snapshotDate, String authorUsername) Create snapshot for Entity with specific date and author and store it to databasecreateTempSnapshot
(Object entity, FetchPlan fetchPlan) Creates non-persistent snapshot for entity.createTempSnapshot
(Object entity, FetchPlan fetchPlan, Date snapshotDate) Creates non-persistent snapshot for entity with a specific date.createTempSnapshot
(Object entity, FetchPlan fetchPlan, Date snapshotDate, String authorUsername) Creates non-persistent snapshot for entity with a specific date and author.extractEntity
(EntitySnapshotModel snapshot) Restore entity by snapshotextractFetchPlan
(EntitySnapshotModel snapshot) Restore fetch plan from snapshotgetLastEntitySnapshot
(MetaClass metaClass, Object referenceId) Get the last snapshot for the given entity by id.getLastEntitySnapshot
(Object entity) Get the last snapshot for the given entity.getSnapshots
(MetaClass metaClass, Object id) Load snapshots for entitygetSnapshots
(Object entity) Get snapshots for entityvoid
Translate snapshots for archival classes
-
Constructor Details
-
EntitySnapshotManagerImpl
public EntitySnapshotManagerImpl(ExtendedEntities extendedEntities, UnconstrainedDataManager unconstrainedDataManager, FetchPlans fetchPlans, MetadataTools metadataTools, Metadata metadata, ReferenceToEntitySupport referenceToEntitySupport, TimeSource timeSource, CurrentAuthentication currentAuthentication, EntitySerialization entitySerialization, FetchPlanSerialization fetchPlanSerialization, EntitySnapshotDataStore entitySnapshotDataStore)
-
-
Method Details
-
getSnapshots
Description copied from interface:EntitySnapshotManager
Load snapshots for entity- Specified by:
getSnapshots
in interfaceEntitySnapshotManager
- Parameters:
metaClass
- Entity metaclassid
- Entity Id- Returns:
- Snapshot list sorted by snapshotDate desc
-
getSnapshots
Description copied from interface:EntitySnapshotManager
Get snapshots for entity- Specified by:
getSnapshots
in interfaceEntitySnapshotManager
- Parameters:
entity
- Entity object- Returns:
- Snapshot list
-
migrateSnapshots
Description copied from interface:EntitySnapshotManager
Translate snapshots for archival classes- Specified by:
migrateSnapshots
in interfaceEntitySnapshotManager
- Parameters:
metaClass
- Metaclassid
- Entity IdclassMapping
- Map of [OldClass -> NewClass] for migration
-
createSnapshot
Description copied from interface:EntitySnapshotManager
Create snapshot for Entity and store it to database- Specified by:
createSnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- EntityfetchPlan
- FetchPlan- Returns:
- Snapshot
-
createSnapshot
Description copied from interface:EntitySnapshotManager
Create snapshot for Entity with specific date and store it to database- Specified by:
createSnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- EntityfetchPlan
- FetchPlansnapshotDate
- Date- Returns:
- Snapshot
-
createSnapshot
public EntitySnapshotModel createSnapshot(Object entity, FetchPlan fetchPlan, Date snapshotDate, String authorUsername) Description copied from interface:EntitySnapshotManager
Create snapshot for Entity with specific date and author and store it to database- Specified by:
createSnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- EntityfetchPlan
- FetchPlansnapshotDate
- DateauthorUsername
- Author- Returns:
- Snapshot
-
extractEntity
Description copied from interface:EntitySnapshotManager
Restore entity by snapshot- Specified by:
extractEntity
in interfaceEntitySnapshotManager
- Parameters:
snapshot
- Snapshot- Returns:
- Entity instance
-
extractFetchPlan
Description copied from interface:EntitySnapshotManager
Restore fetch plan from snapshot- Specified by:
extractFetchPlan
in interfaceEntitySnapshotManager
- Parameters:
snapshot
- Snapshot- Returns:
- FetchPlan instance
-
getLastEntitySnapshot
Description copied from interface:EntitySnapshotManager
Get the last snapshot for the given entity. This method always starts a new transaction. It can be used for entities with composite key if they have UUID.- Specified by:
getLastEntitySnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- entity- Returns:
- snapshot or null if there is no snapshots in database for the given entity
-
getLastEntitySnapshot
Description copied from interface:EntitySnapshotManager
Get the last snapshot for the given entity by id. This method always starts a new transaction.- Specified by:
getLastEntitySnapshot
in interfaceEntitySnapshotManager
- Parameters:
metaClass
- entity meta classreferenceId
- reference id for which snapshot refers- Returns:
- snapshot or null if there is no snapshots in database for the given entity
-
createTempSnapshot
Description copied from interface:EntitySnapshotManager
Creates non-persistent snapshot for entity. It can be used for entities with composite key if they have UUID.- Specified by:
createTempSnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- entityfetchPlan
- fetchPlan- Returns:
- not persistence snapshot
-
createTempSnapshot
public EntitySnapshotModel createTempSnapshot(Object entity, FetchPlan fetchPlan, Date snapshotDate) Description copied from interface:EntitySnapshotManager
Creates non-persistent snapshot for entity with a specific date. It can be used for entities with composite key if they have UUID.- Specified by:
createTempSnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- entityfetchPlan
- entity fetch plansnapshotDate
- date- Returns:
- not persistence snapshot
-
createTempSnapshot
public EntitySnapshotModel createTempSnapshot(Object entity, FetchPlan fetchPlan, Date snapshotDate, String authorUsername) Description copied from interface:EntitySnapshotManager
Creates non-persistent snapshot for entity with a specific date and author. It can be used for entities with composite key if they have UUID.- Specified by:
createTempSnapshot
in interfaceEntitySnapshotManager
- Parameters:
entity
- entityfetchPlan
- entity fetch plansnapshotDate
- dateauthorUsername
- author- Returns:
- not persistence snapshot
-