Package net.sf.basedb.core
Class PluginConfiguration
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.OwnedItem
net.sf.basedb.core.SharedItem
net.sf.basedb.core.CommonItem
net.sf.basedb.core.AnnotatedItem
net.sf.basedb.core.PluginConfiguration
- All Implemented Interfaces:
AccessControlled
,Annotatable
,AnnotatableProxy
,Controlled
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
,Transactional
public class PluginConfiguration
extends AnnotatedItem
implements Transactional, AnnotatableProxy, Registered
This class is used to configure a plugin. A plugin can have many
configurations.
- Version:
- 2.0
- Author:
- Nicklas, Samuel
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.sf.basedb.core.Transactional
Transactional.Action
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
static final Item
The type of item represented by this class.Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionStart the configuration sequence for a plugin.void
copyParametersFrom
(PluginConfiguration copyFrom) Copy all parameter values from another plugin configuration.Get all parents objects which are annotatable and the logged in user has read permission to.Get a message explaining what the proxy does with the annotations.Get the annotation types that can be used by this configuration.static PluginConfiguration
Get aPluginConfiguration
item when you know the ID.(package private) PluginConfigurationData
getData()
Get theBasicData
object that holds all data for this item.Get the date that the item was registered in the database.getJobs()
Get a query that returns the jobs using this plugin configuration.static PluginConfiguration
getNew
(DbControl dc, PluginDefinition pd) Create a newPluginConfiguration
item.private int
Increase the version number once per transaction.getParameterInfo
(String name) Get extra information about a parameter in the latest version.getParameterInfo
(String name, int version) Get extra information about a parameter in a specific version.Get the names of all configuration values in the latest version.getParameterNames
(int version) Get the names of all configuration values in a specific version.private <T> ParameterType<T>
getParameterType
(Class<T> parameterClass, List<?> values) Gets the ParameterType to use with a class.getParameterValues
(int version) Get the configuration parameters as aParameterValues
object.List<?>
getParameterValues
(String name) Get the values of a configuration parameter in the latest version.List<?>
getParameterValues
(String name, int version) Get the values of a configuration parameter in a specific version.(package private) ParameterValuesImpl
getParameterValuesImpl
(int version) Get a write-protected ParameterValuesImpl object so a job can read the paremeters.int
Get the latest version number of the parameters.Get the plugin definition for this configuration.static ItemQuery<PluginConfiguration>
getQuery()
Get a query configured to retrieve plugin configurations.static ItemQuery<PluginConfiguration>
getQuery
(GuiContext gc, String interfaceName) Get a query that returns all plugins configurations related to a specified GUI context and implementing a certain interface.getType()
Get the type of item represented by the object.Get all:Job
:s using this configurationprivate <T> List<T>
getValueList2
(Element parameter, Class<T> classType) Gets the list of values for a parameter from the XML-file.boolean
Checks if this plugin configuration is disabled or not.boolean
isUsed()
Check if: AJob
is using this plugin configurationloadXmlFile2
(InputStream in, String fileName) Load a configurations xml file from the given stream.newJob
(Experiment experiment) Create a newJob
for this plugin configuration.(package private) void
onAfterCommit
(Transactional.Action action) Reset parameter version so that adding new parameters will increase the version the next time.void
setDisabled
(boolean disabled) Disabled or enable this plugin configuration.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.void
setParameterValues
(String name, String label, String description, ParameterType<?> parameterType, List<?> values) Set a configuration parameter.void
setParameterValues
(String name, ParameterType<?> parameterType, List<?> values) Set a configuration parameter.void
setParameterValues2
(List<Element> parameters) Sets parameters for a PluginConfiguration from the elements in a xml configurations file.(package private) void
setParameterValuesInternal
(String name, String label, String description, ParameterType<?> parameterType, List<?> values, boolean validate) Set the values of a configuration parameter.private void
The definition cannot be changed.Methods inherited from class net.sf.basedb.core.AnnotatedItem
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
Methods inherited from interface net.sf.basedb.core.Annotatable
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
-
Field Details
-
TYPE
The type of item represented by this class.- See Also:
-
newParameterVersion
private int newParameterVersion
-
-
Constructor Details
-
PluginConfiguration
PluginConfiguration(PluginConfigurationData pc)
-
-
Method Details
-
getNew
public static PluginConfiguration getNew(DbControl dc, PluginDefinition pd) throws PermissionDeniedException, BaseException Create a newPluginConfiguration
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.pd
- PluginDefinition to create a configuration for.- Returns:
- The new
PluginConfiguration
item - Throws:
InvalidDataException
- If the plugin definition is nullPermissionDeniedException
- If the logged in user doesn't have use permission for the plugin definitionBaseException
- If there is an error
-
getById
public static PluginConfiguration getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aPluginConfiguration
item when you know the ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The ID of the item to load- Returns:
- The
PluginConfiguration
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not foundPermissionDeniedException
- If the logged in user doesn't haveREAD
permission for the itemBaseException
- If there is another error
-
getQuery
Get a query configured to retrieve plugin configurations.- Returns:
- An
ItemQuery
object
-
getQuery
Get a query that returns all plugins configurations related to a specified GUI context and implementing a certain interface. Ie. ThePluginDefinition.isInContext(GuiContext)
returns true for the specified item, andPluginDefinition.supports(PluginType)
returns true for the specified interface.- Parameters:
gc
- The item the plugin should be related to, or null if this parameter is irrelevantinterfaceName
- The complete name of the interface that the plugin must implement, or null if this parameter is irrelevant
-
loadXmlFile2
Load a configurations xml file from the given stream.- Parameters:
in
- The input stream to read fromfileName
- The name of the originating file (optional)- Returns:
- A list with all <configuration> elements in the file
- Throws:
IOException
- Since:
- 3.4
-
getData
PluginConfigurationData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classAnnotatedItem
-
getType
Description copied from interface:Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- Returns:
- A value indicating the type of item
-
getEntryDate
Description copied from interface:Registered
Get the date that the item was registered in the database.- Specified by:
getEntryDate
in interfaceRegistered
- Returns:
- A date or null if this is not known
-
setEntryDate
Description copied from interface:Registered
Set the date the entry was registered in the database. Implementations should only allow this property to be set before the item is first stored in the database. The intention of this method is to facilitate export/import of data between server.- Specified by:
setEntryDate
in interfaceRegistered
- Parameters:
entryDate
- A date or null to use today's date
-
isUsed
Check if:- A
Job
is using this plugin configuration
- Overrides:
isUsed
in classBasicItem
- Returns:
- TRUE if this item is used, FALSE otherwise
- Throws:
BaseException
- If not able to tell if item is used or not.- See Also:
- A
-
getUsingItems
Get all:Job
:s using this configuration
- Overrides:
getUsingItems
in classBasicItem
- Returns:
- A set containing proxies for the items, or an empty set if no items are using this item
- Since:
- 2.2
- See Also:
-
onAfterCommit
Reset parameter version so that adding new parameters will increase the version the next time. -
getAnnotatableParents
Description copied from interface:Annotatable
Get all parents objects which are annotatable and the logged in user has read permission to. If the item doesn't have any annotatable parents, it may return null or an empty set. The method should only return the immediate parent(s), not parents to parents, etc. As of BASE 3.1 this method may also return child items if the child item is aSubtypable
item that has a subtype with theItemSubtype.getPushAnnotations()
flag set.- Specified by:
getAnnotatableParents
in interfaceAnnotatable
- Returns:
- Always null
- Since:
- 2.5
-
getAnnotationTypes
Get the annotation types that can be used by this configuration. This method requires that the plug-in implements theAnnotationSetterPlugin
interface.- Specified by:
getAnnotationTypes
in interfaceAnnotatableProxy
- Returns:
- A query or null if this plug-in doesn't use annotations
- Since:
- 2.5
-
getAnnotationMessage
Get a message explaining what the proxy does with the annotations.- Specified by:
getAnnotationMessage
in interfaceAnnotatableProxy
- Returns:
- A message or null
- Since:
- 2.5
-
getPluginDefinition
Get the plugin definition for this configuration.- Returns:
PluginDefinition
object.- Throws:
PermissionDeniedException
- This exception is thrown if the logged in user doesn't haveREAD
permission to the items.BaseException
- If anything else fails.
-
setPluginDefinition
private void setPluginDefinition(PluginDefinition pd) throws PermissionDeniedException, InvalidUseOfNullException The definition cannot be changed. Used internally only. -
isDisabled
public boolean isDisabled()Checks if this plugin configuration is disabled or not. A disabled configuration can't be used.- Since:
- 3.19.6
-
setDisabled
public void setDisabled(boolean disabled) Disabled or enable this plugin configuration.- Since:
- 3.19.6
-
getParameterVersion
public int getParameterVersion()Get the latest version number of the parameters. -
getNewParameterVersion
private int getNewParameterVersion()Increase the version number once per transaction. -
getParameterNames
Get the names of all configuration values in the latest version.- Returns:
- A
Set
containing the names of the configuration values or an empty set if no values has been defined - See Also:
-
getParameterNames
Get the names of all configuration values in a specific version.- Parameters:
version
- The version to get the configuration parameters for- Returns:
- A
Set
containing the names of the configuration values or an empty set if no values has been defined - See Also:
-
getParameterValues
Get the values of a configuration parameter in the latest version.- Parameters:
name
- The name of the parameter- Returns:
- The values, or null if no value has been set
- Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to all valuesBaseException
- If there is another error- See Also:
-
getParameterValues
public List<?> getParameterValues(String name, int version) throws PermissionDeniedException, BaseException Get the values of a configuration parameter in a specific version.- Parameters:
name
- The name of the parameterversion
- The version of the parameter- Returns:
- The values, or null if no value has been set
- Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to all valuesBaseException
- If there is another error- See Also:
-
getParameterInfo
Get extra information about a parameter in the latest version. The information includes the label, description and values of the parameter.- Parameters:
name
- The name of the parameter- Returns:
- A ParameterInfo object or null if no parameter with the specified name exists
- Throws:
PermissionDeniedException
- If the parameter contain values that the logged in user doesn't have read permission forBaseException
- If there is another error- See Also:
-
getParameterInfo
public ParameterInfo getParameterInfo(String name, int version) throws PermissionDeniedException, BaseException Get extra information about a parameter in a specific version. The information includes the label, description and values of the parameter.- Parameters:
name
- The name of the parameterversion
- The version of the parameter- Returns:
- A ParameterInfo object or null if no parameter with the specified name exists
- Throws:
PermissionDeniedException
- If the parameter contain values that the logged in user doesn't have read permission forBaseException
- If there is another error- See Also:
-
getParameterValues
Get the configuration parameters as aParameterValues
object.- Parameters:
version
- The version of the parameters- Returns:
- A ParameterValues object
- Since:
- 2.5
- See Also:
-
setParameterValues
public void setParameterValues(String name, ParameterType<?> parameterType, List<?> values) throws InvalidDataException, PermissionDeniedException, BaseException Set a configuration parameter. The parameter version number is increased by one when the values are committed to the database.- Parameters:
name
- The name of the configuration parameterparameterType
- The type of the parametervalues
- A list containing the new values, null or empty to remove the configuration values- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If name is null or the new value doesn't validate against the parameter typeBaseException
- If there is another error
-
setParameterValues
public void setParameterValues(String name, String label, String description, ParameterType<?> parameterType, List<?> values) throws InvalidDataException, PermissionDeniedException, BaseException Set a configuration parameter. The parameter version number is increased by one when the values are committed to the database.- Parameters:
name
- The name of the configuration parameterlabel
- The label of the parameter (optional)description
- A description of the parameter (optional)parameterType
- The type of the parametervalues
- A list containing the new values, null or empty to remove the configuration values- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If name is null or the new value doesn't validate against the parameter typeBaseException
- If there is another error
-
setParameterValuesInternal
void setParameterValuesInternal(String name, String label, String description, ParameterType<?> parameterType, List<?> values, boolean validate) throws InvalidDataException, PermissionDeniedException, BaseException Set the values of a configuration parameter.- Parameters:
name
- The name of the configuration parameterlabel
- The label of the parameter (optional)description
- A description of the parameter (optional)parameterType
- The type of the parametervalues
- A list containing the new values, null or empty to remove the configuration valuesvalidate
- If validation byParameterType.validate(String, List)
is needed or not- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If name is null or the new value doesn't validate against the parameter typeBaseException
- If there is another error
-
copyParametersFrom
public void copyParametersFrom(PluginConfiguration copyFrom) throws InvalidDataException, PermissionDeniedException, BaseException Copy all parameter values from another plugin configuration. This method increases the parameter version number and saves the copied parameters in that version.- Parameters:
copyFrom
- The configuration to copy parameters from- Throws:
InvalidDataException
- If the copyFrom parameter is nullPermissionDeniedException
- If the logged in user doesn't have write permission for this configurationBaseException
- If there is another error
-
configure
Start the configuration sequence for a plugin. SeePluginRequest
for more information. The parameters sent to the plugin are those from the latest version.- Returns:
- A
PluginRequest
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionBaseException
- If there is another error
-
newJob
Create a newJob
for this plugin configuration.- Parameters:
experiment
- The experiment the job is part of, or null if the job is not part of an experiment- Returns:
- The new
Job
item - Throws:
PermissionDeniedException
- If the logged in user doesn't have use permission for this plugin definitionBaseException
- Since:
- 2.7
-
getJobs
Get a query that returns the jobs using this plugin configuration.- Returns:
- An
ItemQuery
object
-
getParameterValuesImpl
Get a write-protected ParameterValuesImpl object so a job can read the paremeters.- Throws:
BaseException
-
setParameterValues2
Sets parameters for a PluginConfiguration from the elements in a xml configurations file.- Parameters:
parameters
- A list of the parameters that shall be set to the configuration- Throws:
ClassNotFoundException
- If there is an error while trying to find the type of the parameters.- Since:
- 3.4
-
getValueList2
Gets the list of values for a parameter from the XML-file. Returns a list with parameter values. -
getParameterType
Gets the ParameterType to use with a class. Returns null if this importer doesn't support the class.
-