3.0.2: 2012-01-25

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, Subtypable
Direct Known Subclasses:
Extract, 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-06-22 16:03:17 +0200 (Wed, 22 Jun 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
 Set<Annotatable> getAnnotatableParents()
          Get the biosource or pooled samples.
 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.
 ItemSubtype getItemSubtype()
          Get the subtype of the item.
 Float getOriginalQuantity()
          Get the original quantity of the biomaterial.
 BioMaterial getParent()
          Get the parent biomaterial if there is a single parent item only.
 Item getParentType()
          Get the item type of the parent biomaterial.
 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 hasSingleParent()
          Checks if this biomaterial has a single parent item or not.
 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 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.
(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, getChildCreationEvents, getExternalId, setExternalId, setItemSubtype
 
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.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, Developer documentation: Transactions, Developer documentation: 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

getAnnotatableParents

public Set<Annotatable> getAnnotatableParents()
                                       throws BaseException
Get the biosource or pooled samples.

Specified by:
getAnnotatableParents in interface Annotatable
Returns:
A set containing annotatable items, or null
Throws:
BaseException - If there is an error

getItemSubtype

@SubtypableRelatedItems(value={PROTOCOL,HARDWARE})
public ItemSubtype getItemSubtype()
Description copied from interface: Subtypable
Get the subtype of the item.

Specified by:
getItemSubtype in interface Subtypable
Overrides:
getItemSubtype in class BioMaterial<D extends MeasuredBioMaterialData>
Returns:
A subtype of null if not set
See Also:
SubtypableRelatedItems

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.


getParentType

public Item getParentType()
Get the item type of the parent biomaterial. The parent type must be either the same type as the current biomaterial or "one step up" in the Extract -- Sample -- BioSource chain.

Returns:
The parent type, or null if the biomaterial doesn't have any parents
Since:
3.0

getParent

public BioMaterial getParent()
Get the parent biomaterial if there is a single parent item only.

Returns:
The parent biomaterial or null if there is not exactly one parent
Since:
3.0
See Also:
hasSingleParent()

hasSingleParent

public boolean hasSingleParent()
Checks if this biomaterial has a single parent item or not.

Returns:
TRUE if there is exactly one parent, FALSE if there are 0 or 2 or more parents
Since:
3.0
See Also:
getParentType()

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

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

3.0.2: 2012-01-25