Class PreferencesServiceImpl

java.lang.Object
org.openwms.core.preferences.impl.jpa.PreferencesServiceImpl
All Implemented Interfaces:
PreferencesService

@Validated @TxService class PreferencesServiceImpl extends Object implements PreferencesService
A PreferencesServiceImpl is a transactional Spring managed service implementation to manage Preferences.
Author:
Heiko Scherrer
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • fileDao

      private final PreferenceDao fileDao
    • preferenceRepository

      private final PreferenceRepository 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

      @Measured @NotNull public @NotNull PreferenceEO findByPKey(@NotBlank @NotBlank String pKey)
      Find and return the Preferences identified by the pKey.
      Specified by:
      findByPKey in interface PreferencesService
      Parameters:
      pKey - The persistent identifier
      Returns:
      The instance, never null
    • findByPKeyInternal

      private PreferenceEO findByPKeyInternal(String pKey)
    • findAll

      @Measured @NotNull public @NotNull Collection<PreferenceEO> findAll()
      Find and return all Preferences.
      Specified by:
      findAll in interface PreferencesService
      Returns:
      A Collection of Preferences, never null
    • findForOwnerAndScope

      @Measured @NotNull public @NotNull Collection<PreferenceEO> findForOwnerAndScope(String owner, @NotNull @NotNull PropertyScope scope)
      Find and return all Preferences of a specific scope that belong to the given owner.
      Specified by:
      findForOwnerAndScope in interface PreferencesService
      Parameters:
      owner - The owner of the Preference
      scope - What kind of Preference it is
      Returns:
      A Collection of Preferences, never null
    • ensureUserPreferenceAccess

      private void ensureUserPreferenceAccess(String owner, PropertyScope scope)
    • findForOwnerAndScopeAndKey

      @Measured public Optional<PreferenceEO> findForOwnerAndScopeAndKey(String owner, @NotNull @NotNull PropertyScope scope, @NotBlank @NotBlank String key)
      Find and return the Preference of a specific scope that belongs to the given owner and has the given key.
      Specified by:
      findForOwnerAndScopeAndKey in interface PreferencesService
      Parameters:
      owner - The owner of the Preference
      scope - What kind of Preference it is
      key - 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 all Preferences that belong to a group with the same groupName.
      Specified by:
      findForScopeOwnerGroupName in interface PreferencesService
      Parameters:
      owner - The owner of the Preference
      scope - What kind of Preference it is
      groupName - 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 a Preference of a specific scope that belongs to the given owner and has the given key exists.
      Specified by:
      existsForOwnerAndScopeAndKey in interface PreferencesService
      Parameters:
      owner - The owner of the Preference
      scope - What kind of Preference it is
      key - The Preference key
      Returns:
      true if it does exist, otherwise false
    • create

      @Measured @NotNull public @NotNull PreferenceEO create(@NotNull @NotNull PreferenceEO preference)
      Create a new non-existing Preference.
      Specified by:
      create in interface PreferencesService
      Parameters:
      preference - The instance to create
      Returns:
      The created instance
    • saveInternal

      private PreferenceEO saveInternal(PreferenceEO preference, PreferencesEvent.Type type)
    • verifyDoesNotExist

      private void verifyDoesNotExist(String owner, PropertyScope scope, String key)
    • update

      @Measured @NotNull public @NotNull PreferenceEO update(@NotBlank @NotBlank String pKey, @NotNull @NotNull PreferenceEO preference)
      Update the given and existing Preference.
      Specified by:
      update in interface PreferencesService
      Parameters:
      pKey - The persistent identifier of the Preference to save
      preference - The Preference instance to save
      Returns:
      Saved instance
    • delete

      @Measured public void delete(@NotBlank @NotBlank String pKey)
      Delete an existing Preference.
      Specified by:
      delete in interface PreferencesService
      Parameters:
      pKey - The persistent identifier of the Preference to delete.
    • reloadInitialPreferences

      @Measured public void reloadInitialPreferences()
      Load Preferences from file and merge them with the ones in the persistent store.
      Specified by:
      reloadInitialPreferences in interface PreferencesService