Class PreferencesServiceImpl
java.lang.Object
org.openwms.core.preferences.impl.jpa.PreferencesServiceImpl
- All Implemented Interfaces:
PreferencesService
A PreferencesServiceImpl is a transactional Spring managed service implementation to manage
Preferences
.- Author:
- Heiko Scherrer
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.springframework.context.ApplicationContext
private final PreferenceDao
private static final org.slf4j.Logger
private final org.ameba.mapping.BeanMapper
private final PreferenceRepository
private final org.ameba.i18n.Translator
-
Constructor Summary
ConstructorDescriptionPreferencesServiceImpl
(PreferenceDao fileDao, PreferenceRepository preferenceRepository, org.ameba.mapping.BeanMapper mapper, org.ameba.i18n.Translator translator, org.springframework.context.ApplicationContext ctx) -
Method Summary
Modifier and TypeMethodDescription@NotNull PreferenceEO
create
(@NotNull PreferenceEO preference) Create a new non-existingPreference
.void
Delete an existingPreference
.private void
ensureUserPreferenceAccess
(String owner, PropertyScope scope) boolean
existsForOwnerAndScopeAndKey
(String owner, @NotNull PropertyScope scope, @NotBlank String key) Checks whether aPreference
of a specificscope
that belongs to the givenowner
and has the givenkey
exists.@NotNull Collection
<PreferenceEO> findAll()
Find and return allPreferences
.@NotNull PreferenceEO
findByPKey
(@NotBlank String pKey) Find and return thePreferences
identified by thepKey
.private PreferenceEO
findByPKeyInternal
(String pKey) @NotNull Collection
<PreferenceEO> findForOwnerAndScope
(String owner, @NotNull PropertyScope scope) Find and return allPreferences
of a specificscope
that belong to the givenowner
.findForOwnerAndScopeAndKey
(String owner, @NotNull PropertyScope scope, @NotBlank String key) Find and return thePreference
of a specificscope
that belongs to the givenowner
and has the givenkey
.findForScopeOwnerGroupName
(String owner, @NotNull PropertyScope scope, @NotBlank String groupName) Find and return allPreference
s that belong to a group with the samegroupName
.void
LoadPreferences
from file and merge them with the ones in the persistent store.private PreferenceEO
saveInternal
(PreferenceEO preference, PreferencesEvent.Type type) @NotNull PreferenceEO
update
(@NotBlank String pKey, @NotNull PreferenceEO preference) Update the given and existingPreference
.private void
verifyDoesNotExist
(String owner, PropertyScope scope, String key)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
fileDao
-
preferenceRepository
-
mapper
private final org.ameba.mapping.BeanMapper mapper -
translator
private final org.ameba.i18n.Translator translator -
ctx
private final org.springframework.context.ApplicationContext ctx
-
-
Constructor Details
-
PreferencesServiceImpl
PreferencesServiceImpl(PreferenceDao fileDao, PreferenceRepository preferenceRepository, org.ameba.mapping.BeanMapper mapper, org.ameba.i18n.Translator translator, org.springframework.context.ApplicationContext ctx)
-
-
Method Details
-
findByPKey
Find and return thePreferences
identified by thepKey
.- Specified by:
findByPKey
in interfacePreferencesService
- Parameters:
pKey
- The persistent identifier- Returns:
- The instance, never null
-
findByPKeyInternal
-
findAll
Find and return allPreferences
.- Specified by:
findAll
in interfacePreferencesService
- Returns:
- A Collection of Preferences, never null
-
findForOwnerAndScope
@Measured @NotNull public @NotNull Collection<PreferenceEO> findForOwnerAndScope(String owner, @NotNull @NotNull PropertyScope scope) Find and return allPreferences
of a specificscope
that belong to the givenowner
.- Specified by:
findForOwnerAndScope
in interfacePreferencesService
- Parameters:
owner
- The owner of the Preferencescope
- What kind of Preference it is- Returns:
- A Collection of Preferences, never null
-
ensureUserPreferenceAccess
-
findForOwnerAndScopeAndKey
@Measured public Optional<PreferenceEO> findForOwnerAndScopeAndKey(String owner, @NotNull @NotNull PropertyScope scope, @NotBlank @NotBlank String key) Find and return thePreference
of a specificscope
that belongs to the givenowner
and has the givenkey
.- Specified by:
findForOwnerAndScopeAndKey
in interfacePreferencesService
- Parameters:
owner
- The owner of the Preferencescope
- What kind of Preference it iskey
- The Preference key- Returns:
- A Collection of Preferences, never null
-
findForScopeOwnerGroupName
@Measured public List<PreferenceEO> findForScopeOwnerGroupName(String owner, @NotNull @NotNull PropertyScope scope, @NotBlank @NotBlank String groupName) Find and return allPreference
s that belong to a group with the samegroupName
.- Specified by:
findForScopeOwnerGroupName
in interfacePreferencesService
- Parameters:
owner
- The owner of the Preferencescope
- What kind of Preference it isgroupName
- The name of the group- Returns:
- All instances, never null
-
existsForOwnerAndScopeAndKey
@Measured public boolean existsForOwnerAndScopeAndKey(String owner, @NotNull @NotNull PropertyScope scope, @NotBlank @NotBlank String key) Checks whether aPreference
of a specificscope
that belongs to the givenowner
and has the givenkey
exists.- Specified by:
existsForOwnerAndScopeAndKey
in interfacePreferencesService
- Parameters:
owner
- The owner of the Preferencescope
- What kind of Preference it iskey
- The Preference key- Returns:
- true if it does exist, otherwise false
-
create
Create a new non-existingPreference
.- Specified by:
create
in interfacePreferencesService
- Parameters:
preference
- The instance to create- Returns:
- The created instance
-
saveInternal
-
verifyDoesNotExist
-
update
@Measured @NotNull public @NotNull PreferenceEO update(@NotBlank @NotBlank String pKey, @NotNull @NotNull PreferenceEO preference) Update the given and existingPreference
.- Specified by:
update
in interfacePreferencesService
- Parameters:
pKey
- The persistent identifier of the Preference to savepreference
- The Preference instance to save- Returns:
- Saved instance
-
delete
Delete an existingPreference
.- Specified by:
delete
in interfacePreferencesService
- Parameters:
pKey
- The persistent identifier of the Preference to delete.
-
reloadInitialPreferences
@Measured public void reloadInitialPreferences()LoadPreferences
from file and merge them with the ones in the persistent store.- Specified by:
reloadInitialPreferences
in interfacePreferencesService
-