Package net.sf.basedb.core
Class ParameterValuesImpl
java.lang.Object
net.sf.basedb.core.ParameterValuesImpl
- All Implemented Interfaces:
ParameterValues
An implementation of the
ParameterValues
interface that
lets a plugin write the job's configuration.- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2019-02-26 11:10:15 +0100 (tis, 26 feb. 2019) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final PluginConfiguration
private final int
The id of the job or configuration.private final Job
Preloaded parameter values, if the write protected flag is set.private final Map<String,
ParameterType<?>> private final PluginDefinition
private final boolean
The configuration should only be writeable when configuring the job, not while executing a job. -
Constructor Summary
ConstructorDescriptionParameterValuesImpl
(Job job, boolean writeProtected) ParameterValuesImpl
(PluginConfiguration config, int version, boolean writeProtected) ParameterValuesImpl
(PluginDefinition plugin) Empty parameter values -
Method Summary
Modifier and TypeMethodDescriptionint
getId()
Get the ID of the job or configuration the parameters comes from.getJob()
Get the job that we are executing/configuring.Get the configuration that we are using/configuring.Get the plugin that we are executing/configuring.<T> T
Get a single value for a specific parameter.<T> List<T>
Get aList
of values for a specific parameter.(package private) boolean
(package private) void
saveParameters
(Job job, Map<String, PluginParameter<?>> moreInfo) (package private) void
saveParameters
(PluginConfiguration config, Map<String, PluginParameter<?>> moreInfo) <T> void
setValue
(String name, ParameterType<T> type, T value) Set a single value for a parameter.<T> void
setValues
(String name, ParameterType<T> type, List<T> values) Set a list of values for a parameter.
-
Field Details
-
id
private final int idThe id of the job or configuration. -
job
-
configuration
-
plugin
-
writeProtected
private final boolean writeProtectedThe configuration should only be writeable when configuring the job, not while executing a job. -
parameters
Preloaded parameter values, if the write protected flag is set. -
parameterTypes
-
-
Constructor Details
-
ParameterValuesImpl
ParameterValuesImpl(PluginDefinition plugin) Empty parameter values -
ParameterValuesImpl
ParameterValuesImpl(Job job, boolean writeProtected) throws BaseException - Throws:
BaseException
-
ParameterValuesImpl
ParameterValuesImpl(PluginConfiguration config, int version, boolean writeProtected) throws BaseException - Throws:
BaseException
-
-
Method Details
-
getJob
Description copied from interface:ParameterValues
Get the job that we are executing/configuring.- Specified by:
getJob
in interfaceParameterValues
- Returns:
- A Job or null if not known
-
getPluginDefinition
Description copied from interface:ParameterValues
Get the plugin that we are executing/configuring.- Specified by:
getPluginDefinition
in interfaceParameterValues
- Returns:
- A PluginDefinition or null if not known
-
getPluginConfiguration
Description copied from interface:ParameterValues
Get the configuration that we are using/configuring.- Specified by:
getPluginConfiguration
in interfaceParameterValues
- Returns:
- A PluginConfiguration or null if not known
-
getId
public int getId()Description copied from interface:ParameterValues
Get the ID of the job or configuration the parameters comes from.- Specified by:
getId
in interfaceParameterValues
-
getValue
Description copied from interface:ParameterValues
Get a single value for a specific parameter. If the parameter has more then one value only the first value is returned. UseParameterValues.getValues(String)
to return all values as a list.- Specified by:
getValue
in interfaceParameterValues
- Parameters:
name
- the name of the parameter- Returns:
- The value or null if no parameter with that name is found
- Throws:
PermissionDeniedException
- If the logged in user doesn't have permission to read the valueBaseException
- If there is another error
-
getValues
Description copied from interface:ParameterValues
Get aList
of values for a specific parameter.- Specified by:
getValues
in interfaceParameterValues
- Parameters:
name
- The name of the parameter- Returns:
- The values or null if no parameter with that name is found
- Throws:
PermissionDeniedException
- If the logged in user doesn't have permission to read the valuesBaseException
- If there is another error
-
setValue
public <T> void setValue(String name, ParameterType<T> type, T value) throws PermissionDeniedException, InvalidDataException, BaseException Description copied from interface:ParameterValues
Set a single value for a parameter. The core will store the value at the appropriate place in the database. Ie. as a configuration value to either the plugin or job configuration. If the configuration settings are write protected because the plugin received an execute command the settings will not be changed. If the value is null, but the parameter type doesn't allow null values, the default value is used. If the default value is null, an exception will be thrown.- Specified by:
setValue
in interfaceParameterValues
- Parameters:
name
- The name of the parametertype
- The type of the valuevalue
- The value to be set- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the value is invalid according to the settings in the typeBaseException
- If there is another error
-
setValues
public <T> void setValues(String name, ParameterType<T> type, List<T> values) throws PermissionDeniedException, InvalidDataException, BaseException Description copied from interface:ParameterValues
Set a list of values for a parameter. The core will store the values at the appropriate place in the database. Ie. as a configuration value to either the plugin or job configuration. If the configuration settings are write protected because the plugin received an execute command the settings will not be changed.- Specified by:
setValues
in interfaceParameterValues
- Parameters:
name
- The name of the parametertype
- The type of the valuevalues
- A list containing the values- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If any of the values is invalid according to the settings in the typeBaseException
- If there is another error
-
isWriteProtected
boolean isWriteProtected() -
saveParameters
-
saveParameters
-