2.8.1: 2008-09-10

net.sf.basedb.core
Class Protocol

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.OwnedItem<D>
          extended by net.sf.basedb.core.SharedItem<D>
              extended by net.sf.basedb.core.CommonItem<ProtocolData>
                  extended by net.sf.basedb.core.Protocol
All Implemented Interfaces:
AccessControlled, FileAttachable, Identifiable, Nameable, Ownable, Removable, Shareable

public class Protocol
extends CommonItem<ProtocolData>
implements FileAttachable

This class is used to represent individual protocol items and information about them.

Version:
2.0
Author:
enell

Field Summary
static Item TYPE
          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
Protocol(ProtocolData data)
          Creates a new protocol item.
 
Method Summary
 void addParameter(AnnotationType annotationType)
          Add an annotation type as a parameter to this protocol.
static Protocol getById(DbControl dc, int id)
          Get a Protocol item when you know the ID.
 File getFile()
          Get the file that is attached to the item.
static Protocol getNew(DbControl dc, ProtocolType protocolType)
          Create a new Protocol item.
 ItemQuery<AnnotationType> getParameters()
          Get a query that returns all annotation types used as parameters for this protocol.
 ProtocolType getProtocolType()
          Get the associated ProtocolType item.
static ItemQuery<Protocol> getQuery()
          Get a query configured to retrieve protocols.
 Item getType()
          Get the type of item represented by the object.
 Set<ItemProxy> getUsingItems()
          Get all: a BioMaterial:s and Hybridization:s using this protocol a Plate:s using this protocol an ArrayBatch:s using this protocol a Scan:s using this protocol a RawBioAssay:s using this protocol
 boolean isParameter(AnnotationType annotationType)
          Check if the annotation type is a parameter to this protocol.
 boolean isUsed()
          Check if this protocol is used by: a BioMaterialEvent a PlateEvent an ArrayBatch a Scan a RawBioAssay
 void removeParameter(AnnotationType annotationType)
          Remove an annotation type from the parameters for this protocol.
 void setFile(File file)
          Attach a file to the item.
 void setProtocolType(ProtocolType protocolType)
          Set the protocol type of this Protocol item.
 
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable
 
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable
 
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership, toTransferable
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.PROTOCOL, getType()
Constructor Detail

Protocol

Protocol(ProtocolData data)
Creates a new protocol item.

Parameters:
data - the data
Method Detail

getNew

public static Protocol getNew(DbControl dc,
                              ProtocolType protocolType)
                       throws BaseException
Create a new Protocol item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
protocolType - The type of the protocol
Returns:
The new Protocol item
Throws:
BaseException - If there is an error

getById

public static Protocol getById(DbControl dc,
                               int id)
                        throws ItemNotFoundException,
                               PermissionDeniedException,
                               BaseException
Get a Protocol item when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load
Returns:
The Protocol item
Throws:
ItemNotFoundException - This exception is thrown if an item with the specified ID is not found
PermissionDeniedException - This exception is thrown if the logged in user doesn't have READ permission to the item
BaseException - This exception is thrown if there is another error

getQuery

public static ItemQuery<Protocol> getQuery()
Get a query configured to retrieve protocols.

Returns:
An ItemQuery object

getType

public Item 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 the Item enumeration.

Specified by:
getType in interface Identifiable
Returns:
A value indicating the type of item

getFile

public File getFile()
             throws PermissionDeniedException,
                    BaseException
Description copied from interface: FileAttachable
Get the file that is attached to the item.

Specified by:
getFile in interface FileAttachable
Returns:
A File item, or null if no file is attached
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission for the file
BaseException - If there is another error

setFile

public void setFile(File file)
             throws PermissionDeniedException
Description copied from interface: FileAttachable
Attach a file to the item.

Specified by:
setFile in interface FileAttachable
Parameters:
file - The file to attach to the item
Throws:
PermissionDeniedException - If the logged in user doesn't have use permission for the file or write permission for the item

isUsed

public boolean isUsed()
               throws BaseException
Check if this protocol is used by:

Overrides:
isUsed in class BasicItem<ProtocolData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException - If not able to tell if item is used or not.
See Also:
BasicItem.getUsingItems()

getUsingItems

public Set<ItemProxy> getUsingItems()
Get all:

getProtocolType

public ProtocolType getProtocolType()
                             throws PermissionDeniedException,
                                    BaseException
Get the associated ProtocolType item. All Protocol items must have a type.

Returns:
The ProtocolType item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission for the protocol type
BaseException - If there is any error

setProtocolType

public void setProtocolType(ProtocolType protocolType)
                     throws PermissionDeniedException,
                            InvalidUseOfNullException
Set the protocol type of this Protocol item. This parameter mustn't be null.

Parameters:
protocolType - The new ProtocolType
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission to this protocol or Permission.USE permission for the protocol type
InvalidUseOfNullException - If protocoltype is null

addParameter

public void addParameter(AnnotationType annotationType)
                  throws PermissionDeniedException,
                         InvalidDataException
Add an annotation type as a parameter to this protocol.

Parameters:
annotationType - The annotation type to add to this protocol
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission for the protocol and Permission.USE for the annotation type
InvalidDataException - If the annotationType is null, or the AnnotationType.isProtocolParameter() doesn't return true
Since:
2.2

removeParameter

public void removeParameter(AnnotationType annotationType)
                     throws PermissionDeniedException,
                            InvalidDataException
Remove an annotation type from the parameters for this protocol.

Parameters:
annotationType - The annotation type to remove from this protocol
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission for the protocol
InvalidDataException - If the annotationType is null
Since:
2.2

isParameter

public boolean isParameter(AnnotationType annotationType)
Check if the annotation type is a parameter to this protocol.

Parameters:
annotationType - The annotation type to check, null always return false
Returns:
TRUE if the annotation type is a parameter, FALSE otherwise
Since:
2.2
See Also:
AnnotationType.isProtocolParameter(Protocol)

getParameters

public ItemQuery<AnnotationType> getParameters()
Get a query that returns all annotation types used as parameters for this protocol.

Returns:
An ItemQuery object
Since:
2.2

2.8.1: 2008-09-10