2.17.2: 2011-06-17

net.sf.basedb.core
Class MeasuredBioMaterial<D extends MeasuredBioMaterialData>

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<D>
                  extended by net.sf.basedb.core.AnnotatedItem<D>
                      extended by net.sf.basedb.core.BioMaterial<D>
                          extended by net.sf.basedb.core.MeasuredBioMaterial<D>
All Implemented Interfaces:
AccessControlled, Annotatable, Identifiable, Nameable, Ownable, Registered, Removable, Shareable
Direct Known Subclasses:
Extract, LabeledExtract, Sample

public abstract class MeasuredBioMaterial<D extends MeasuredBioMaterialData>
extends BioMaterial<D>
implements Registered

This class is the base class for measured biomaterial items. A measured item is an item which can have original and remaining quantities associated with them.

The core keeps track of the remaining quantity whenever an item is used to create other items. As it is, an item can be used when creating another item of the same type (pooling) or when creating an item of the appropriate subtype, ie. Sample -> Extract -> LabeledExtract.

It is also possible to add a note using a BioMaterialEvent saying that the quantity has been changed and why.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2011-02-09 14:49:51 +0100 (Wed, 09 Feb 2011) $

Field Summary
private  BioPlateEventParticipant bioPlateEventParticipant
           
private  BioMaterialEvent creationEvent
           
 
Fields inherited from class net.sf.basedb.core.BioMaterial
MAX_EXTERNAL_ID_LENGTH
 
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Constructor Summary
MeasuredBioMaterial(D measuredBioMaterialData)
           
 
Method Summary
 BioWell getBioWell()
          Get the well this biomaterial is located in.
 BioMaterialEvent getCreationEvent()
          Get the event that represents the creation of this biomaterial.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 ItemQuery<BioMaterialEvent> getEvents()
          Get a query that returns all events for this biomaterial.
 Float getOriginalQuantity()
          Get the original quantity of the biomaterial.
 ItemQuery<BioMaterialEvent> getPoolingEvents()
          Get a query that returns all events where this biomaterial has been used as a source.
 Protocol getProtocol()
          Get the protocol from the creation event.
 Float getRemainingQuantity()
          Get the remaining quantity of the biomaterial.
 Set<ItemProxy> getUsingItems()
          Get all: BioMaterial:s where this item has been used as a source
 boolean isInWell()
          Check if this biomaterial is located in a well on a bioplate or not.
 boolean isLockedInWell()
          Check if this biomaterial is placed in a well that it can't be removed from.
 boolean isPooled()
          Check if this biomaterial was created by pooling or not.
 boolean isUsed()
          Check that: no pooled biomaterial has been created from this item
 BioMaterialEvent newEvent()
          Create a new event for this biomaterial.
 BioMaterialEvent newEvent(BioPlateEventParticipant master)
          Create a new event for this biomaterial that is part of a master bioplate event.
(package private)  void onBeforeCommit(Transactional.Action action)
          Make sure the creation event is created at the same time this item is created and that source biomaterials get their used quantities back if this item is deleted.
(package private)  void setBioPlateEventParticipant(BioPlateEventParticipant bioPlateEventParticipant)
           
 void setBioWell(BioWell well)
          Sets the BioWell where this biomaterial is located.
 void setOriginalQuantity(Float originalQuantity)
          Set the original quantity of the biomaterial.
 void setPooled(boolean pooled)
          Specify if this biomaterial was created by pooling or not.
(package private) static void updateRemainingQuantity(DbControl dc, MeasuredBioMaterialData bioMaterial, Float usedQuantity)
          Update the remaining quantity of a biomaterial.
 
Methods inherited from class net.sf.basedb.core.BioMaterial
countChildren, getById, getExternalId, setExternalId
 
Methods inherited from class net.sf.basedb.core.AnnotatedItem
getAnnotationSet, isAnnotated, removeAnnotations, toTransferable
 
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, 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, 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, getType, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 
Methods inherited from interface net.sf.basedb.core.Annotatable
getAnnotatableParents
 
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
 

Field Detail

bioPlateEventParticipant

private BioPlateEventParticipant bioPlateEventParticipant

creationEvent

private BioMaterialEvent creationEvent
Constructor Detail

MeasuredBioMaterial

MeasuredBioMaterial(D measuredBioMaterialData)
Method Detail

isUsed

public boolean isUsed()
               throws BaseException
Check that:

Overrides:
isUsed in class BasicItem<D extends MeasuredBioMaterialData>
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:

onBeforeCommit

void onBeforeCommit(Transactional.Action action)
              throws BaseException
Make sure the creation event is created at the same time this item is created and that source biomaterials get their used quantities back if this item is deleted. All events are deleted by cascade mapping in Hibernate.

Overrides:
onBeforeCommit in class BioMaterial<D extends MeasuredBioMaterialData>
Throws:
BaseException - If there is another error
See Also:
Transactional, Core API overview - Transaction handling, Coding rules and guidelines for item classes

getProtocol

public Protocol getProtocol()
Get the protocol from the creation event.

Specified by:
getProtocol in interface Annotatable
Overrides:
getProtocol in class AnnotatedItem<D extends MeasuredBioMaterialData>
Returns:
Always null
Since:
2.2

getEntryDate

public Date getEntryDate()
Description copied from interface: Registered
Get the date that the item was registered in the database.

Specified by:
getEntryDate in interface Registered
Returns:
A date or null if this is not known

getCreationEvent

public BioMaterialEvent getCreationEvent()
                                  throws PermissionDeniedException,
                                         BaseException
Get the event that represents the creation of this biomaterial.

Returns:
A BioMaterialEvent data.
Throws:
PermissionDeniedException - If logged in user doesn't have read permission on the biomaterial.
BaseException - If there is some other error.

setBioPlateEventParticipant

void setBioPlateEventParticipant(BioPlateEventParticipant bioPlateEventParticipant)

getOriginalQuantity

public Float getOriginalQuantity()
Get the original quantity of the biomaterial.

Returns:
A Float holding the original quantity, or null if not known

setOriginalQuantity

public void setOriginalQuantity(Float originalQuantity)
                         throws PermissionDeniedException,
                                InvalidDataException,
                                BaseException
Set the original quantity of the biomaterial. If the remaining quantity is null, it's value is also set to the same as the original value.

Parameters:
originalQuantity - The new value for the original quantity, or null if not known
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the original quantity is below zero
BaseException - If there is some other kind of error.

getRemainingQuantity

public Float getRemainingQuantity()
Get the remaining quantity of the biomaterial. The remaining quantity cannot be modified directly. It is calculated based on the events for this biomaterial. Use the newEvent() method to get an event object where you can specify the used quantity.

Returns:
A Float holding the remaining quantity or null if not known

updateRemainingQuantity

static void updateRemainingQuantity(DbControl dc,
                                    MeasuredBioMaterialData bioMaterial,
                                    Float usedQuantity)
Update the remaining quantity of a biomaterial. This method does nothing if the usedQuantity parameter is null or if the remaining quantity is null.


isPooled

public boolean isPooled()
Check if this biomaterial was created by pooling or not.

Returns:
TRUE if pooled, FALSE otherwise.

setPooled

public void setPooled(boolean pooled)
               throws PermissionDeniedException,
                      BaseException
Specify if this biomaterial was created by pooling or not. Changing this property also clears the parent biomaterial and the sources collection for the creation event.

Parameters:
pooled - set to TRUE if pooled, FALSE otherwise.
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
BaseException - If there is another error
See Also:
BioMaterialEvent.getSources()

newEvent

public BioMaterialEvent newEvent()
                          throws PermissionDeniedException,
                                 BaseException
Create a new event for this biomaterial.

Returns:
a BioMaterialEvent object.
Throws:
PermissionDeniedException - If the logged in user doesn't have use permission for this biomaterial
BaseException - If there is another error

newEvent

public BioMaterialEvent newEvent(BioPlateEventParticipant master)
                          throws PermissionDeniedException,
                                 BaseException
Create a new event for this biomaterial that is part of a master bioplate event.

Returns:
a BioMaterialEvent object.
Throws:
PermissionDeniedException - If the logged in user doesn't have use permission for this biomaterial
BaseException - If there is another error
Since:
2.17

getEvents

public ItemQuery<BioMaterialEvent> getEvents()
Get a query that returns all events for this biomaterial.

Returns:
An ItemQuery object

getPoolingEvents

public ItemQuery<BioMaterialEvent> getPoolingEvents()
Get a query that returns all events where this biomaterial has been used as a source.

Returns:
An ItemQuery object
Since:
2.9

setBioWell

public void setBioWell(BioWell well)
                throws PermissionDeniedException,
                       BaseException
Sets the BioWell where this biomaterial is located.

Parameters:
well - The BioWell to set.
Throws:
ItemInUseException - If the well is already used by another biomaterial
PermissionDeniedException - If logged in user doesn't have Permission.WRITE for this MeasuredBioMaterial or Permission.USE for the BioWell.
BaseException - If there is another error.
Since:
2.10

getBioWell

public BioWell getBioWell()
Get the well this biomaterial is located in.

Returns:
A BioWell object or null if this biomaterial is not located on a plate
Since:
2.10

isInWell

public boolean isInWell()
Check if this biomaterial is located in a well on a bioplate or not.

Returns:
TRUE if the biomaterial is in a well, FALSE if not
Since:
2.17

isLockedInWell

public boolean isLockedInWell()
Check if this biomaterial is placed in a well that it can't be removed from.

Returns:
TRUE if the biomaterial is locked, FALSE if is not in a well or in a well that allows moving it
Since:
2.16

2.17.2: 2011-06-17