Package net.sf.basedb.core
Class BioMaterialEvent
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.ChildItem
net.sf.basedb.core.BioMaterialEvent
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Registered
This class represents an event in the life of a
MeasuredBioMaterial
.
There are three main types of events: creation events,
hybridization events and other events. A creation event is an event that
produces a measured biomaterial from other biomaterials. A hybridization event
is an event that produces a hybridization from labeled extracts. Other events
are used to leave a note about something that affected an already existing biomaterial.- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2019-02-26 11:10:15 +0100 (tis, 26 feb. 2019) $
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
static final int
The maximum length of the comment about this event.private boolean
static final Item
The type of item represented by this class. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate BioMaterialEventSource
addCheckedSource
(BioMaterial bioMaterial) addSource
(BioMaterial bioMaterial) Add a biomaterial as a source to this event.private void
checkAllowedSource
(BioMaterial source, boolean forAdd) Check if the biomaterial is allowed as a source.void
Clear the sources collection and return the used quantities to the source biomaterials.private void
clearSourcesExcept
(BioMaterial parent) Clear the sources collection and return the used quantities to the source biomaterials, except for the given biomaterial.(package private) static void
Ensure that theMeasuredBioMaterial.getParent()
andMeasuredBioMaterial.getParentType()
reflect the current sources collection.Get theMeasuredBioMaterial
that was affected or created by this event.Get the bioplate event participant that is the master of this event.static BioMaterialEvent
Get aBioMaterialEvent
item when you know the id.Get the comment about this event.(package private) BioMaterialEventData
getData()
Get theBasicData
object that holds all data for this item.Get the date this event was added to the database.Get the date this event was done in the lab.getEventSource
(BioMaterial bioMaterial) Get information about a biomaterial used as a source to this event.Create a special query that return BioMaterialEventSource objects.getEventSources
(DbControl dc, int position) Utility method for finding all sources on a given bioassay position.Get the type of event.Get theHardware
that was used in this event.getKit()
Get theKit
that was used in this event.static BioMaterialEvent
getNew
(DbControl dc, MeasuredBioMaterial bioMaterial) Create a newBioMaterialEvent
of theBioMaterialEvent.Type.OTHER
type.static BioMaterialEvent
getNew
(DbControl dc, MeasuredBioMaterial bioMaterial, BioPlateEventParticipant master) Create a newBioMaterialEvent
of theBioMaterialEvent.Type.OTHER
type that is linked with a masterBioPlateEventParticipant
.(package private) static BioMaterialEvent
getNewBioAssayEvent
(DbControl dc, PhysicalBioAssay physicalBioAssay, BioPlateEventParticipant master) Create a newBioMaterialEvent
of theBioMaterialEvent.Type.BIOASSAY
type.(package private) static BioMaterialEvent
getNewCreationEvent
(DbControl dc, MeasuredBioMaterial bioMaterial, BioPlateEventParticipant master) Create a newBioMaterialEvent
of theBioMaterialEvent.Type.CREATION
type (creation event).Get thePhysicalBioAssay
that was created by this event.Get theProtocol
describing the procedure used in this event.static ItemQuery<BioMaterialEvent>
getQuery
(MeasuredBioMaterial bioMaterial) Get a query that returns events for a biomaterial.(package private) SharedData
Get the shareable parent item of this child item.<T extends BioMaterial>
ItemQuery<T>Get a query that return all biomaterials used as sources for this event.getType()
Get the type of item represented by the object.Get the quantity that was used from the biomaterial by this event.getUsedQuantity
(MeasuredBioMaterial bioMaterial) Get the quantity that was used by this event for the specified biomaterial.getUser()
Get theUser
that is responsible for this event.(package private) void
initPermissions
(int granted, int denied) READ permission is granted and DELETE permissions is denied to evereyone for creation events.boolean
Check if this event is related with a bioplate event.boolean
isSource
(BioMaterial bioMaterial) Check if the given biomaterial has been used as a source in this event.(package private) void
onBeforeCommit
(Transactional.Action action) Return used guantity to biomaterials on delete action.void
removeSource
(BioMaterial bioMaterial) Remove a biomaterial used as a source.private void
setBioMaterial
(MeasuredBioMaterial bioMaterial) Set the biomaterial that was affected or created by this event.void
setComment
(String comment) Set the comment about this event.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.void
setEventDate
(Date eventDate) Set the date this event was done in the lab.void
setHardware
(Hardware hardware) Get theHardware
that was used in this event.void
Set theKit
that was used in this event.private void
setPhysicalBioAssay
(PhysicalBioAssay physicalBioAssay) Set the hybidization that was created by this event.(package private) void
setProjectDefaults
(Project activeProject) Set protocol and hardware from project default settings.void
setProtocol
(Protocol protocol) Set theProtocol
that describes the procedure used in this event.setSource
(BioMaterial parent) Set a single parent item for this event.void
setUsedQuantity
(Float usedQuantity) Set the used quantity.Methods inherited from class net.sf.basedb.core.ChildItem
getPermissionForUse, getPermissionForWriteDeleteAndCreate, getPluginPermissions
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, 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, getVersion
-
Field Details
-
TYPE
The type of item represented by this class.- See Also:
-
protocolHasBeenSet
private boolean protocolHasBeenSet -
hardwareHasBeenSet
private boolean hardwareHasBeenSet -
MAX_COMMENT_LENGTH
public static final int MAX_COMMENT_LENGTHThe maximum length of the comment about this event. Check the length against this value before calling thesetComment(String)
method to avoid exceptions.- See Also:
-
-
Constructor Details
-
BioMaterialEvent
BioMaterialEvent(BioMaterialEventData bioMaterialEventData)
-
-
Method Details
-
getNew
public static BioMaterialEvent getNew(DbControl dc, MeasuredBioMaterial bioMaterial) throws BaseException Create a newBioMaterialEvent
of theBioMaterialEvent.Type.OTHER
type.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessbioMaterial
- The affected biomaterial- Returns:
- The new
BioMaterialEvent
item - Throws:
BaseException
- If there is an error
-
getNew
public static BioMaterialEvent getNew(DbControl dc, MeasuredBioMaterial bioMaterial, BioPlateEventParticipant master) throws BaseException Create a newBioMaterialEvent
of theBioMaterialEvent.Type.OTHER
type that is linked with a masterBioPlateEventParticipant
. If a master bioplate event is used it must be a new event that has not yet been saved to the database.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessbioMaterial
- The affected biomaterialmaster
- The master bioplate event or null- Returns:
- The new
BioMaterialEvent
item - Throws:
BaseException
- If there is an error- Since:
- 2.17
-
getNewCreationEvent
static BioMaterialEvent getNewCreationEvent(DbControl dc, MeasuredBioMaterial bioMaterial, BioPlateEventParticipant master) throws BaseException Create a newBioMaterialEvent
of theBioMaterialEvent.Type.CREATION
type (creation event).- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessbioMaterial
- The biomaterial that was created.master
- The master bioplate event or null- Returns:
- The new
BioMaterialEvent
item - Throws:
BaseException
- If there is an error- Since:
- 2.17
-
getNewBioAssayEvent
static BioMaterialEvent getNewBioAssayEvent(DbControl dc, PhysicalBioAssay physicalBioAssay, BioPlateEventParticipant master) throws BaseException Create a newBioMaterialEvent
of theBioMaterialEvent.Type.BIOASSAY
type.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessphysicalBioAssay
- The hybridization that was created.master
- The master bioplate event or null- Returns:
- The new
BioMaterialEvent
item - Throws:
BaseException
- If there is an error- Since:
- 2.17
-
getById
public static BioMaterialEvent getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aBioMaterialEvent
item when you know the id.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The id of the item to load- Returns:
- The
BioMaterialEvent
item - Throws:
ItemNotFoundException
- If an item with the specified id is not foundPermissionDeniedException
- If the logged in user doesn't have read permission to the itemBaseException
- If there is another error
-
getQuery
public static ItemQuery<BioMaterialEvent> getQuery(MeasuredBioMaterial bioMaterial) throws InvalidDataException Get a query that returns events for a biomaterial. All events where the given biomaterial is either a source or a product are returned.- Parameters:
bioMaterial
- The biomaterial to retreive events for, null is not allowed- Returns:
- An
ItemQuery
object - Throws:
InvalidDataException
- If thebioMaterial
is null- See Also:
-
getData
BioMaterialEventData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this 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 theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- Returns:
- A value indicating the type of item
-
onBeforeCommit
Return used guantity to biomaterials on delete action.- Overrides:
onBeforeCommit
in classBasicItem
- Throws:
BaseException
- If there is an error- See Also:
-
initPermissions
READ permission is granted and DELETE permissions is denied to evereyone for creation events. WRITE permission is denied if this event is associated with a plate event. Other permissions are always checked on the parent biomaterial or hybridization.- Overrides:
initPermissions
in classChildItem
- Parameters:
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass- Throws:
BaseException
- If the permissions couldn't be initialised
-
setProjectDefaults
Set protocol and hardware from project default settings.- Overrides:
setProjectDefaults
in classBasicItem
- Parameters:
activeProject
- The currently active project- Throws:
BaseException
- Since:
- 2.9
-
getEventType
Get the type of event.- See Also:
-
getBioMaterial
Get theMeasuredBioMaterial
that was affected or created by this event.- Returns:
- A
MeasuredBioMaterial
item or null if this is hybridization event - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the biomaterialBaseException
- If there is another error
-
setBioMaterial
private void setBioMaterial(MeasuredBioMaterial bioMaterial) throws PermissionDeniedException, InvalidDataException Set the biomaterial that was affected or created by this event. -
getPhysicalBioAssay
Get thePhysicalBioAssay
that was created by this event.- Returns:
- A
PhysicalBioAssay
item or null if this isn't a bioassay event - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the bioassayBaseException
- If there is another error
-
setPhysicalBioAssay
private void setPhysicalBioAssay(PhysicalBioAssay physicalBioAssay) throws PermissionDeniedException, InvalidDataException Set the hybidization that was created by this event. -
isPlateEvent
public boolean isPlateEvent()Check if this event is related with a bioplate event.- Since:
- 2.17
-
getBioPlateEventParticipant
Get the bioplate event participant that is the master of this event. If this event has a master event, many properties such as event date, protocol, etc. must be set on the master event.- Returns:
- A bioplate event participant or null
- Since:
- 2.17
-
getUser
Get theUser
that is responsible for this event.- Returns:
- A
User
item - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the userBaseException
- If there is another error
-
getProtocol
Get theProtocol
describing the procedure used in this event.- Returns:
- A
Protocol
item, or null if not known - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the protocolBaseException
- If there is another error
-
setProtocol
Set theProtocol
that describes the procedure used in this event.- Parameters:
protocol
- AProtocol
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 protocol
-
getHardware
Get theHardware
that was used in this event.- Returns:
- A
Hardware
item, or null if not known - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the hardwareBaseException
- If there is another error
-
setHardware
Get theHardware
that was used in this event.- Parameters:
hardware
- AHardware
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
-
getKit
Get theKit
that was used in this event.- Returns:
- A
Kit
item, or null if not known - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the kitBaseException
- If there is another error- Since:
- 3.7
-
setKit
Set theKit
that was used in this event.- Parameters:
kit
- AKit
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 kit- Since:
- 3.7
-
getUsedQuantity
Get the quantity that was used from the biomaterial by this event. If this is a creation event this value is the negative value of the original quantity of the created biomaterial. -
setUsedQuantity
Set the used quantity.- Parameters:
usedQuantity
- The quantity to set.- Throws:
PermissionDeniedException
- If logged in user doesn't have write permission on current item.
-
getUsedQuantity
Get the quantity that was used by this event for the specified biomaterial.- Parameters:
bioMaterial
- A biomaterial object
-
getEventSource
Get information about a biomaterial used as a source to this event.- Parameters:
bioMaterial
- The biomaterial- Returns:
- A BioMaterialEventSource object or null if the given biomaterial is not a source to the event
- Since:
- 3.0
- See Also:
-
isSource
Check if the given biomaterial has been used as a source in this event.- Parameters:
bioMaterial
- The biomaterial to check
-
setSource
Set a single parent item for this event. Any sources that are currently associated with it are removed and the used quantity is returned.- Parameters:
parent
- The parent biomaterial, or null to remove all parents- Since:
- 3.0
-
addSource
Add a biomaterial as a source to this event. If the given biomaterial already is a source, the existing information is returned. If this event already has sources the new source must be of the same type as the existing sources and the produced biomaterial.- Parameters:
bioMaterial
- The biomaterial (null is not allowed)- Returns:
- A BioMaterialEventSource object
- Since:
- 3.0
-
addCheckedSource
-
removeSource
public void removeSource(BioMaterial bioMaterial) throws PermissionDeniedException, InvalidDataException, BaseException Remove a biomaterial used as a source. Sources can only be specified if the produced biomaterial is a pooled biomaterial and this is a creation event.- Parameters:
bioMaterial
- The biomaterial used as a source- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission for this event of use permission for the sourceInvalidDataException
- If this is not a creation event or if the produced biomaterial is not pooled or if the source biomaterial is of another typeBaseException
- If there is another error- Since:
- 3.0
-
ensureProductParentCorrectness
Ensure that theMeasuredBioMaterial.getParent()
andMeasuredBioMaterial.getParentType()
reflect the current sources collection. -
checkAllowedSource
private void checkAllowedSource(BioMaterial source, boolean forAdd) throws PermissionDeniedException, InvalidDataException, BaseException Check if the biomaterial is allowed as a source. -
clearSources
public void clearSources()Clear the sources collection and return the used quantities to the source biomaterials.- Since:
- 3.0
-
clearSourcesExcept
Clear the sources collection and return the used quantities to the source biomaterials, except for the given biomaterial.- Parameters:
parent
- A biomaterial that should already be a parent biomaterial or null to clear all sources- Since:
- 3.0.4
-
getSources
Get a query that return all biomaterials used as sources for this event. To filter or sort on the used quantity or position columns use 'srcevt' as alias. For example to only return sources in position 2 and to order the result by used quantity:query = event.getSources(); query.restrict(Expressions.gteq( Hql.property("srcevt", "position"), Expressions.integer(2)) ); query.order(Orders.asc(Hql.property("srcevt", "usedQuantity")));
NOTE! The filtering and ordering on the "srcevt" columns is only available in BASE 2.6 and later.
- Returns:
- An
ItemQuery
object
-
getEventSources
Create a special query that return BioMaterialEventSource objects. The objects are notBasicItem
:s but can be used to get information about and modify the source biomaterials used in the event. Note that the query may return objects that link to biomaterial that the logged in used doesn't have read access to.- Returns:
- A special query
- Since:
- 3.0
-
getEventSources
Utility method for finding all sources on a given bioassay position.- Parameters:
position
- The position number (between 1 andPhysicalBioAssay.getSize()
.- Returns:
- A list (empty if no sources are found)
-
getComment
Get the comment about this event.- Returns:
- The comment
-
setComment
Set the comment about this event. The value may be null, but mustn't be longer than the value specified by theMAX_COMMENT_LENGTH
constant.- Parameters:
comment
- The new comment- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission on this eventInvalidDataException
- If the comment is too long
-
getEntryDate
Get the date this event was added to the database.- Specified by:
getEntryDate
in interfaceRegistered
- Returns:
- A
Date
object
-
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
-
getEventDate
Get the date this event was done in the lab.- Returns:
- A
Date
object, or null if not known
-
setEventDate
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
-