Interface SettingsService
- Since:
- 2.0
- Version:
- 2.2
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default setting resource directory, ifSYSTEM_PROP_SETTING_RESOURCE_DIRis not defined.static final StringThe instruction parameter for setting flags.static final StringThe instruction parameter for setting key.static final StringThe instruction parameter for setting type.static final StringThe instruction parameter for setting value.static final StringThe system property for the setting resource directory.static final StringThe instruction topic for a request to update (create or change) a setting value. -
Method Summary
Modifier and TypeMethodDescriptionaddProviderFactoryInstance(String factoryUid) Add a new factory instance, and return the new instance ID.default StringaddProviderFactoryInstance(String factoryUid, String instanceUid) Add a new factory instance, and return the new instance ID.Create a backup of all settings, and return a backup object if the backup was performed.voiddeleteProviderFactoryInstance(String factoryUid, String instanceUid) Delete an existing factory instance.voiddisableProviderFactoryInstance(String factoryUid, String instanceUid) Disable a provider factory instance.voidenableProviderFactoryInstance(String factoryUid, String instanceUid) Enable a provider factory instance.voidexportSettingsCSV(Writer out) Export all settings as CSV formatted text.Get a collection of all known settings backups.List<net.solarnetwork.settings.SettingSpecifierProviderFactory>Get a list of all possible setting provider factories.List<net.solarnetwork.settings.SettingSpecifierProviderFactory>getProviderFactories(net.solarnetwork.util.SearchFilter filter) Get a filtered list of all possible setting provider factories.net.solarnetwork.settings.SettingSpecifierProviderFactorygetProviderFactory(String factoryUid) Get a specific factory for a given UID.List<net.solarnetwork.settings.SettingSpecifierProvider>Get a list of all possible non-factory setting providers.List<net.solarnetwork.settings.SettingSpecifierProvider>getProviders(net.solarnetwork.util.SearchFilter filter) Get a list of all possible non-factory setting providers.getProvidersForFactory(String factoryUid) Get all possible setting providers for a specific factory UID, grouped by instance ID.getReaderForBackup(SettingsBackup backup) Get aReaderto the backup data for a given SettingsBackup object.getSettingResourceHandler(String handlerKey, String instanceKey) Get a setting resource handler.Get a list of all available setting resource handlers.Iterable<org.springframework.core.io.Resource>getSettingResources(String handlerKey, String instanceKey, String settingKey) Get current setting resources.getSettings(String factoryUid, String instanceUid) Get a list of all available settings for a given factory and/or instance ID.getSettingValue(net.solarnetwork.settings.SettingSpecifierProvider provider, net.solarnetwork.settings.SettingSpecifier setting) Get the current value of a setting.voidimportSettingResources(String handlerKey, String instanceKey, String settingKey, Iterable<org.springframework.core.io.Resource> resources) Import setting resources.voidImport all settings from a CSV formatted text stream.voidimportSettingsCSV(Reader in, SettingsImportOptions options) Import all settings from a CSV formatted text stream, with options.default voidremoveProviderFactoryInstances(String factoryUid, Set<String> instanceUids) Reset and delete factory instances.voidresetProviderFactoryInstance(String factoryUid, String instanceUid) Reset an existing factory instance to its default values.static PathGet the path to the setting resource directory.voidupdateSettings(SettingsCommand command) Update setting values.
-
Field Details
-
SYSTEM_PROP_SETTING_RESOURCE_DIR
The system property for the setting resource directory.- Since:
- 1.4
- See Also:
-
DEFAULT_SETTING_RESOURCE_DIR
The default setting resource directory, ifSYSTEM_PROP_SETTING_RESOURCE_DIRis not defined.- Since:
- 1.4
- See Also:
-
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
The instruction parameter for setting key.- Since:
- 1.3
- See Also:
-
PARAM_UPDATE_SETTING_TYPE
The instruction parameter for setting type.- Since:
- 1.3
- See Also:
-
PARAM_UPDATE_SETTING_VALUE
The instruction parameter for setting value.- Since:
- 1.3
- See Also:
-
PARAM_UPDATE_SETTING_FLAGS
The instruction parameter for setting flags.- Since:
- 1.3
- See Also:
-
-
Method Details
-
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_DIRis defined as an absolute path, that path is used directly. OtherwiseSYSTEM_PROP_SETTING_RESOURCE_DIRis treated as a path relative toConstants.solarNodeHome(), defaulting toDEFAULT_SETTING_RESOURCE_DIRif 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
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
Enable a provider factory instance.- Parameters:
factoryUid- the factory UID to enableinstanceUid- the instance UID to enable- Since:
- 2.1
-
disableProviderFactoryInstance
Disable a provider factory instance.- Parameters:
factoryUid- the factory UID to disableinstanceUid- the instance UID to disable- Since:
- 2.1
-
addProviderFactoryInstance
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
Add a new factory instance, and return the new instance ID.If
instanceUidis provided and an instance already exists for that ID, this will have the same effect as ifenableProviderFactoryInstance(String, String)was called.- Parameters:
factoryUid- the factory UID to create the new instance forinstanceUid- the instance UID to create the new instance for, or null to automatically assign one- Returns:
- the new instance ID
- Since:
- 2.1
-
deleteProviderFactoryInstance
Delete an existing factory instance.- Parameters:
factoryUid- the factory UID to create the new instance forinstanceUid- the instance UID to create the new instance for
-
resetProviderFactoryInstance
Reset an existing factory instance to its default values.- Parameters:
factoryUid- the factory UID to resetinstanceUid- the instance UID to reset
-
removeProviderFactoryInstances
Reset and delete factory instances.- Parameters:
factoryUid- the factory UID of the instances to removeinstanceUids- 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 settingsetting- the setting- Returns:
- the current setting value
-
updateSettings
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
Get a setting resource handler.- Parameters:
handlerKey- the ID if theSettingResourceHandlerto getinstanceKey- ifhandlerKeyis 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 theSettingResourceHandlerto get the resources frominstanceKey- ifhandlerKeyis a factory, the ID of the instance to import the resources for, otherwise nullsettingKey- 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
SettingResourceHandlerfor the givenhandlerKeyandinstanceKeyvalues by invokingSettingResourceHandler.applySettingResources(String, Iterable)withsettingKeyand the persisted resources.- Parameters:
handlerKey- the ID if theSettingResourceHandlerto import toinstanceKey- ifhandlerKeyis a factory, the ID of the instance to import the resources for, otherwise nullsettingKey- the setting ID to import the resources forresources- the resources to import- Throws:
IOException- if any IO error occurs- Since:
- 1.4
-
exportSettingsCSV
Export all settings as CSV formatted text.- Parameters:
out- the output stream- Throws:
IOException- if any IO error occurs
-
getSettings
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 componentinstanceUid- if UID of the instance- Returns:
- the available settings, never null
- Throws:
IllegalArgumentException- if both arguments are null- Since:
- 2.1
-
importSettingsCSV
Import all settings from a CSV formatted text stream.- Parameters:
in- the input stream- Throws:
IOException- if any IO error occurs
-
importSettingsCSV
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
Get aReaderto 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
-