Class PlateMapping
- 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.PlateMapping
-
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
public class PlateMapping extends CommonItem implements Registered
This class represents a mapping from one plate geometry to another. Given one or more plates of some specific geometry, a mapping creates one or more new plates of some other or the same geometry. The new plates and their wells will be linked to the plates and wells they were created from.A mapping is specified by a set of source/destination coordinate pairs. A coordinate is specified by plate number, row and column. With this information it is possible to pick wells from the source plates and link them to wells on the destination plates.
It is not required that the mapping is complete, ie. contains a mapping for each destination coordinate. Such destination wells will be marked as empty. A destination coordinate may only be mapped to one source coordinate, but it is possible that one source coordinate is mapped to several destination coordinates.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
Plate
,PlateGeometry
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_IMAGE_LENGTH
The maximum length of the image name that can be stored in the database.static Item
TYPE
The type of item represented by this class.-
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
-
Constructor Summary
Constructors Constructor Description PlateMapping(PlateMappingData plateMappingData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Plate>
apply(List<Plate> sourcePlates, PlateType destinationPlateType)
Apply this mapping to the given list of source plates and generate new plates of the specified type.private void
checkCoordinate(MappingCoordinate c, int plateCount, PlateGeometryData geometry, boolean destination)
Checks that the coordinate is within the bouds given by the mapping and geometry.static PlateMapping
getById(DbControl dc, int id)
Get aPlateMapping
item when you know the id.(package private) PlateMappingData
getData()
Get theBasicData
object that holds all data for this item.int
getDestinationCount()
Get the number of produced destination plates.PlateGeometry
getDestinationGeometry()
Get thePlateGeometry
of the created plates.Date
getEntryDate()
Get the date that the item was registered in the database.String
getImage()
Get the name of a small image that is a graphical representation of the mapping.static PlateMapping
getNew(DbControl dc, PlateGeometry sourceGeometry, int sourceCount, PlateGeometry destinationGeometry, int destinationCount)
Create a newPlateMapping
item.static ItemQuery<PlateMapping>
getQuery()
Get a query that returns plate mappings.MappingCoordinate
getSourceCoordinate(MappingCoordinate destinationCoordinate)
Get the source coordinate for a given destination coordinate.int
getSourceCount()
Get the number of required source plates.PlateGeometry
getSourceGeometry()
Get thePlateGeometry
that is required for source plates.Item
getType()
Get the type of item represented by the object.Set<ItemProxy>
getUsingItems()
Get all:Plate
:s created with this mappingboolean
isUsed()
Check if: APlate
has been created from this mappingprivate void
setDestinationCount(int destinationCount)
Set the number of produced destination plates.private void
setDestinationGeometry(PlateGeometry destinationGeometry)
Set the destination geometry.void
setEntryDate(Date entryDate)
Set the date the entry was registered in the database.void
setImage(String image)
Set the name of a small image that is a graphical representation of the mapping.void
setSourceCoordinate(MappingCoordinate destinationCoordinate, MappingCoordinate sourceCoordinate)
Set the source coordinate for a given destination coordinate.private void
setSourceCount(int sourceCount)
Set the number of source plates.private void
setSourceGeometry(PlateGeometry sourceGeometry)
Set the source geometry.-
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, onBeforeCommit, 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, breakCircularReferences, 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, getVersion
-
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
-
-
-
-
Field Detail
-
TYPE
public static final Item TYPE
The type of item represented by this class.- See Also:
Item.PLATEMAPPING
,getType()
-
MAX_IMAGE_LENGTH
public static final int MAX_IMAGE_LENGTH
The maximum length of the image name that can be stored in the database. Check the length against this value before calling thesetImage(String)
method to avoid exceptions.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlateMapping
PlateMapping(PlateMappingData plateMappingData)
-
-
Method Detail
-
getNew
public static PlateMapping getNew(DbControl dc, PlateGeometry sourceGeometry, int sourceCount, PlateGeometry destinationGeometry, int destinationCount) throws PermissionDeniedException, InvalidDataException, BaseException
Create a newPlateMapping
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accesssourceGeometry
- The required geometry of the source platessourceCount
- The number of source platesdestinationGeometry
- The geometry of the created destination platesdestinationCount
- The number of created destination plates- Returns:
- The new
PlateMapping
item - Throws:
PermissionDeniedException
- If the loggged in user doesn't have use permission for the geometriesInvalidDataException
- If any of the geometries are null, or any of the count values are less than oneBaseException
- If there is another error
-
getById
public static PlateMapping getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aPlateMapping
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
PlateMapping
item - Throws:
ItemNotFoundException
- If an item with the specified id is not foundPermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is another error
-
getQuery
public static ItemQuery<PlateMapping> getQuery()
Get a query that returns plate mappings.- Returns:
- An
ItemQuery
object
-
getData
PlateMappingData getData()
Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classCommonItem
-
getType
public 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
-
getEntryDate
public Date 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
public void setEntryDate(Date entryDate)
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
-
isUsed
public boolean isUsed() throws BaseException
Check if:- A
Plate
has been created from this mapping
- 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:
BasicItem.getUsingItems()
- A
-
getUsingItems
public Set<ItemProxy> getUsingItems()
Get all:Plate
:s created with this mapping
- 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:
BasicItem.addUsingItems(Set, Item, org.hibernate.query.Query)
-
getSourceGeometry
public PlateGeometry getSourceGeometry() throws PermissionDeniedException, BaseException
Get thePlateGeometry
that is required for source plates.- Returns:
- A
PlateGeometry
item - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission for the plate geometryBaseException
- If there is another error
-
setSourceGeometry
private void setSourceGeometry(PlateGeometry sourceGeometry) throws PermissionDeniedException, InvalidDataException
Set the source geometry.- Throws:
PermissionDeniedException
- If the logged in user doesn't have use permission for the geometryInvalidDataException
- If the geometry is null
-
getSourceCount
public int getSourceCount()
Get the number of required source plates.
-
setSourceCount
private void setSourceCount(int sourceCount) throws InvalidDataException
Set the number of source plates.- Throws:
InvalidDataException
- If the source count is less than one
-
getDestinationGeometry
public PlateGeometry getDestinationGeometry() throws PermissionDeniedException, BaseException
Get thePlateGeometry
of the created plates.- Returns:
- A
PlateGeometry
item - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission for the plate geometryBaseException
- If there is another error
-
setDestinationGeometry
private void setDestinationGeometry(PlateGeometry destinationGeometry) throws PermissionDeniedException, InvalidDataException
Set the destination geometry.- Throws:
PermissionDeniedException
- If the logged in user doesn't have use permission for the geometryInvalidDataException
- If the geometry is null
-
getDestinationCount
public int getDestinationCount()
Get the number of produced destination plates.
-
setDestinationCount
private void setDestinationCount(int destinationCount) throws InvalidDataException
Set the number of produced destination plates.- Throws:
InvalidDataException
- If the destination count is less than one
-
getImage
public String getImage()
Get the name of a small image that is a graphical representation of the mapping.- Returns:
- The name of an image or null
-
setImage
public void setImage(String image) throws PermissionDeniedException, InvalidDataException
Set the name of a small image that is a graphical representation of the mapping. Null is allowed but the value can't be longer than the value specified by theMAX_IMAGE_LENGTH
constant.- Parameters:
image
- The name of the image- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the value is too long
-
getSourceCoordinate
public MappingCoordinate getSourceCoordinate(MappingCoordinate destinationCoordinate)
Get the source coordinate for a given destination coordinate.- Parameters:
destinationCoordinate
- The destination coordinate- Returns:
- A
MappingCoordinate
object or null if no source coordinate has been specified
-
setSourceCoordinate
public void setSourceCoordinate(MappingCoordinate destinationCoordinate, MappingCoordinate sourceCoordinate) throws PermissionDeniedException, InvalidDataException
Set the source coordinate for a given destination coordinate.- Parameters:
destinationCoordinate
- The destination coordinatesourceCoordinate
- The source coordinate, or null to remove the mapping for the destination coordinate- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission or if the mapping has been saved to the databaseInvalidDataException
- If the destination coordinate is null or any of the coordinates are outside the range of valid coordinates as specified by the geometries
-
checkCoordinate
private void checkCoordinate(MappingCoordinate c, int plateCount, PlateGeometryData geometry, boolean destination) throws InvalidDataException
Checks that the coordinate is within the bouds given by the mapping and geometry.- Throws:
InvalidDataException
-
apply
public List<Plate> apply(List<Plate> sourcePlates, PlateType destinationPlateType) throws PermissionDeniedException, InvalidDataException, BaseException
Apply this mapping to the given list of source plates and generate new plates of the specified type. The source plates must all be of the geometry specified bygetSourceGeometry()
and the destroyed flag mustn't be set. The list must contain exactly the required number of plates as specified by @link #getSourceCount()}. The destination plate type must be of the required destination geometry,getDestinationGeometry()
.The new plates are not saved to the database and doesn't have any names, descriptions or other information. It is up to the client application to fill in this information and save the new plates.
- Parameters:
sourcePlates
- AList
containingPlate
itemsdestinationPlateType
- ThePlateType
of the destination plates- Returns:
- A
List
containing the new (unsaved)Plate
items - Throws:
PermissionDeniedException
- If the logged in user doesn't have use permission for this plate mapping and to all source platesInvalidDataException
- If any of the parameters are invalidBaseException
- If there is another error
-
-