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
ConstructorDescriptionHistoryDataStoreImpl
(org.slf4j.Logger log, BinaryHashingService hashingService, Context context, BusinessUnitManager businessUnitManager, SecurityManager securityManager, RunEnvironmentService runEnvironmentService, HistoryHibernateConfiguration hibernateConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
checkPermissionForModel
(String entityModel) void
close()
Closes the underlying session factory.void
deleteOldHistoryEntries
(long maximumAge) Deletes all HistoryEntries that are older then maximumAge@Nullable HistorySnapshot
fetch
(long pk) Fetch a specificHistorySnapshot
by primary key.getCount
(HistorySearchParams searchParams) Returns the number ofhistory entries
which apply to the givenHistorySearchParams
.getHistoryEntries
(HistorySearchParams searchParams) Returns a list ofHistoryEntry
instances that are ordered by timestamp (descending).protected HibernatePropertiesBuilder
boolean
hasPermissionForModel
(String entityModel) Returns true if the current user has access to the history of the given entity modelsaveOrUpdateHistoryEntries
(List<HistorySnapshot> historyEntries) Saves the givenHistorySnapshot
instances 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:
getDataSource
in interfaceHistoryDataStore
- Returns:
- the
DataSource
of the history database
-
saveOrUpdateHistoryEntries
Description copied from interface:HistoryDataStore
Saves the givenHistorySnapshot
instances into the store. If theHistorySnapshot
contains an existing primary key, the existing entry is updated.- Specified by:
saveOrUpdateHistoryEntries
in interfaceHistoryDataStore
-
getCount
Description copied from interface:HistoryDataStore
Returns the number ofhistory entries
which apply to the givenHistorySearchParams
.- Specified by:
getCount
in interfaceHistoryDataStore
-
getHistoryEntries
Description copied from interface:HistoryDataStore
Returns a list ofHistoryEntry
instances that are ordered by timestamp (descending).- Specified by:
getHistoryEntries
in interfaceHistoryDataStore
- Parameters:
searchParams
- bean that defines the pagination and filtering of the results
-
deleteOldHistoryEntries
public void deleteOldHistoryEntries(long maximumAge) Description copied from interface:HistoryDataStore
Deletes all HistoryEntries that are older then maximumAge- Specified by:
deleteOldHistoryEntries
in interfaceHistoryDataStore
- Parameters:
maximumAge
- the maximum age of history entries in months
-
fetch
Description copied from interface:HistoryDataStore
Fetch a specificHistorySnapshot
by primary key. The primary key can be obtained from theVersion
object returned byHistoryDataStore.getHistoryEntries(HistorySearchParams)
.- Specified by:
fetch
in interfaceHistoryDataStore
-
hasPermissionForModel
Description copied from interface:HistoryDataStore
Returns true if the current user has access to the history of the given entity model- Specified by:
hasPermissionForModel
in interfaceHistoryDataStore
-
checkPermissionForModel
-
checkHistoryEntryVersionReadPermission
protected void checkHistoryEntryVersionReadPermission() -
close
public void close()Description copied from interface:HistoryDataStore
Closes the underlying session factory.- Specified by:
close
in interfaceHistoryDataStore
-