2.17.2: 2011-06-17

net.sf.basedb.core
Class ParameterValuesImpl

java.lang.Object
  extended by net.sf.basedb.core.ParameterValuesImpl
All Implemented Interfaces:
ParameterValues

 class ParameterValuesImpl
extends Object
implements ParameterValues

An implementation of the ParameterValues interface that lets a plugin write the job's configuration.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2011-05-09 08:45:49 +0200 (Mon, 09 May 2011) $

Field Summary
private  PluginConfiguration configuration
           
private  int id
          The id of the job or configuration.
private  Job job
           
private  Map<String,List<?>> parameters
          Preloaded parameter values, if the write protected flag is set.
private  Map<String,ParameterType> parameterTypes
           
private  PluginDefinition plugin
           
private  boolean writeProtected
          The configuration should only be writeable when configuring the job, not while executing a job.
 
Constructor Summary
ParameterValuesImpl(Job job, boolean writeProtected)
           
ParameterValuesImpl(PluginConfiguration config, int version, boolean writeProtected)
           
ParameterValuesImpl(PluginDefinition plugin)
          Empty parameter values
 
Method Summary
 int getId()
          Get the ID of the job or configuration the parameters comes from.
 Job getJob()
          Get the job that we are executing/configuring.
 PluginConfiguration getPluginConfiguration()
          Get the configuration that we are using/configuring.
 PluginDefinition getPluginDefinition()
          Get the plugin that we are executing/configuring.
 Object getValue(String name)
          Get a single value for a specific parameter.
 List<?> getValues(String name)
          Get a List of values for a specific parameter.
(package private)  boolean isWriteProtected()
           
(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

private final int id
The id of the job or configuration.


job

private final Job job

configuration

private final PluginConfiguration configuration

plugin

private final PluginDefinition plugin

writeProtected

private final boolean writeProtected
The configuration should only be writeable when configuring the job, not while executing a job.


parameters

private final Map<String,List<?>> parameters
Preloaded parameter values, if the write protected flag is set.


parameterTypes

private final Map<String,ParameterType> parameterTypes
Constructor Detail

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 Detail

getJob

public Job getJob()
Description copied from interface: ParameterValues
Get the job that we are executing/configuring.

Specified by:
getJob in interface ParameterValues
Returns:
A Job or null if not known

getPluginDefinition

public PluginDefinition getPluginDefinition()
Description copied from interface: ParameterValues
Get the plugin that we are executing/configuring.

Specified by:
getPluginDefinition in interface ParameterValues
Returns:
A PluginDefinition or null if not known

getPluginConfiguration

public PluginConfiguration getPluginConfiguration()
Description copied from interface: ParameterValues
Get the configuration that we are using/configuring.

Specified by:
getPluginConfiguration in interface ParameterValues
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 interface ParameterValues

getValue

public Object getValue(String name)
                throws PermissionDeniedException,
                       BaseException
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. Use ParameterValues.getValues(String) to return all values as a list.

Specified by:
getValue in interface ParameterValues
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 value
BaseException - If there is another error

getValues

public List<?> getValues(String name)
                  throws PermissionDeniedException,
                         BaseException
Description copied from interface: ParameterValues
Get a List of values for a specific parameter.

Specified by:
getValues in interface ParameterValues
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 values
BaseException - 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 interface ParameterValues
Parameters:
name - The name of the parameter
type - The type of the value
value - The value to be set
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the value is invalid according to the settings in the type
BaseException - 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 interface ParameterValues
Parameters:
name - The name of the parameter
type - The type of the value
values - A list containing the values
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If any of the values is invalid according to the settings in the type
BaseException - If there is another error

isWriteProtected

boolean isWriteProtected()

saveParameters

void saveParameters(Job job,
                    Map<String,PluginParameter<?>> moreInfo)

saveParameters

void saveParameters(PluginConfiguration config,
                    Map<String,PluginParameter<?>> moreInfo)

2.17.2: 2011-06-17