Class ParameterValuesWrapper

java.lang.Object
net.sf.basedb.core.plugin.ParameterValuesWrapper
All Implemented Interfaces:
ParameterValues

public class ParameterValuesWrapper
extends Object
implements ParameterValues
A helper class that will wrap the parameter values from one job, one configuration and one request object. The main use is to simplify reading parameter values that may be located at different places. The getValue(String) and getValues(String) methods will first check the request, if no parameter is present the job will be checked and at last the configuration.

The setValue(String, ParameterType, Object) and setValues(String, ParameterType, List) can be configured to write through to either the job or the configuration.

Version:
2.4
Author:
nicklas
Last modified
$Date: 2019-02-26 11:10:15 +0100 (tis, 26 feb. 2019) $
  • Field Details

  • Constructor Details

  • Method Details

    • getId

      public int getId()
      Get the ID of either the job or the configuration, depending in the preferJob parameter that was set when creating this object.
      Specified by:
      getId in interface ParameterValues
      Returns:
      The ID of the job or configuration or 0 if there is none
    • 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
    • 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
    • getPluginDefinition

      public PluginDefinition getPluginDefinition()
      Get the PluginDefinition of either the job or the configuration, depending in the preferJob parameter that was set when creating this object.
      Specified by:
      getPluginDefinition in interface ParameterValues
      Returns:
      The PluginDefinition of the job or configuration or null if there is none
    • getValue

      public <T> T getValue​(String name) throws PermissionDeniedException, BaseException
      Get the value of the parameter with the specified name. This method first looks for a value in the Request object. If not found, it looks in the job object, and at last in the configuration object.
      Specified by:
      getValue in interface ParameterValues
      Parameters:
      name - the name of the parameter
      Returns:
      The value of the specified parameter
      Throws:
      PermissionDeniedException - If the logged in user doesn't have permission to read the value
      BaseException - If there is another error
    • getValues

      public <T> List<T> getValues​(String name) throws PermissionDeniedException, BaseException
      Get the values of the parameter with the specified name. This method first looks for a value in the Request object. If not found, it looks in the job object, and at last in the configuration object.
      Specified by:
      getValues in interface ParameterValues
      Parameters:
      name - The name of the parameter
      Returns:
      The value of the specified parameter
      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
      Set the value on either the job or configuration, depending in the preferJob parameter that was set when creating this object.
      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
      Set the value on either the job or configuration, depending in the preferJob parameter that was set when creating this object.
      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