2.17.2: 2011-06-17

net.sf.basedb.core
Class Platform

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<PlatformData>
      extended by net.sf.basedb.core.Platform
All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Removable

public class Platform
extends BasicItem<PlatformData>
implements Nameable, Removable

This class is used to represent an experimental platform in BASE. An experimental platform is used to define the types of files that are used as data files. For example, the AFFYMETRIX platform defines CDF and CEL files.

A platform may have variants. A PlatformVariant has independent settings but may inherit file types from the main platform.

Some platforms are file-only platforms, and has data that can't be imported into the database, for example the Affymetrix platform. Platforms that are not file-only can also import data into the database. Such platforms may be locked to a single RawDataType or they may be GENERIC.

Version:
2.5
Author:
Nicklas
Last modified
$Date: 2011-02-18 13:19:38 +0100 (Fri, 18 Feb 2011) $

Field Summary
static String AFFYMETRIX
          The external id for the Affymetrix platform.
static String GENERIC
          The external id for the Generic platform.
static int MAX_EXTERNAL_ID_LENGTH
          The maximum length of the external ID 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
Platform(PlatformData data)
          Creates a new filetype item from the given data.
 
Method Summary
 void addFileType(DataFileType type, boolean required, PlatformVariant variant)
          Add a file type to this platform/variant.
static Platform getByExternalId(DbControl dc, String externalId)
          Get a Platform item when you know the external ID.
static Platform getById(DbControl dc, int id)
          Get a Platform object when you know the ID.
 String getDescription()
          Get the description for the item.
 String getExternalId()
          Get the external id for the platform.
 PlatformFileType getFileType(DataFileType type, PlatformVariant variant)
          Get information about a file type that has been registered with this platform/variant.
 ItemQuery<PlatformFileType> getFileTypes(PlatformVariant variant, boolean restrict)
          Get the file types registered with this platform.
 String getName()
          Get the name of the item.
static Platform getNew(DbControl dc, String externalId, int channels)
          Create a new file-only platform.
static Platform getNew(DbControl dc, String externalId, RawDataType rawDataType)
          Create a new platform which may optionally import data into the database.
static ItemQuery<Platform> getQuery()
          Get a query configured to retrieve Platform items.
 RawDataType getRawDataType()
          Get the raw data type this platform is locked to.
 Item getType()
          Get the type of item represented by the object.
 Set<ItemProxy> getUsingItems()
          Get all: ArrayDesign:s and RawBioAssay:s using this platform
 ItemQuery<PlatformVariant> getVariants()
          Get a query that returns variants of this platform.
protected  void initPermissions(int granted, int denied)
          Deny deletion of the GENERIC and Affymetrix platform.
 boolean isFileOnly()
          Check if the platform is a file-only platform or if it allows data to be imported into the database.
 boolean isRemoved()
          Check if the removed flag is set for this item.
 boolean isUsed()
          Check if: any raw bioassays or array design are using this platform
 PlatformVariant newVariant(String systemId)
          Create a new PlatformVariant of this platform.
(package private)  void onAfterCommit(Transactional.Action action)
          Register file-only platforms as raw data type after insert and unregister after delete.
 void removeFileType(DataFileType type, PlatformVariant variant)
          Remove a file type from this platform/variant.
private  void setChannels(int channels)
          Set the number of channels for a file-only platform.
 void setDescription(String description)
          Set the description for the item.
private  void setExternalId(String externalId)
           
 void setName(String name)
          Set the name of the item.
private  void setRawDataType(RawDataType rawDataType)
          Set the raw data type.
 void setRemoved(boolean removed)
          Set the removed flag for this item.
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, 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.PLATFORM, getType()

GENERIC

public static final String GENERIC
The external id for the Generic platform. It allows importing raw data into the database for all raw data type.

See Also:
getByExternalId(DbControl, String), Constant Field Values

AFFYMETRIX

public static final String AFFYMETRIX
The external id for the Affymetrix platform. It is a file-only platform.

See Also:
getByExternalId(DbControl, String), Constant Field Values

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

Platform

Platform(PlatformData data)
Creates a new filetype item from the given data.

Parameters:
data - the data.
Method Detail

getNew

public static Platform getNew(DbControl dc,
                              String externalId,
                              int channels)
Create a new file-only platform. Data for this platform can't be imported to the database.

Parameters:
dc - The DbControl to use for database access
externalId - The external ID of the platform, must be unique for all platforms
channels - Number of channels in this platform
Returns:
The new platform object

getNew

public static Platform getNew(DbControl dc,
                              String externalId,
                              RawDataType rawDataType)
Create a new platform which may optionally import data into the database.

Parameters:
dc - The DbControl to use for database access
externalId - The external ID of the platform, must be unique for all platforms
rawDataType - A specific raw data type this platform will be locked to or null if it is not locked to any specific raw data type
Returns:
The new platform object

getById

public static Platform getById(DbControl dc,
                               int id)
                        throws ItemNotFoundException,
                               PermissionDeniedException,
                               BaseException
Get a Platform object 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 Platform 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 items
BaseException - If there is another error

getByExternalId

public static Platform getByExternalId(DbControl dc,
                                       String externalId)
                                throws ItemNotFoundException,
                                       PermissionDeniedException,
                                       BaseException
Get a Platform item when you know the external ID.

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

getQuery

public static ItemQuery<Platform> getQuery()
                                    throws BaseException
Get a query configured to retrieve Platform items.

Returns:
An ItemQuery object
Throws:
BaseException - If the query could not be created.

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

isUsed

public boolean isUsed()
               throws BaseException
Check if:

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

initPermissions

protected void initPermissions(int granted,
                               int denied)
Deny deletion of the GENERIC and Affymetrix platform. The GENERIC platform is required by the system and the AFFYMETRIX platform is required for backwards compatibility reasons.

Overrides:
initPermissions in class BasicItem<PlatformData>
Parameters:
granted - Permissions that have been granted by the subclass
denied - Permissions that have been denied by the subclass

onAfterCommit

void onAfterCommit(Transactional.Action action)
Register file-only platforms as raw data type after insert and unregister after delete.

Overrides:
onAfterCommit in class BasicItem<PlatformData>
Since:
2.16.2
See Also:
Transactional, Core API overview - Transaction handling, Coding rules and guidelines for item classes

getExternalId

public String getExternalId()
Get the external id for the platform.


setExternalId

private void setExternalId(String externalId)
                    throws PermissionDeniedException,
                           InvalidDataException,
                           BaseException
Throws:
PermissionDeniedException
InvalidDataException
BaseException

setChannels

private void setChannels(int channels)
Set the number of channels for a file-only platform.


setRawDataType

private void setRawDataType(RawDataType rawDataType)
Set the raw data type. The raw data type must allow data to be imported into the database.

Parameters:
rawDataType - The raw data type, null is allowed

isFileOnly

public boolean isFileOnly()
Check if the platform is a file-only platform or if it allows data to be imported into the database.

Returns:
TRUE if only file data is allowed, FALSE if import to database is allowed

getRawDataType

public RawDataType getRawDataType()
Get the raw data type this platform is locked to. File-only platforms are always locked to a raw data type. Platforms that support import of data to the database may or may not be locked. Note! If the variant is a file-only variant that hasn't been committed to the database a new instance of RawDataType is returned for each call to this method.

Returns:
The raw data type or null if the platform isn't locked

getVariants

public ItemQuery<PlatformVariant> getVariants()
Get a query that returns variants of this platform.

Returns:
An ItemQuery object

newVariant

public PlatformVariant newVariant(String systemId)
Create a new PlatformVariant of this platform.

Parameters:
systemId - The systemId of the new variant (must be unique)
Returns:
The new PlatformVariant object
See Also:
PlatformVariant.getNew(DbControl, Platform, String)

getFileTypes

public ItemQuery<PlatformFileType> getFileTypes(PlatformVariant variant,
                                                boolean restrict)
Get the file types registered with this platform.

See Also:
PlatformFileType.getQuery(Platform, PlatformVariant, boolean)

addFileType

public void addFileType(DataFileType type,
                        boolean required,
                        PlatformVariant variant)
Add a file type to this platform/variant. If the file type has already been registered this method can be used to change the required flag.

Parameters:
type - The file type
required - If a file of this type is required or not
variant - An optional variant
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidUseOfNullException - If type is null

removeFileType

public void removeFileType(DataFileType type,
                           PlatformVariant variant)
Remove a file type from this platform/variant. If the file type isn't registered this method does nothing. If a variant is given the file type is only removed from that variant. If no variant is given the file type is only removed from the platform, not from other variants that have registered with the file type.

Parameters:
type - The file type to remove
variant - An optional variant
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidUseOfNullException - If type is null

getFileType

public PlatformFileType getFileType(DataFileType type,
                                    PlatformVariant variant)
Get information about a file type that has been registered with this platform/variant.

Parameters:
type - The file type to get information for
variant - An optional variant
Returns:
Null if the file type isn't registered with the platform/variant or a PlatformFileType object

2.17.2: 2011-06-17