2.17.2: 2011-06-17

net.sf.basedb.core
Class PlateEvent

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.ChildItem<PlateEventData>
          extended by net.sf.basedb.core.PlateEvent
All Implemented Interfaces:
AccessControlled, Identifiable, Registered

public class PlateEvent
extends ChildItem<PlateEventData>
implements Registered

This class represents an event in the life of a Plate. The possible events for a plate are defined by the PlateEventType:s of a the plates PlateType.

Version:
2.0
Author:
Nicklas
See Also:
Plate, PlateEventType
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Field Summary
static int MAX_COMMENT_LENGTH
          The maximum length of the comment about this event.
private static QueryRuntimeFilter RUNTIME_FILTER
          This filter will only return items if the logged in user has generic read permission to plates.
static Item TYPE
          The type of item represented by this class.
 
Constructor Summary
PlateEvent(PlateEventData plateEventData)
           
 
Method Summary
static PlateEvent getById(DbControl dc, int id)
          Get a PlateEvent item when you know the id.
 String getComment()
          Get the comment about this event.
 Date getEntryDate()
          Get the date this event was added to the database.
 Date getEventDate()
          Get the date this event was done in the lab.
 Hardware getHardware()
          Get the Hardware that was used in this event.
static PlateEvent getNew(DbControl dc, Plate plate, PlateEventType plateEventType)
          Create a new PlateEvent item.
 Plate getPlate()
          Get the Plate this event belongs to.
 PlateEventType getPlateEventType()
          Get the PlateEventType of this event.
 Protocol getProtocol()
          Get the Protocol that was followed in this event.
static ItemQuery<PlateEvent> getQuery(Plate plate)
          Get a query configured to retrieve plate events for the specified plate.
(package private)  SharedData getSharedParent()
          Get the shareable parent item of this child item.
 Item getType()
          Get the type of item represented by the object.
 User getUser()
          Get the User that is responsible for this event.
 void setComment(String comment)
          Set the comment about this event.
 void setEventDate(Date eventDate)
          Set the date this event was done in the lab.
 void setHardware(Hardware hardware)
          Set the Hardware that was used in this event.
private  void setPlate(Plate plate)
          Set the plate owning this event.
private  void setPlateEventType(PlateEventType plateEventType)
          Set the plate event type of this event.
 void setProtocol(Protocol protocol)
          Set the protocol that was followed in this event.
 
Methods inherited from class net.sf.basedb.core.ChildItem
getPermissionForWriteDeleteAndCreate, getPluginPermissions, initPermissions
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, 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
 

Field Detail

TYPE

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

See Also:
Item.PLATEEVENT, getType()

RUNTIME_FILTER

private static final QueryRuntimeFilter RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to plates.


MAX_COMMENT_LENGTH

public static final int MAX_COMMENT_LENGTH
The maximum length of the comment about this event. Check the length against this value before calling the setComment(String) method to avoid exceptions.

See Also:
Constant Field Values
Constructor Detail

PlateEvent

PlateEvent(PlateEventData plateEventData)
Method Detail

getNew

public static PlateEvent getNew(DbControl dc,
                                Plate plate,
                                PlateEventType plateEventType)
                         throws InvalidDataException,
                                BaseException
Create a new PlateEvent item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
plate - The plate
plateEventType - The type of the event
Returns:
The new PlateEvent item
Throws:
PermissionDeniedException - If the loggged in user doesn't have write permission for the plate type
InvalidDataException - If the plate or event type is null, or if the plate type of the plate and event type are different
BaseException - If there is an error

getById

public static PlateEvent getById(DbControl dc,
                                 int id)
                          throws ItemNotFoundException,
                                 PermissionDeniedException,
                                 BaseException
Get a PlateEvent 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 PlateEvent item
Throws:
ItemNotFoundException - If an item with the specified id is not found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

getQuery

public static ItemQuery<PlateEvent> getQuery(Plate plate)
Get a query configured to retrieve plate events for the specified plate.

Parameters:
plate - The plate to retreive event for, null is allowed if the logged in user has generic READ permission for plates in which case all events will be returned
Returns:
An ItemQuery object
See Also:
Plate.getEvents()

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

getSharedParent

SharedData getSharedParent()
Description copied from class: ChildItem
Get the shareable parent item of this child item. This is used by the ChildItem.initPermissions(int, int) method to calculate the logged in user's permissions for the child item.

Specified by:
getSharedParent in class ChildItem<PlateEventData>
Returns:
The parent item

getPlate

public Plate getPlate()
               throws PermissionDeniedException,
                      BaseException
Get the Plate this event belongs to.

Returns:
The Plate item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission for the plate
BaseException - If there is another error

setPlate

private void setPlate(Plate plate)
               throws PermissionDeniedException,
                      InvalidDataException
Set the plate owning this event.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission for the plate
InvalidDataException - If the plate is null

getPlateEventType

public PlateEventType getPlateEventType()
                                 throws PermissionDeniedException,
                                        BaseException
Get the PlateEventType of this event.

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

setPlateEventType

private void setPlateEventType(PlateEventType plateEventType)
                        throws PermissionDeniedException,
                               InvalidDataException
Set the plate event type of this event.

Throws:
InvalidDataException - If the event type is null or belongs to a different PlateType than the plate
PermissionDeniedException

getProtocol

public Protocol getProtocol()
                     throws PermissionDeniedException,
                            BaseException
Get the Protocol that was followed in this event.

Returns:
The Protocol item, or null if no protocol type has been specified
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the protocol
BaseException - If there is another error

setProtocol

public void setProtocol(Protocol protocol)
                 throws PermissionDeniedException,
                        BaseException
Set the protocol that was followed in this event. It is recommended that the ProtocolType of the protocol matches the protocol type set by the PlateEventType, but the core doesn't check this.

Parameters:
protocol - The new Protocol
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission for this event or use permission for the protocol
BaseException - If there is another error

getHardware

public Hardware getHardware()
                     throws PermissionDeniedException,
                            BaseException
Get the Hardware that was used in this event.

Returns:
A Hardwareitem or null of not known
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the hardware.
BaseException - If there is another error.

setHardware

public void setHardware(Hardware hardware)
                 throws PermissionDeniedException
Set the Hardware that was used in this event.

Parameters:
hardware - A Hardware item or null if not known.
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission on this event or use permission for the hardware.

getComment

public String getComment()
Get the comment about this event.

Returns:
The comment

setComment

public void setComment(String comment)
                throws PermissionDeniedException,
                       InvalidDataException
Set the comment about this event. The value may be null, but mustn't be longer than the value specified by the MAX_COMMENT_LENGTH constant.

Parameters:
comment - The new comment
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission on this event
InvalidDataException - If the comment is too long

getEntryDate

public Date getEntryDate()
Get the date this event was added to the database.

Specified by:
getEntryDate in interface Registered
Returns:
A Date object

getEventDate

public Date getEventDate()
Get the date this event was done in the lab.

Returns:
A Date object, or null if not known

setEventDate

public void setEventDate(Date eventDate)
                  throws PermissionDeniedException
Set the date this event was done in the lab.

Parameters:
eventDate - The date, or null if not known
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission on this event

getUser

public User getUser()
             throws PermissionDeniedException,
                    BaseException
Get the User that is responsible for this event.

Returns:
A User item
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the user
BaseException - If there is another error

2.17.2: 2011-06-17