2.17.2: 2011-06-17

net.sf.basedb.core
Class Hardware

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

public class Hardware
extends CommonItem<HardwareData>
implements Registered

This class is used to represent individual hardware items and information about them. In the current version of BASE the only type of hardware we keep information about is scanners.

Version:
2.0
Author:
enell
See Also:
HardwareType
Last modified
$Date: 2010-10-27 14:32:44 +0200 (Wed, 27 Oct 2010) $

Field Summary
static int MAX_VERSIONSTRING_LENGTH
          The maximum length of the version variable 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
Hardware(HardwareData data)
          Creates a new hardware item.
 
Method Summary
static Hardware getById(DbControl dc, int id)
          Get a Hardware item when you know the ID.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 HardwareType getHardwareType()
          Get the associated HardwareType item.
static Hardware getNew(DbControl dc, HardwareType hardwareType)
          Create a new Hardware item.
static ItemQuery<Hardware> getQuery()
          Get a query configured to retrieve hardware.
 Item getType()
          Get the type of item represented by the object.
 Set<ItemProxy> getUsingItems()
          Get all: Scan:s with this hardware ArrayBatch:s with this hardware BioMaterial:s and Hybridization:s with this hardware Plate:s with this hardware
 String getVersionString()
          Get the versionstring of this Hardware item.
 boolean isUsed()
          Check if: a Scan is linked to this hardware an ArrayBatch is linked to this hardware a BioMaterialEvent is linked to this hardware a PlateEvent is linked to this hardware
 void setHardwareType(HardwareType hardwareType)
          Set the HardwareType of this Hardware item.
 void setVersionString(String versionString)
          Set the versionstring for this Hardware item.
 
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.HARDWARE, getType()

MAX_VERSIONSTRING_LENGTH

public static final int MAX_VERSIONSTRING_LENGTH
The maximum length of the version variable that can be stored in the database. Check the length against this value before calling the setVersionString(String) method to avoid exceptions.

See Also:
Constant Field Values
Constructor Detail

Hardware

Hardware(HardwareData data)
Creates a new hardware item.

Parameters:
data - the data
Method Detail

getNew

public static Hardware getNew(DbControl dc,
                              HardwareType hardwareType)
                       throws BaseException
Create a new Hardware item.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
hardwareType - The HardwareType connected to this hardware. It cannot be null.
Returns:
The new Hardware item
Throws:
BaseException - If there is an error

getById

public static Hardware getById(DbControl dc,
                               int id)
                        throws ItemNotFoundException,
                               PermissionDeniedException,
                               BaseException
Get a Hardware 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 Hardware 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<Hardware> getQuery()
                                    throws BaseException
Get a query configured to retrieve hardware.

Returns:
An ItemQuery object
Throws:
BaseException - When the query could not be configured.

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<HardwareData>
Returns:
TRUE if this hardware is used.
Throws:
BaseException - if there is any error.
See Also:
BasicItem.getUsingItems()

getUsingItems

public Set<ItemProxy> getUsingItems()
Get all:

getHardwareType

public HardwareType getHardwareType()
                             throws PermissionDeniedException,
                                    BaseException
Get the associated HardwareType item. All Hardware items must have a type.

Returns:
The HardwareType item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is any error

setHardwareType

public void setHardwareType(HardwareType hardwareType)
                     throws PermissionDeniedException,
                            InvalidUseOfNullException
Set the HardwareType of this Hardware item. This parameter mustn't be null.

Parameters:
hardwareType - The new HardwareType
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission for the hardware or Permission.USE permission for the hardware type
InvalidUseOfNullException - If the hardware type is null

getVersionString

public String getVersionString()
Get the versionstring of this Hardware item.

Returns:
A string with the version of this item, or null if not known

setVersionString

public void setVersionString(String versionString)
                      throws StringTooLongException,
                             PermissionDeniedException
Set the versionstring for this Hardware item. The value must not be longer than the value specified by the MAX_VERSIONSTRING_LENGTH constant.

Parameters:
versionString - The new version for this item, or null if not known
Throws:
StringTooLongException - If versionString is longer then MAX_VERSIONSTRING_LENGTH
PermissionDeniedException - If the logged in user don't have write permission on this item

2.17.2: 2011-06-17