2.17.2: 2011-06-17

net.sf.basedb.core
Class BioMaterial<D extends BioMaterialData>

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<D>
                  extended by net.sf.basedb.core.AnnotatedItem<D>
                      extended by net.sf.basedb.core.BioMaterial<D>
All Implemented Interfaces:
AccessControlled, Annotatable, Identifiable, Nameable, Ownable, Removable, Shareable
Direct Known Subclasses:
BioSource, MeasuredBioMaterial

public abstract class BioMaterial<D extends BioMaterialData>
extends AnnotatedItem<D>

This is the base class for for the four types of biomaterials: BioSource, Sample, Extract and LabeledExtract.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2010-12-21 11:31:46 +0100 (Tue, 21 Dec 2010) $

Field Summary
static int MAX_EXTERNAL_ID_LENGTH
          The maximum length of the external id that can be stored in the database.
 
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Constructor Summary
BioMaterial(D bioMaterialData)
           
 
Method Summary
abstract  long countChildren(boolean pooled)
          Count the number of already existing children to this biomaterial.
static BioMaterial getById(DbControl dc, int id)
          Get a biomaterial item when you know the id.
 String getExternalId()
          Get the external id of the biomaterial.
(package private)  void onBeforeCommit(Transactional.Action action)
          On delete action: issue an update to decrease the size of all BioMaterialList:s this is a member of.
 void setExternalId(String externalId)
          Set the external id of the biomaterial.
 
Methods inherited from class net.sf.basedb.core.AnnotatedItem
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations, toTransferable
 
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, 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, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, 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.Annotatable
getAnnotatableParents
 
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getType, 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

MAX_EXTERNAL_ID_LENGTH

public static final int MAX_EXTERNAL_ID_LENGTH
The maximum length of the external id that can be stored in the database.

See Also:
setExternalId(String), Constant Field Values
Constructor Detail

BioMaterial

BioMaterial(D bioMaterialData)
Method Detail

getById

public static BioMaterial getById(DbControl dc,
                                  int id)
Get a biomaterial item when you know the id. This method can return any of the subclasses of BioMaterial. Eg. BioSource, Sample, Extract or LabeledExtract.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The id of the item to load
Returns:
The Sample item
Throws:
ItemNotFoundException - If an item with the specified id is not found
PermissionDeniedException - If the logged in user doesn't have read permission to the item
BaseException - If there is another error
Since:
2.17

onBeforeCommit

void onBeforeCommit(Transactional.Action action)
              throws NotLoggedInException,
                     BaseException
On delete action: issue an update to decrease the size of all BioMaterialList:s this is a member of.

Overrides:
onBeforeCommit in class SharedItem<D extends BioMaterialData>
Throws:
NotLoggedInException - If no user is logged in
BaseException - If there is another error
See Also:
Transactional, Core API overview - Transaction handling, Coding rules and guidelines for item classes

getExternalId

public String getExternalId()
Get the external id of the biomaterial. This value can be used to link with information in external databases. It is not used by the BASE core and it doesn't have to be unique.

Returns:
The external id for the biomaterial

setExternalId

public void setExternalId(String externalId)
                   throws PermissionDeniedException,
                          InvalidDataException
Set the external id of the biomaterial. The value may be null but must not be longer than the value specified by the MAX_EXTERNAL_ID_LENGTH constant.

Parameters:
externalId - The new value for the external id
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the string is too long

countChildren

public abstract long countChildren(boolean pooled)
Count the number of already existing children to this biomaterial. The count includes items that the logged in user doesn't have access to.

Parameters:
pooled - If TRUE, the count is for biomaterials of the same type, if FALSE the count is for biomaterials of the child type
Since:
2.16

2.17.2: 2011-06-17