2.17.2: 2011-06-17

net.sf.basedb.core
Class PlateMapping

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<PlateMappingData>
                  extended by net.sf.basedb.core.PlateMapping
All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Ownable, Registered, Removable, Shareable

public class PlateMapping
extends CommonItem<PlateMappingData>
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: 2010-10-27 14:32:44 +0200 (Wed, 27 Oct 2010) $

Field Summary
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
PlateMapping(PlateMappingData plateMappingData)
           
 
Method Summary
 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 a PlateMapping item when you know the id.
 int getDestinationCount()
          Get the number of produced destination plates.
 PlateGeometry getDestinationGeometry()
          Get the PlateGeometry 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 new PlateMapping 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 the PlateGeometry 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 mapping
 boolean isUsed()
          Check if: A Plate has been created from this mapping
private  void setDestinationCount(int destinationCount)
          Set the number of produced destination plates.
private  void setDestinationGeometry(PlateGeometry destinationGeometry)
          Set the destination geometry.
 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, isRemoved, setDescription, setName, setRemoved, toTransferable
 
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, 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, 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

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 the setImage(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 new PlateMapping item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
sourceGeometry - The required geometry of the source plates
sourceCount - The number of source plates
destinationGeometry - The geometry of the created destination plates
destinationCount - 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 geometries
InvalidDataException - If any of the geometries are null, or any of the count values are less than one
BaseException - If there is another error

getById

public static PlateMapping getById(DbControl dc,
                                   int id)
                            throws ItemNotFoundException,
                                   PermissionDeniedException,
                                   BaseException
Get a PlateMapping item when you know the id.

Parameters:
dc - The DbControl 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 found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

getQuery

public static ItemQuery<PlateMapping> getQuery()
Get a query that returns plate mappings.

Returns:
An ItemQuery object

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 the Item enumeration.

Specified by:
getType in interface Identifiable
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 interface Registered
Returns:
A date or null if this is not known

isUsed

public boolean isUsed()
               throws BaseException
Check if:

Overrides:
isUsed in class BasicItem<PlateMappingData>
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:

getSourceGeometry

public PlateGeometry getSourceGeometry()
                                throws PermissionDeniedException,
                                       BaseException
Get the PlateGeometry that is required for source plates.

Returns:
A PlateGeometry item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission for the plate geometry
BaseException - 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 geometry
InvalidDataException - 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 the PlateGeometry of the created plates.

Returns:
A PlateGeometry item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission for the plate geometry
BaseException - 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 geometry
InvalidDataException - 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 the MAX_IMAGE_LENGTH constant.

Parameters:
image - The name of the image
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - 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 coordinate
sourceCoordinate - 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 database
InvalidDataException - 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 by getSourceGeometry() 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 - A List containing Plate items
destinationPlateType - The PlateType 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 plates
InvalidDataException - If any of the parameters are invalid
BaseException - If there is another error

2.17.2: 2011-06-17