Class HistoryDataStoreImpl
java.lang.Object
ch.tocco.nice2.persist.history.impl.store.HistoryDataStoreImpl
- All Implemented Interfaces:
HistoryDataStore
Initializes a separate
SessionFactory for the history database using the
properties of the 'hikaricp.history.properties'.
Provides functionality to write to and read from the history data store.-
Constructor Summary
ConstructorsConstructorDescriptionHistoryDataStoreImpl(org.slf4j.Logger log, BinaryHashingService hashingService, Context context, BusinessUnitManager businessUnitManager, SecurityManager securityManager, RunEnvironmentService runEnvironmentService, HistoryHibernateConfiguration hibernateConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidcheckPermissionForModel(String entityModel) voidclose()Closes the underlying session factory.voiddeleteOldHistoryEntries(long maximumAge) Deletes all HistoryEntries that are older then maximumAge@Nullable HistorySnapshotfetch(long pk) Fetch a specificHistorySnapshotby primary key.getCount(HistorySearchParams searchParams) Returns the number ofhistory entrieswhich apply to the givenHistorySearchParams.getHistoryEntries(HistorySearchParams searchParams) Returns a list ofHistoryEntryinstances that are ordered by timestamp (descending).protected HibernatePropertiesBuilderbooleanhasPermissionForModel(String entityModel) Returns true if the current user has access to the history of the given entity modelsaveOrUpdateHistoryEntries(List<HistorySnapshot> historyEntries) Saves the givenHistorySnapshotinstances into the store.void
-
Constructor Details
-
HistoryDataStoreImpl
public HistoryDataStoreImpl(org.slf4j.Logger log, BinaryHashingService hashingService, Context context, BusinessUnitManager businessUnitManager, SecurityManager securityManager, RunEnvironmentService runEnvironmentService, HistoryHibernateConfiguration hibernateConfiguration)
-
-
Method Details
-
setHistoryEnabled
@Value("${nice2.persist.history.persistence.state}") public void setHistoryEnabled(HistoryDataStoreState state) -
getSettings
-
getDataSource
- Specified by:
getDataSourcein interfaceHistoryDataStore- Returns:
- the
DataSourceof the history database
-
saveOrUpdateHistoryEntries
Description copied from interface:HistoryDataStoreSaves the givenHistorySnapshotinstances into the store. If theHistorySnapshotcontains an existing primary key, the existing entry is updated.- Specified by:
saveOrUpdateHistoryEntriesin interfaceHistoryDataStore
-
getCount
Description copied from interface:HistoryDataStoreReturns the number ofhistory entrieswhich apply to the givenHistorySearchParams.- Specified by:
getCountin interfaceHistoryDataStore
-
getHistoryEntries
Description copied from interface:HistoryDataStoreReturns a list ofHistoryEntryinstances that are ordered by timestamp (descending).- Specified by:
getHistoryEntriesin interfaceHistoryDataStore- Parameters:
searchParams- bean that defines the pagination and filtering of the results
-
deleteOldHistoryEntries
public void deleteOldHistoryEntries(long maximumAge) Description copied from interface:HistoryDataStoreDeletes all HistoryEntries that are older then maximumAge- Specified by:
deleteOldHistoryEntriesin interfaceHistoryDataStore- Parameters:
maximumAge- the maximum age of history entries in months
-
fetch
Description copied from interface:HistoryDataStoreFetch a specificHistorySnapshotby primary key. The primary key can be obtained from theVersionobject returned byHistoryDataStore.getHistoryEntries(HistorySearchParams).- Specified by:
fetchin interfaceHistoryDataStore
-
hasPermissionForModel
Description copied from interface:HistoryDataStoreReturns true if the current user has access to the history of the given entity model- Specified by:
hasPermissionForModelin interfaceHistoryDataStore
-
checkPermissionForModel
-
checkHistoryEntryVersionReadPermission
protected void checkHistoryEntryVersionReadPermission() -
close
public void close()Description copied from interface:HistoryDataStoreCloses the underlying session factory.- Specified by:
closein interfaceHistoryDataStore
-