2.17.2: 2011-06-17

net.sf.basedb.core
Class Image

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.ChildItem<ImageData>
          extended by net.sf.basedb.core.Image
All Implemented Interfaces:
AccessControlled, FileAttachable, Identifiable, Nameable, Removable

public class Image
extends ChildItem<ImageData>
implements Nameable, Removable, FileAttachable

An image represents a single image produced by a Scan. The images are usually analysed by some software to produce a RawBioAssay.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Nested Class Summary
static class Image.Format
          This enumeration is used to indicate the type of image.
 
Field Summary
private static QueryRuntimeFilter RUNTIME_FILTER
          This filter will only return items if the logged in user has generic read permission to scans.
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
Image(ImageData data)
           
 
Method Summary
static Image getById(DbControl dc, int id)
          Get an Image item when you know the id.
 String getDescription()
          Get the description for the item.
 File getFile()
          Get the file that is attached to the item.
 Image.Format getFormat()
          Get the format of this image.
 String getName()
          Get the name of the item.
static Image getNew(DbControl dc, Scan scan)
          Create a new Image item.
static ItemQuery<Image> getQuery(Scan scan)
          Get a query configured to retrieve images for the specified scan.
 Scan getScan()
          Get the scan this image belongs to.
(package private)  SharedData getSharedParent()
          Get the shareable parent item of this child item.
 Item getType()
          Get the type of item represented by the object.
 boolean isPreview()
          A boolean value indicating if this image is a preview image or the full-sized image.
 boolean isRemoved()
          Check if the removed flag is set for this item.
 void setDescription(String description)
          Set the description for the item.
 void setFile(File file)
          Attach a file to the item.
 void setFormat(Image.Format format)
          Set the format of the image.
 void setName(String name)
          Set the name of the item.
 void setPreview(boolean preview)
          Set a flag indicating if this image is a preview image or the full-sized image.
 void setRemoved(boolean removed)
          Set the removed flag for this item.
(package private)  void setScan(Scan scan)
          Set the scan this image belongs to.
 
Methods inherited from class net.sf.basedb.core.ChildItem
getPermissionForWriteDeleteAndCreate, getPluginPermissions, initPermissions
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, 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
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.IMAGE, getType()

RUNTIME_FILTER

private static final QueryRuntimeFilter RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to scans.

Constructor Detail

Image

Image(ImageData data)
Method Detail

getNew

public static Image getNew(DbControl dc,
                           Scan scan)
                    throws BaseException
Create a new Image item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
scan - The Scan which the image is related to
Returns:
The new Image item
Throws:
BaseException - If there is an error
See Also:
Scan.newImage()

getById

public static Image getById(DbControl dc,
                            int id)
                     throws ItemNotFoundException,
                            PermissionDeniedException,
                            BaseException
Get an Image 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 Image 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

getQuery

public static ItemQuery<Image> getQuery(Scan scan)
                                 throws BaseException
Get a query configured to retrieve images for the specified scan.

Parameters:
scan - The scan to retreive images for, null is allowed if the logged in user has generic READ permission for scans in which case all images will be returned
Returns:
An ItemQuery object
Throws:
BaseException - If getting the query fails.
See Also:
Scan.getImages()

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

getName

public String getName()
Description copied from interface: Nameable
Get the name of the item.

Specified by:
getName in interface Nameable
Returns:
A String with the name of the item

setName

public void setName(String name)
             throws PermissionDeniedException,
                    InvalidDataException
Description copied from interface: Nameable
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the Nameable.MAX_NAME_LENGTH constant.

Specified by:
setName in interface Nameable
Parameters:
name - The new name for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the name is null or longer than specified by the Nameable.MAX_NAME_LENGTH constant

getDescription

public String getDescription()
Description copied from interface: Nameable
Get the description for the item.

Specified by:
getDescription in interface Nameable
Returns:
A String with a description of the item

setDescription

public void setDescription(String description)
                    throws PermissionDeniedException,
                           InvalidDataException
Description copied from interface: Nameable
Set the description for the item. The description can be null but mustn't be longer than the value specified by the Nameable.MAX_DESCRIPTION_LENGTH constant.

Specified by:
setDescription in interface Nameable
Parameters:
description - The new description for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the description longer than specified by the Nameable.MAX_DESCRIPTION_LENGTH constant

isRemoved

public boolean isRemoved()
Description copied from interface: Removable
Check if the removed flag is set for this item.

Specified by:
isRemoved in interface Removable
Returns:
TRUE if the item is flagged as removed, FALSE otherwise

setRemoved

public void setRemoved(boolean removed)
                throws PermissionDeniedException
Description copied from interface: Removable
Set the removed flag for this item.

Specified by:
setRemoved in interface Removable
Parameters:
removed - TRUE if the item should be flagged as removed, FALSE otherwise
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.DELETE permission for setting the flag to TRUE or Permission.WRITE permission for setting the flag to FALSE

getFile

public File getFile()
             throws PermissionDeniedException,
                    BaseException
Description copied from interface: FileAttachable
Get the file that is attached to the item.

Specified by:
getFile in interface FileAttachable
Returns:
A File item, or null if no file is attached
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission for the file
BaseException - If there is another error

setFile

public void setFile(File file)
             throws PermissionDeniedException
Description copied from interface: FileAttachable
Attach a file to the item.

Specified by:
setFile in interface FileAttachable
Parameters:
file - The file to attach to the item
Throws:
PermissionDeniedException - If the logged in user doesn't have use permission for the file or write permission for the item

getSharedParent

SharedData getSharedParent()
Description copied from class: ChildItem
Get the shareable parent item of this child item. This is used by the ChildItem.initPermissions(int, int) method to calculate the logged in user's permissions for the child item.

Specified by:
getSharedParent in class ChildItem<ImageData>
Returns:
The parent item

getScan

public Scan getScan()
             throws PermissionDeniedException,
                    BaseException
Get the scan this image belongs to.

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

setScan

void setScan(Scan scan)
       throws PermissionDeniedException,
              InvalidDataException
Set the scan this image belongs to. Can only be set on a new item.

Throws:
InvalidDataException - If the scan is null
PermissionDeniedException

isPreview

public boolean isPreview()
A boolean value indicating if this image is a preview image or the full-sized image.

Returns:
TRUE if the image is a preview image, FALSE otherwise

setPreview

public void setPreview(boolean preview)
                throws PermissionDeniedException
Set a flag indicating if this image is a preview image or the full-sized image.

Parameters:
preview - TRUE if the image is a preview image, FALSE otherwise
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission

getFormat

public Image.Format getFormat()
Get the format of this image.

Returns:
A Format object

setFormat

public void setFormat(Image.Format format)
               throws PermissionDeniedException
Set the format of the image.

Parameters:
format - The format
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission

2.17.2: 2011-06-17