Package net.sf.basedb.core
Class QuotaType
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.QuotaType
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Registered
,SystemItem
public class QuotaType extends BasicItem implements Nameable, SystemItem, Registered
This class represents the different types a quota can have.
- Version:
- 2.0
- Author:
- enell
- Last modified
- $Date: 2019-02-22 09:06:54 +0100 (fre, 22 feb. 2019) $
-
Field Summary
Fields Modifier and Type Field Description static String
EXPERIMENT
The ID for experiments.static String
FILE
The ID for the file.static String
RAW_DATA
The ID for the raw data.static String
TOTAL
The ID for the total quota.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
Fields inherited from interface net.sf.basedb.core.SystemItem
MAX_SYSTEM_ID_LENGTH
-
Constructor Summary
Constructors Constructor Description QuotaType(QuotaTypeData data)
Creates a newQuotaType
item. -
Method Summary
Modifier and Type Method Description static QuotaType
getById(DbControl dc, int id)
Get aQuotaType
object when you know the id.(package private) QuotaTypeData
getData()
Get theBasicData
object that holds all data for this item.String
getDescription()
Get the description for the item.Date
getEntryDate()
Get the date that the item was registered in the database.String
getName()
Get the name of the item.static ItemQuery<QuotaType>
getQuery()
Get a query configured to retrieveQuotaType
.String
getSystemId()
Get the system id for the item.Item
getType()
Get the type of item represented by the object.(package private) void
initPermissions(int granted, int denied)
The logged in user has read permission to the quota assigned to him/her.boolean
isSystemItem()
Check if the item is a system item or not.boolean
isUsed()
Check if this item is used by some other item.void
setDescription(String description)
Set the description for the item.void
setEntryDate(Date entryDate)
Set the date the entry was registered in the database.void
setName(String name)
Set the name of the item.Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
-
Field Details
-
TYPE
The type of item represented by this class.- See Also:
Item.QUOTATYPE
,getType()
-
TOTAL
The ID for the total quota.- See Also:
- Constant Field Values
-
FILE
The ID for the file.- See Also:
- Constant Field Values
-
RAW_DATA
The ID for the raw data.- See Also:
- Constant Field Values
-
EXPERIMENT
The ID for experiments.- See Also:
- Constant Field Values
-
-
Constructor Details
-
QuotaType
QuotaType(QuotaTypeData data)Creates a newQuotaType
item.- Parameters:
data
- The data class for this item.
-
-
Method Details
-
getById
public static QuotaType getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseExceptionGet aQuotaType
object when you know the id.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The id of the item to load- Returns:
- The
QuotaType
item - Throws:
ItemNotFoundException
- This exception is thrown if an item with the specified ID is not foundPermissionDeniedException
- This exception is thrown if the logged in user doesn't haveREAD
permission to the itemsBaseException
- This exception is thrown if there is another error
-
getQuery
Get a query configured to retrieveQuotaType
. All logged in users have READ permission to all QuotaType items.- Returns:
- An
ItemQuery
object
-
getData
QuotaTypeData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this 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 theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- Returns:
- A value indicating the type of item
-
getName
Description copied from interface:Nameable
Get the name of the item. -
setName
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 theNameable.MAX_NAME_LENGTH
constant.- Specified by:
setName
in interfaceNameable
- Parameters:
name
- The new name for the item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the name is null or longer than specified by theNameable.MAX_NAME_LENGTH
constant
-
getDescription
Description copied from interface:Nameable
Get the description for the item.- Specified by:
getDescription
in interfaceNameable
- Returns:
- A
String
with a description of the item
-
setDescription
public void setDescription(String description) throws PermissionDeniedException, InvalidDataExceptionDescription 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 theNameable.MAX_DESCRIPTION_LENGTH
constant.- Specified by:
setDescription
in interfaceNameable
- Parameters:
description
- The new description for the item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the description longer than specified by theNameable.MAX_DESCRIPTION_LENGTH
constant
-
getSystemId
Description copied from interface:SystemItem
Get the system id for the item.- Specified by:
getSystemId
in interfaceSystemItem
- Returns:
- The id of the item or null if it is not a system item
-
isSystemItem
public boolean isSystemItem()Description copied from interface:SystemItem
Check if the item is a system item or not. A system item have a non-null value for the system id.- Specified by:
isSystemItem
in interfaceSystemItem
- Returns:
- TRUE if this item is a system item, FALSE otherwise
-
getEntryDate
Description copied from interface:Registered
Get the date that the item was registered in the database.- Specified by:
getEntryDate
in interfaceRegistered
- Returns:
- A date or null if this is not known
-
setEntryDate
Description copied from interface:Registered
Set the date the entry was registered in the database. Implementations should only allow this property to be set before the item is first stored in the database. The intention of this method is to facilitate export/import of data between server.- Specified by:
setEntryDate
in interfaceRegistered
- Parameters:
entryDate
- A date or null to use today's date
-
isUsed
public boolean isUsed()Description copied from class:BasicItem
Check if this item is used by some other item. With used we mean that another item is linking to this item in way that prevents this item from beeing deleted. Ie. if we tried to delete an item that is used, we would get a foreign key violation error from the database. If the subclass overrides this method it should propagate the call to the superclass, ie.super.isUsed()
, unless it has decided that the item is used by some other means.- Overrides:
isUsed
in classBasicItem
- Returns:
- Allways return true.
- See Also:
BasicItem.getUsingItems()
-
initPermissions
The logged in user has read permission to the quota assigned to him/her. If this is a system item, delete and create permissions are denied.- Overrides:
initPermissions
in classBasicItem
- Parameters:
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass- Throws:
BaseException
- This exception is thrown if there is any error
-