Package net.sf.basedb.core
Class MeasuredBioMaterial
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.BioMaterial
net.sf.basedb.core.MeasuredBioMaterial
- All Implemented Interfaces:
AccessControlled
,Annotatable
,Identifiable
,Listable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
,Subtypable
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: 2017-06-07 13:28:31 +0200 (on, 07 jun 2017) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
Transaction handler for updating the remaining quantity of a biomaterial based on the sum of the used quantity in this transaction. -
Field Summary
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
-
Method Summary
Modifier and TypeMethodDescription(package private) int
breakCircularReferences
(Set<ItemProxy> items) Any parent items found among the given items are removed from the creation event of this item.Get the biosource or pooled samples and the bioplate the biomaterial is located on.getAnnotatableParents
(Collection<? extends MeasuredBioMaterial> parents) Get the annotable parents, possible only a given set of specific parents items.Get the well this biomaterial is located in.Get the event that represents the creation of this biomaterial.(package private) MeasuredBioMaterialData
getData()
Get theBasicData
object that holds all data for this item.Get the date that the item was registered in the database.Get a query that returns all events for this biomaterial.Get the subtype of the item.Get the original quantity of the biomaterial.Get the parent biomaterial if there is a single parent item only.Get the item type of the parent biomaterial.Get the protocol from the creation event.Get the remaining quantity of the biomaterial.Get all:BioMaterial
:s where this item has been used as a sourceboolean
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
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 itemnewEvent()
Create a new event for this biomaterial.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 theBioWell
where this biomaterial is located.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.void
setOriginalQuantity
(Float originalQuantity) Set the original quantity of the biomaterial.private void
updateFreeWells
(BioPlateData plate, int delta) (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
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, 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, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, 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.Identifiable
getId, getType, getVersion
Methods inherited from interface net.sf.basedb.core.Nameable
getDescription, getName, setDescription, setName
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
-
Field Details
-
bioPlateEventParticipant
-
creationEvent
-
-
Constructor Details
-
MeasuredBioMaterial
MeasuredBioMaterial(MeasuredBioMaterialData measuredBioMaterialData)
-
-
Method Details
-
getData
MeasuredBioMaterialData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classBioMaterial
-
isUsed
Check that:- no pooled biomaterial has been created from this item
- 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:
-
getUsingItems
Get all:BioMaterial
:s where this item has been used as a source
- 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:
-
breakCircularReferences
Any parent items found among the given items are removed from the creation event of this item.- Overrides:
breakCircularReferences
in classBasicItem
- Since:
- 3.8
-
onBeforeCommit
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 classSharedItem
- Throws:
BaseException
- If there is another error- See Also:
-
getProtocol
Get the protocol from the creation event.- Specified by:
getProtocol
in interfaceAnnotatable
- Overrides:
getProtocol
in classAnnotatedItem
- Returns:
- Always null
- Since:
- 2.2
-
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
-
getAnnotatableParents
Get the biosource or pooled samples and the bioplate the biomaterial is located on.- Specified by:
getAnnotatableParents
in interfaceAnnotatable
- Overrides:
getAnnotatableParents
in classBioMaterial
- Returns:
- A set containing annotatable items, or null
- Throws:
BaseException
- If there is an error
-
getAnnotatableParents
public Set<Annotatable> getAnnotatableParents(Collection<? extends MeasuredBioMaterial> parents) throws BaseException Get the annotable parents, possible only a given set of specific parents items.- Parameters:
parents
- If not null or empty, only include the given parent items (for pooled items only)- Throws:
BaseException
- Since:
- 3.3
-
getItemSubtype
Description copied from interface:Subtypable
Get the subtype of the item.- Specified by:
getItemSubtype
in interfaceSubtypable
- Overrides:
getItemSubtype
in classBioMaterial
- Returns:
- A subtype of null if not set
- See Also:
-
getCreationEvent
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
-
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 permissionInvalidDataException
- If the original quantity is below zeroBaseException
- If there is some other kind of error.
-
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 thenewEvent()
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 theusedQuantity
parameter is null or if the remaining quantity is null. -
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
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
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:
-
newEvent
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 biomaterialBaseException
- 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 biomaterialBaseException
- If there is another error- Since:
- 2.17
-
getEvents
Get a query that returns all events for this biomaterial.- Returns:
- An
ItemQuery
object
-
setBioWell
Sets theBioWell
where this biomaterial is located.- Parameters:
well
- TheBioWell
to set.- Throws:
ItemInUseException
- If the well is already used by another biomaterialPermissionDeniedException
- If logged in user doesn't havePermission.WRITE
for this MeasuredBioMaterial orPermission.USE
for the BioWell.BaseException
- If there is another error.- Since:
- 2.10
-
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
-
updateFreeWells
-
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
-