Interface SettingsService


public interface SettingsService
Service API for settings.
Since:
2.0
Version:
2.2
Author:
matt
  • Field Details

    • SYSTEM_PROP_SETTING_RESOURCE_DIR

      static final String SYSTEM_PROP_SETTING_RESOURCE_DIR
      The system property for the setting resource directory.
      Since:
      1.4
      See Also:
    • DEFAULT_SETTING_RESOURCE_DIR

      static final String DEFAULT_SETTING_RESOURCE_DIR
      The default setting resource directory, if SYSTEM_PROP_SETTING_RESOURCE_DIR is not defined.
      Since:
      1.4
      See Also:
    • TOPIC_UPDATE_SETTING

      static final String TOPIC_UPDATE_SETTING
      The instruction topic for a request to update (create or change) a setting value.
      Since:
      1.3
      See Also:
    • PARAM_UPDATE_SETTING_KEY

      static final String PARAM_UPDATE_SETTING_KEY
      The instruction parameter for setting key.
      Since:
      1.3
      See Also:
    • PARAM_UPDATE_SETTING_TYPE

      static final String PARAM_UPDATE_SETTING_TYPE
      The instruction parameter for setting type.
      Since:
      1.3
      See Also:
    • PARAM_UPDATE_SETTING_VALUE

      static final String PARAM_UPDATE_SETTING_VALUE
      The instruction parameter for setting value.
      Since:
      1.3
      See Also:
    • PARAM_UPDATE_SETTING_FLAGS

      static final String PARAM_UPDATE_SETTING_FLAGS
      The instruction parameter for setting flags.
      Since:
      1.3
      See Also:
  • Method Details

    • settingResourceDirectory

      static Path settingResourceDirectory()
      Get the path to the setting resource directory.

      This is the directory where external setting resources can be persisted. If the system property SYSTEM_PROP_SETTING_RESOURCE_DIR is defined as an absolute path, that path is used directly. Otherwise SYSTEM_PROP_SETTING_RESOURCE_DIR is treated as a path relative to Constants.solarNodeHome(), defaulting to DEFAULT_SETTING_RESOURCE_DIR if not defined.

      Returns:
      the setting resource directory, never null
      Since:
      1.4
    • getProviders

      List<net.solarnetwork.settings.SettingSpecifierProvider> getProviders()
      Get a list of all possible non-factory setting providers.
      Returns:
      list of setting providers (never null)
    • getProviders

      List<net.solarnetwork.settings.SettingSpecifierProvider> getProviders(net.solarnetwork.util.SearchFilter filter)
      Get a list of all possible non-factory setting providers.
      Parameters:
      filter - the search filter; the filter is applied to the factory service properties
      Returns:
      list of setting providers (never null)
      Since:
      1.6
    • getProviderFactories

      List<net.solarnetwork.settings.SettingSpecifierProviderFactory> getProviderFactories()
      Get a list of all possible setting provider factories.
      Returns:
      list of setting provider factories (never null)
    • getProviderFactories

      List<net.solarnetwork.settings.SettingSpecifierProviderFactory> getProviderFactories(net.solarnetwork.util.SearchFilter filter)
      Get a filtered list of all possible setting provider factories.
      Parameters:
      filter - the search filter; the filter is applied to the factory service properties
      Returns:
      list of setting provider factories (never null)
      Since:
      1.6
    • getProviderFactory

      net.solarnetwork.settings.SettingSpecifierProviderFactory getProviderFactory(String factoryUid)
      Get a specific factory for a given UID.
      Parameters:
      factoryUid - the factory UID to get the providers for
      Returns:
      the factory, or null if not available
    • enableProviderFactoryInstance

      void enableProviderFactoryInstance(String factoryUid, String instanceUid)
      Enable a provider factory instance.
      Parameters:
      factoryUid - the factory UID to enable
      instanceUid - the instance UID to enable
      Since:
      2.1
    • disableProviderFactoryInstance

      void disableProviderFactoryInstance(String factoryUid, String instanceUid)
      Disable a provider factory instance.
      Parameters:
      factoryUid - the factory UID to disable
      instanceUid - the instance UID to disable
      Since:
      2.1
    • addProviderFactoryInstance

      String addProviderFactoryInstance(String factoryUid)
      Add a new factory instance, and return the new instance ID.
      Parameters:
      factoryUid - the factory UID to create the new instance for
      Returns:
      the new instance ID
    • addProviderFactoryInstance

      default String addProviderFactoryInstance(String factoryUid, String instanceUid)
      Add a new factory instance, and return the new instance ID.

      If instanceUid is provided and an instance already exists for that ID, this will have the same effect as if enableProviderFactoryInstance(String, String) was called.

      Parameters:
      factoryUid - the factory UID to create the new instance for
      instanceUid - the instance UID to create the new instance for, or null to automatically assign one
      Returns:
      the new instance ID
      Since:
      2.1
    • deleteProviderFactoryInstance

      void deleteProviderFactoryInstance(String factoryUid, String instanceUid)
      Delete an existing factory instance.
      Parameters:
      factoryUid - the factory UID to create the new instance for
      instanceUid - the instance UID to create the new instance for
    • resetProviderFactoryInstance

      void resetProviderFactoryInstance(String factoryUid, String instanceUid)
      Reset an existing factory instance to its default values.
      Parameters:
      factoryUid - the factory UID to reset
      instanceUid - the instance UID to reset
    • removeProviderFactoryInstances

      default void removeProviderFactoryInstances(String factoryUid, Set<String> instanceUids)
      Reset and delete factory instances.
      Parameters:
      factoryUid - the factory UID of the instances to remove
      instanceUids - the instance UID to remove
      Since:
      2.2
    • getProvidersForFactory

      Map<String,net.solarnetwork.settings.FactorySettingSpecifierProvider> getProvidersForFactory(String factoryUid)
      Get all possible setting providers for a specific factory UID, grouped by instance ID.
      Parameters:
      factoryUid - the factory UID to get the providers for
      Returns:
      mapping of instance IDs to associated setting providers (never null)
    • getSettingValue

      Object getSettingValue(net.solarnetwork.settings.SettingSpecifierProvider provider, net.solarnetwork.settings.SettingSpecifier setting)
      Get the current value of a setting.
      Parameters:
      provider - the provider of the setting
      setting - the setting
      Returns:
      the current setting value
    • updateSettings

      void updateSettings(SettingsCommand command)
      Update setting values.
      Parameters:
      command - the update command
    • getSettingResourceHandlers

      List<SettingResourceHandler> getSettingResourceHandlers()
      Get a list of all available setting resource handlers.
      Returns:
      the handlers, never null
      Since:
      2.1
    • getSettingResourceHandler

      SettingResourceHandler getSettingResourceHandler(String handlerKey, String instanceKey)
      Get a setting resource handler.
      Parameters:
      handlerKey - the ID if the SettingResourceHandler to get
      instanceKey - if handlerKey is a factory, the ID of the instance to import the resources for, otherwise null
      Returns:
      the resource handler, or null if not available
      Since:
      1.4
    • getSettingResources

      Iterable<org.springframework.core.io.Resource> getSettingResources(String handlerKey, String instanceKey, String settingKey) throws IOException
      Get current setting resources.
      Parameters:
      handlerKey - the ID if the SettingResourceHandler to get the resources from
      instanceKey - if handlerKey is a factory, the ID of the instance to import the resources for, otherwise null
      settingKey - the setting ID to get the resources for
      Returns:
      the resources (never null)
      Throws:
      IOException - if any IO error occurs
      Since:
      1.4
    • importSettingResources

      void importSettingResources(String handlerKey, String instanceKey, String settingKey, Iterable<org.springframework.core.io.Resource> resources) throws IOException
      Import setting resources.

      The setting resources will be persisted by this service, and should then also be passed to the appropriate SettingResourceHandler for the given handlerKey and instanceKey values by invoking SettingResourceHandler.applySettingResources(String, Iterable) with settingKey and the persisted resources.

      Parameters:
      handlerKey - the ID if the SettingResourceHandler to import to
      instanceKey - if handlerKey is a factory, the ID of the instance to import the resources for, otherwise null
      settingKey - the setting ID to import the resources for
      resources - the resources to import
      Throws:
      IOException - if any IO error occurs
      Since:
      1.4
    • exportSettingsCSV

      void exportSettingsCSV(Writer out) throws IOException
      Export all settings as CSV formatted text.
      Parameters:
      out - the output stream
      Throws:
      IOException - if any IO error occurs
    • getSettings

      List<Setting> getSettings(String factoryUid, String instanceUid)
      Get a list of all available settings for a given factory and/or instance ID.
      Parameters:
      factoryUid - the UID of the factory to get, or null for a non-factory component
      instanceUid - if UID of the instance
      Returns:
      the available settings, never null
      Throws:
      IllegalArgumentException - if both arguments are null
      Since:
      2.1
    • importSettingsCSV

      void importSettingsCSV(Reader in) throws IOException
      Import all settings from a CSV formatted text stream.
      Parameters:
      in - the input stream
      Throws:
      IOException - if any IO error occurs
    • importSettingsCSV

      void importSettingsCSV(Reader in, SettingsImportOptions options) throws IOException
      Import all settings from a CSV formatted text stream, with options.
      Parameters:
      in - The input stream to import.
      options - The import options.
      Throws:
      IOException - if any IO error occurs
      Since:
      1.2
    • backupSettings

      SettingsBackup backupSettings()
      Create a backup of all settings, and return a backup object if the backup was performed.

      A new backup need not be created if the settings are unchanged. In that case, or if this method does not create a backup for any reason, this method should return null.

      Returns:
      the backup object, or null if no backup created
    • getAvailableBackups

      Collection<SettingsBackup> getAvailableBackups()
      Get a collection of all known settings backups.
      Returns:
      the backups, never null
    • getReaderForBackup

      Reader getReaderForBackup(SettingsBackup backup)
      Get a Reader to the backup data for a given SettingsBackup object.
      Parameters:
      backup - the backup to get the Reader for
      Returns:
      the Reader, or null if the backup cannot be found