public class BioMaterialEvent extends ChildItem implements Registered
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.Modifier and Type | Class and Description |
---|---|
static class |
BioMaterialEvent.Type
The type of the event.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
hardwareHasBeenSet |
static int |
MAX_COMMENT_LENGTH
The maximum length of the comment about this event.
|
private boolean |
protocolHasBeenSet |
static Item |
TYPE
The type of item represented by this class.
|
Constructor and Description |
---|
BioMaterialEvent(BioMaterialEventData bioMaterialEventData) |
Modifier and Type | Method and Description |
---|---|
private BioMaterialEventSource |
addCheckedSource(BioMaterial bioMaterial) |
BioMaterialEventSource |
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 |
clearSources()
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 |
ensureProductParentCorrectness(BioMaterialEventData event)
Ensure that the
MeasuredBioMaterial.getParent()
and MeasuredBioMaterial.getParentType() reflect the current
sources collection. |
MeasuredBioMaterial |
getBioMaterial()
Get the
MeasuredBioMaterial that was affected or created by this event. |
BioPlateEventParticipant |
getBioPlateEventParticipant()
Get the bioplate event participant that is the master of this event.
|
static BioMaterialEvent |
getById(DbControl dc,
int id)
Get a
BioMaterialEvent item when you know the id. |
java.lang.String |
getComment()
Get the comment about this event.
|
(package private) BioMaterialEventData |
getData()
Get the
BasicData object that holds all data for this item. |
java.util.Date |
getEntryDate()
Get the date this event was added to the database.
|
java.util.Date |
getEventDate()
Get the date this event was done in the lab.
|
BioMaterialEventSource |
getEventSource(BioMaterial bioMaterial)
Get information about a biomaterial used as a source to this event.
|
SpecialQuery<BioMaterialEventSource> |
getEventSources()
Create a special query that return BioMaterialEventSource objects.
|
java.util.List<BioMaterialEventSource> |
getEventSources(DbControl dc,
int position)
Utility method for finding all sources on a given bioassay
position.
|
BioMaterialEvent.Type |
getEventType()
Get the type of event.
|
Hardware |
getHardware()
Get the
Hardware that was used in this event. |
Kit |
getKit()
Get the
Kit that was used in this event. |
static BioMaterialEvent |
getNew(DbControl dc,
MeasuredBioMaterial bioMaterial)
Create a new
BioMaterialEvent of the BioMaterialEvent.Type.OTHER type. |
static BioMaterialEvent |
getNew(DbControl dc,
MeasuredBioMaterial bioMaterial,
BioPlateEventParticipant master)
Create a new
BioMaterialEvent of the BioMaterialEvent.Type.OTHER type
that is linked with a master BioPlateEventParticipant . |
(package private) static BioMaterialEvent |
getNewBioAssayEvent(DbControl dc,
PhysicalBioAssay physicalBioAssay,
BioPlateEventParticipant master)
Create a new
BioMaterialEvent of the BioMaterialEvent.Type.BIOASSAY
type. |
(package private) static BioMaterialEvent |
getNewCreationEvent(DbControl dc,
MeasuredBioMaterial bioMaterial,
BioPlateEventParticipant master)
Create a new
BioMaterialEvent of the BioMaterialEvent.Type.CREATION
type (creation event). |
PhysicalBioAssay |
getPhysicalBioAssay()
Get the
PhysicalBioAssay that was created by this event. |
Protocol |
getProtocol()
Get the
Protocol 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 |
getSharedParent()
Get the shareable parent item of this child item.
|
ItemQuery<? extends BioMaterial> |
getSources()
Get a query that return all biomaterials used as sources
for this event.
|
Item |
getType()
Get the type of item represented by the object.
|
java.lang.Float |
getUsedQuantity()
Get the quantity that was used from the biomaterial by this event.
|
java.lang.Float |
getUsedQuantity(MeasuredBioMaterial bioMaterial)
Get the quantity that was used by this event for the specified biomaterial.
|
User |
getUser()
Get the
User 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 |
isPlateEvent()
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(java.lang.String comment)
Set the comment about this event.
|
void |
setEntryDate(java.util.Date entryDate)
Set the date the entry was registered in the database.
|
void |
setEventDate(java.util.Date eventDate)
Set the date this event was done in the lab.
|
void |
setHardware(Hardware hardware)
Get the
Hardware that was used in this event. |
void |
setKit(Kit kit)
Set the
Kit 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 the
Protocol that describes the procedure used in this event. |
BioMaterialEventSource |
setSource(BioMaterial parent)
Set a single parent item for this event.
|
void |
setUsedQuantity(java.lang.Float usedQuantity)
Set the used quantity.
|
getPermissionForUse, getPermissionForWriteDeleteAndCreate, getPluginPermissions
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
public static final Item TYPE
Item.BIOMATERIALEVENT
,
getType()
private boolean protocolHasBeenSet
private boolean hardwareHasBeenSet
public static final int MAX_COMMENT_LENGTH
setComment(String)
method to avoid exceptions.BioMaterialEvent(BioMaterialEventData bioMaterialEventData)
public static BioMaterialEvent getNew(DbControl dc, MeasuredBioMaterial bioMaterial) throws BaseException
BioMaterialEvent
of the BioMaterialEvent.Type.OTHER
type.dc
- The DbControl
which will be used for
permission checking and database accessbioMaterial
- The affected biomaterialBioMaterialEvent
itemBaseException
- If there is an errorpublic static BioMaterialEvent getNew(DbControl dc, MeasuredBioMaterial bioMaterial, BioPlateEventParticipant master) throws BaseException
BioMaterialEvent
of the BioMaterialEvent.Type.OTHER
type
that is linked with a master BioPlateEventParticipant
. If a master
bioplate event is used it must be a new event that has not yet been saved to the
database.dc
- The DbControl
which will be used for
permission checking and database accessbioMaterial
- The affected biomaterialmaster
- The master bioplate event or nullBioMaterialEvent
itemBaseException
- If there is an errorstatic BioMaterialEvent getNewCreationEvent(DbControl dc, MeasuredBioMaterial bioMaterial, BioPlateEventParticipant master) throws BaseException
BioMaterialEvent
of the BioMaterialEvent.Type.CREATION
type (creation event).dc
- The DbControl
which will be used for
permission checking and database accessbioMaterial
- The biomaterial that was created.master
- The master bioplate event or nullBioMaterialEvent
itemBaseException
- If there is an errorstatic BioMaterialEvent getNewBioAssayEvent(DbControl dc, PhysicalBioAssay physicalBioAssay, BioPlateEventParticipant master) throws BaseException
BioMaterialEvent
of the BioMaterialEvent.Type.BIOASSAY
type.dc
- The DbControl
which will be used for
permission checking and database accessphysicalBioAssay
- The hybridization that was created.master
- The master bioplate event or nullBioMaterialEvent
itemBaseException
- If there is an errorpublic static BioMaterialEvent getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
BioMaterialEvent
item when you know the id.dc
- The DbControl
which will be used for
permission checking and database access.id
- The id of the item to loadBioMaterialEvent
itemItemNotFoundException
- 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 errorpublic static ItemQuery<BioMaterialEvent> getQuery(MeasuredBioMaterial bioMaterial) throws InvalidDataException
bioMaterial
- The biomaterial to retreive events for, null is not allowedItemQuery
objectInvalidDataException
- If the bioMaterial
is nullMeasuredBioMaterial.getEvents()
BioMaterialEventData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
void onBeforeCommit(Transactional.Action action) throws BaseException
onBeforeCommit
in class BasicItem
BaseException
- If there is an errorTransactional
,
Developer documentation: Transactions,
Developer documentation: Coding rules and guidelines for item classesvoid initPermissions(int granted, int denied) throws BaseException
initPermissions
in class ChildItem
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclassBaseException
- If the permissions couldn't be initialisedvoid setProjectDefaults(Project activeProject) throws BaseException
setProjectDefaults
in class BasicItem
activeProject
- The currently active projectBaseException
SharedData getSharedParent()
ChildItem
ChildItem.initPermissions(int, int)
method to calculate
the logged in user's permissions for the child item.getSharedParent
in class ChildItem
public BioMaterialEvent.Type getEventType()
BioMaterialEvent.Type
public MeasuredBioMaterial getBioMaterial() throws PermissionDeniedException, BaseException
MeasuredBioMaterial
that was affected or created by this event.MeasuredBioMaterial
item or null if this is
hybridization eventPermissionDeniedException
- If the logged in user doesn't have
read permission to the biomaterialBaseException
- If there is another errorprivate void setBioMaterial(MeasuredBioMaterial bioMaterial) throws PermissionDeniedException, InvalidDataException
public PhysicalBioAssay getPhysicalBioAssay() throws PermissionDeniedException, BaseException
PhysicalBioAssay
that was created by this event.PhysicalBioAssay
item or null if this isn't a
bioassay eventPermissionDeniedException
- If the logged in user doesn't have
read permission to the bioassayBaseException
- If there is another errorprivate void setPhysicalBioAssay(PhysicalBioAssay physicalBioAssay) throws PermissionDeniedException, InvalidDataException
public boolean isPlateEvent()
public BioPlateEventParticipant getBioPlateEventParticipant()
public User getUser() throws PermissionDeniedException, BaseException
User
that is responsible for this event.User
itemPermissionDeniedException
- If the logged in user doesn't have
read permission to the userBaseException
- If there is another errorpublic Protocol getProtocol() throws PermissionDeniedException, BaseException
Protocol
describing the procedure used in this event.Protocol
item, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
read permission to the protocolBaseException
- If there is another errorpublic void setProtocol(Protocol protocol) throws PermissionDeniedException
Protocol
that describes the procedure used in this event.protocol
- A Protocol
item, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
write permission on this event or use permission for the protocolpublic Hardware getHardware() throws PermissionDeniedException, BaseException
Hardware
that was used in this event.Hardware
item, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
read permission to the hardwareBaseException
- If there is another errorpublic void setHardware(Hardware hardware) throws PermissionDeniedException
Hardware
that was used in this event.hardware
- A Hardware
item, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
write permission on this event or use permission for the hardwarepublic Kit getKit() throws PermissionDeniedException, BaseException
Kit
that was used in this event.Kit
item, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
read permission to the kitBaseException
- If there is another errorpublic void setKit(Kit kit) throws PermissionDeniedException
Kit
that was used in this event.kit
- A Kit
item, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
write permission on this event or use permission for the kitpublic java.lang.Float getUsedQuantity()
public void setUsedQuantity(java.lang.Float usedQuantity) throws PermissionDeniedException
usedQuantity
- The quantity to set.PermissionDeniedException
- If logged in user doesn't have write
permission on current item.public java.lang.Float getUsedQuantity(MeasuredBioMaterial bioMaterial)
bioMaterial
- A biomaterial objectpublic BioMaterialEventSource getEventSource(BioMaterial bioMaterial)
bioMaterial
- The biomaterialaddSource(BioMaterial)
public boolean isSource(BioMaterial bioMaterial)
bioMaterial
- The biomaterial to checkpublic BioMaterialEventSource setSource(BioMaterial parent)
parent
- The parent biomaterial, or null to remove all parentspublic BioMaterialEventSource addSource(BioMaterial bioMaterial)
bioMaterial
- The biomaterial (null is not allowed)private BioMaterialEventSource addCheckedSource(BioMaterial bioMaterial)
public void removeSource(BioMaterial bioMaterial) throws PermissionDeniedException, InvalidDataException, BaseException
bioMaterial
- The biomaterial used as a sourcePermissionDeniedException
- 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 errorstatic void ensureProductParentCorrectness(BioMaterialEventData event)
MeasuredBioMaterial.getParent()
and MeasuredBioMaterial.getParentType()
reflect the current
sources collection.private void checkAllowedSource(BioMaterial source, boolean forAdd) throws PermissionDeniedException, InvalidDataException, BaseException
public void clearSources()
private void clearSourcesExcept(BioMaterial parent)
parent
- A biomaterial that should already be a parent biomaterial
or null to clear all sourcespublic ItemQuery<? extends BioMaterial> getSources()
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.
ItemQuery
objectpublic SpecialQuery<BioMaterialEventSource> getEventSources()
BasicItem
: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.public java.util.List<BioMaterialEventSource> getEventSources(DbControl dc, int position)
position
- The position number (between 1 and PhysicalBioAssay.getSize()
.public java.lang.String getComment()
public void setComment(java.lang.String comment) throws PermissionDeniedException, InvalidDataException
MAX_COMMENT_LENGTH
constant.comment
- The new commentPermissionDeniedException
- If the logged in user doesn't have
write permission on this eventInvalidDataException
- If the comment is too longpublic java.util.Date getEntryDate()
getEntryDate
in interface Registered
Date
objectpublic void setEntryDate(java.util.Date entryDate)
Registered
setEntryDate
in interface Registered
entryDate
- A date or null to use today's datepublic java.util.Date getEventDate()
Date
object, or null if not knownpublic void setEventDate(java.util.Date eventDate) throws PermissionDeniedException
eventDate
- The date, or null if not knownPermissionDeniedException
- If the logged in user doesn't have
write permission on this event