Class PreferencesServiceImpl
java.lang.Object
org.openwms.core.preferences.impl.PreferencesServiceImpl
- All Implemented Interfaces:
PreferencesService
A PreferencesServiceImpl is a transactional Spring managed service implementation to manage
Preferences.- Author:
- Heiko Scherrer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.springframework.context.ApplicationContextprivate final PreferenceDaoprivate final FilePreferenceMapperprivate static final org.slf4j.Loggerprivate final PreferencePersistencePortprivate final org.ameba.i18n.Translator -
Constructor Summary
ConstructorsConstructorDescriptionPreferencesServiceImpl(PreferenceDao fileDao, PreferencePersistencePort persistencePort, FilePreferenceMapper filePreferenceMapper, org.ameba.i18n.Translator translator, org.springframework.context.ApplicationContext ctx) -
Method Summary
Modifier and TypeMethodDescription@NotNull Preferencecreate(@NotNull Preference preference) Create a new non-existingPreference.voidDelete an existingPreference.private voidensureUserPreferenceAccess(String owner, PropertyScope scope) booleanexistsForOwnerAndScopeAndKey(String owner, @NotNull PropertyScope scope, @NotBlank String key) Checks whether aPreferenceof a specificscopethat belongs to the givenownerand has the givenkeyexists.@NotNull Collection<Preference> findAll()Find and return allPreferences.@NotNull PreferencefindByPKey(@NotBlank String pKey) Find and return thePreferencesidentified by thepKey.private PreferencefindByPKeyInternal(String pKey) @NotNull Collection<Preference> findForOwnerAndScope(String owner, @NotNull PropertyScope scope) Find and return allPreferencesof a specificscopethat belong to the givenowner.findForOwnerAndScopeAndKey(String owner, @NotNull PropertyScope scope, @NotBlank String key) Find and return thePreferenceof a specificscopethat belongs to the givenownerand has the givenkey.findForScopeOwnerGroupName(String owner, @NotNull PropertyScope scope, @NotBlank String groupName) Find and return allPreferences that belong to a group with the samegroupName.voidLoadPreferencesfrom file and merge them with the ones in the persistent store.private PreferencesaveInternal(Preference preference, PreferencesEvent.Type type) @NotNull Preferenceupdate(@NotBlank String pKey, @NotNull Preference preference) Update the given and existingPreference.private voidverifyDoesNotExist(String owner, PropertyScope scope, String key)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
fileDao
-
persistencePort
-
filePreferenceMapper
-
translator
private final org.ameba.i18n.Translator translator -
ctx
private final org.springframework.context.ApplicationContext ctx
-
-
Constructor Details
-
PreferencesServiceImpl
PreferencesServiceImpl(PreferenceDao fileDao, PreferencePersistencePort persistencePort, FilePreferenceMapper filePreferenceMapper, org.ameba.i18n.Translator translator, org.springframework.context.ApplicationContext ctx)
-
-
Method Details
-
findByPKey
Find and return thePreferencesidentified by thepKey.- Specified by:
findByPKeyin interfacePreferencesService- Parameters:
pKey- The persistent identifier- Returns:
- The instance, never null
-
findByPKeyInternal
-
findAll
Find and return allPreferences.- Specified by:
findAllin interfacePreferencesService- Returns:
- A Collection of Preferences, never null
-
findForOwnerAndScope
@Measured @NotNull public @NotNull Collection<Preference> findForOwnerAndScope(String owner, @NotNull @NotNull PropertyScope scope) Find and return allPreferencesof a specificscopethat belong to the givenowner.- Specified by:
findForOwnerAndScopein 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<Preference> findForOwnerAndScopeAndKey(String owner, @NotNull @NotNull PropertyScope scope, @NotBlank @NotBlank String key) Find and return thePreferenceof a specificscopethat belongs to the givenownerand has the givenkey.- Specified by:
findForOwnerAndScopeAndKeyin 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<Preference> findForScopeOwnerGroupName(String owner, @NotNull @NotNull PropertyScope scope, @NotBlank @NotBlank String groupName) Find and return allPreferences that belong to a group with the samegroupName.- Specified by:
findForScopeOwnerGroupNamein 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 aPreferenceof a specificscopethat belongs to the givenownerand has the givenkeyexists.- Specified by:
existsForOwnerAndScopeAndKeyin 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:
createin interfacePreferencesService- Parameters:
preference- The instance to create- Returns:
- The created instance
-
saveInternal
-
verifyDoesNotExist
-
update
@Measured @NotNull public @NotNull Preference update(@NotBlank @NotBlank String pKey, @NotNull @NotNull Preference preference) Update the given and existingPreference.- Specified by:
updatein 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:
deletein interfacePreferencesService- Parameters:
pKey- The persistent identifier of the Preference to delete.
-
reloadInitialPreferences
@Measured public void reloadInitialPreferences()LoadPreferencesfrom file and merge them with the ones in the persistent store.- Specified by:
reloadInitialPreferencesin interfacePreferencesService
-