|
3.2.1: 2012-12-13 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.core.BasicItem<ItemSubtypeData>
net.sf.basedb.core.ItemSubtype
public class ItemSubtype
Item subtypes can be used to classify items into sub-categories.
Subtypes can be defined for all item types that implement the
Subtypable
interface. For a given item type the name
of the subtype should be unique.
Field Summary | |
---|---|
private static Map<Item,List<Item>> |
relatedItems
|
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 | |
---|---|
ItemSubtype(ItemSubtypeData data)
|
Method Summary | |
---|---|
void |
checkItemType(Item itemType)
Check if this subtype can be used on items of the given type. |
ItemSubtypeFileType |
getAssociatedDataFileType(DataFileType fileType,
boolean create)
Get information about a data file type that has been associated with this item subtype. |
static ItemSubtype |
getById(DbControl dc,
int id)
Get an item subtype object when you know the ID. |
ItemQuery<ItemSubtypeFileType> |
getDataFileTypes()
Get a query returning the data file types that have been associated with this subtype. |
String |
getDescription()
Get the description for the item. |
Date |
getEntryDate()
Get the date that the item was registered in the database. |
ItemSubtype |
getItemSubtype()
Get the subtype of the item. |
Item |
getMainItemType()
Get the main item type that the subtype belongs to. |
String |
getName()
Get the name of the item. |
static ItemSubtype |
getNew(DbControl dc,
Item itemType)
Create a new item subtype item. |
ItemQuery<ItemSubtype> |
getParentSubtypes()
Get a query returning all subtypes that have a relation to this subtype. |
static List<ItemSubtype> |
getParentSubtypes(DbControl dc,
Subtypable item,
Item parentType)
Utility method for locating all subtypes that have a relationship to the subtype of the given item. |
boolean |
getPushAnnotations()
If this flag is set, the annotations on items of this subtype can be pushed to the parent item. |
static ItemQuery<ItemSubtype> |
getQuery(Item itemType)
Get a query configured to retrieve item types. |
static List<Item> |
getRelatedItems(Item mainItem)
Get a list with (subtypable) items that are related to the given item (which should also be subtypable). |
static ItemSubtype |
getRelatedSubtype(DbControl dc,
Subtypable item,
Item... relatedItems)
Utility method for locating a subtype that is related to the subtype of a given item. |
static ItemSubtype |
getRelatedSubtype(DbControl dc,
Subtypable item,
Item relatedItem,
int defaultSubtype)
Same as getRelatedSubtype(DbControl, Subtypable, Item, int, int) with the
same id for the last two parameters. |
static ItemSubtype |
getRelatedSubtype(DbControl dc,
Subtypable item,
Item relatedItem,
int defaultIfNoSubtype,
int defaultIfNoRelated)
Utility method for loading a subtype that is related to the subtype of the given item. |
ItemSubtype |
getRelatedSubtype(Item itemType)
Get a related subtype of another item type. |
ItemQuery<ItemSubtype> |
getRelatedSubtypes()
Get a query returning all subtypes that are related to this subtype. |
String |
getSystemId()
Get the system id for the item. |
Item |
getType()
Get the type of item represented by the object. |
Set<ItemProxy> |
getUsingItems()
Get all: Subtypable items of this subtype. |
(package private) void |
initPermissions(int granted,
int denied)
If this is a system protocol type, delete and create permissions are revoked. |
boolean |
isAssociatedDataFileType(DataFileType fileType)
Checks if the given data file type is associated with this subtype or not. |
boolean |
isRemoved()
Check if the removed flag is set for this item. |
boolean |
isSystemItem()
Check if the item is a system item or not. |
boolean |
isUsed()
Checks if: any Subtypable item is using this subtype. |
void |
removeAssociatedDataFileType(DataFileType fileType)
Remove the association between this subtype and the given data file type. |
void |
removeRelatedSubtype(Item itemType)
Remove the related subtype for the given item type. |
void |
setDescription(String description)
Set the description for the item. |
void |
setItemSubtype(ItemSubtype subtype)
Do nothing. |
private void |
setMainItemType(Item itemType)
|
void |
setName(String name)
Set the name of the item. |
void |
setOnItem(Subtypable item)
Helper method for implementing the Subtypable.setItemSubtype(ItemSubtype)
method. |
void |
setPushAnnotations(boolean pushAnnotations)
|
void |
setRelatedSubtype(ItemSubtype subtype)
Set a subtype that is related to this subtype. |
void |
setRemoved(boolean removed)
Set the removed flag for this item. |
static boolean |
supportsPushAnnotations(Item mainItem)
Check if the given item type has support for pushing annotations to the parent item or not. |
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, 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 |
---|
public static final Item TYPE
Item.ITEMSUBTYPE
,
getType()
private static Map<Item,List<Item>> relatedItems
Constructor Detail |
---|
ItemSubtype(ItemSubtypeData data)
Method Detail |
---|
public static List<Item> getRelatedItems(Item mainItem)
Protocol
has a link to
File
via Protocol.getFile()
. Given the subtype of the protocol
we can find the desired subtype of the file and check agains the actual subtype:
Protocol p = ... ItemSubtype protocolSubtype = p.getItemSubtype(); ItemSubtype desiredFileSubtype = protocolSubtype.getRelatedSubtype(Item.FILE); File f = p.getFile(); ItemSubtype actualFileSubtype = f.getItemSubtype();
mainItem
-
getRelatedSubtype(Item)
public static boolean supportsPushAnnotations(Item mainItem)
public static ItemSubtype getRelatedSubtype(DbControl dc, Subtypable item, Item relatedItem, int defaultSubtype)
getRelatedSubtype(DbControl, Subtypable, Item, int, int)
with the
same id for the last two parameters.
public static ItemSubtype getRelatedSubtype(DbControl dc, Subtypable item, Item relatedItem, int defaultIfNoSubtype, int defaultIfNoRelated)
Subtypable.getItemSubtype()
and
then getRelatedSubtype(Item)
but with proper null handling and
a possibility to return a default subtype if no related one can be found.
dc
- A DbControl to use for database accessitem
- A subtypable itemrelatedItem
- The main item type of the related subtype we are looking fordefaultIfNoSubtype
- The ID of the subtype to return if the item has no
subtypedefaultIfNoRelated
- The ID of the subtype to return if the item has a subtype,
but the subtype has no related subtype for the given related item type
public static ItemSubtype getRelatedSubtype(DbControl dc, Subtypable item, Item... relatedItems)
dc
- A DbControl to use for database accessitem
- A subtypable itemrelatedItems
- The main item type of the related subtype we are looking for
public static List<ItemSubtype> getParentSubtypes(DbControl dc, Subtypable item, Item parentType)
getRelatedSubtype(Item)
return the subtype of the given subtypable item (optionally restricting
to one parent item type).
dc
- A DbControl to use for database accessitem
- A subtypeable itemparentType
- The item type of the subtypes that we want to find or null
to find any subtype
public static ItemSubtype getNew(DbControl dc, Item itemType) throws BaseException
dc
- The DbControl
which will be used for
permission checking and database accessitemType
- The main item type
ItemSubtype
item
BaseException
- If there is an errorpublic static ItemSubtype getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
dc
- The DbControl
which will be used for
permission checking and database access.id
- The system ID of the item to load.
ItemSubtype
item
ItemNotFoundException
- This exception is thrown if an
item with the specified ID is not found
PermissionDeniedException
- This exception is thrown if
the logged in user doesn't have read permission to the item
BaseException
- This exception is thrown if there is another
errorpublic static ItemQuery<ItemSubtype> getQuery(Item itemType)
itemType
- Optionally filter the query to only return
subtypes for the given item type
ItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public Date getEntryDate()
Registered
getEntryDate
in interface Registered
public boolean isRemoved()
Removable
isRemoved
in interface Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwise
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 FALSEpublic String getSystemId()
SystemItem
getSystemId
in interface SystemItem
public boolean isSystemItem()
SystemItem
isSystemItem
in interface SystemItem
public String getName()
Nameable
getName
in interface Nameable
String
with the name of the itempublic void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.
setName
in interface Nameable
name
- The new name for the item
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
constantpublic String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.
setDescription
in interface Nameable
description
- The new description for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic ItemSubtype getItemSubtype()
Subtypable
getItemSubtype
in interface Subtypable
SubtypableRelatedItems
public void setItemSubtype(ItemSubtype subtype)
setItemSubtype
in interface Subtypable
subtype
- A subtype or nullsetOnItem(Subtypable)
public boolean isUsed() throws BaseException
Subtypable
item is using this subtype.
MimeType.getFileType()
and DataFileType.getGenericType()
.
isUsed
in class BasicItem<ItemSubtypeData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
Subtypable
items of this subtype.
getUsingItems
in class BasicItem<ItemSubtypeData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<ItemSubtypeData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- If the permissions couldn't be initialisedpublic Item getMainItemType()
private void setMainItemType(Item itemType)
public boolean getPushAnnotations()
Annotatable.getAnnotatableParents()
for an item may return items that are actually child items if they have a subtype with
this flag set. For this feature to work it must also be supported by the
actual parent item implementation of Annotatable.getAnnotatableParents()
which is indicated by annotating the Subtypable.getItemSubtype()
method
with SupportsPushAnnotations
.
public void setPushAnnotations(boolean pushAnnotations)
getPushAnnotations()
public ItemSubtype getRelatedSubtype(Item itemType)
getRelatedItems(Item)
to find out which other
subtypable items that can be related to this subtype.
itemType
- The other item type (which should also be subtypable)
public void setRelatedSubtype(ItemSubtype subtype)
subtype
- The subtype (null is not allowed)getRelatedSubtype(Item)
public void removeRelatedSubtype(Item itemType)
itemType
- The item type of the related subtype to
be removedpublic ItemQuery<ItemSubtype> getRelatedSubtypes()
public ItemQuery<ItemSubtype> getParentSubtypes()
public ItemQuery<ItemSubtypeFileType> getDataFileTypes()
FileStoreEnabled
interface.
public boolean isAssociatedDataFileType(DataFileType fileType)
fileType
- The file type to check
public ItemSubtypeFileType getAssociatedDataFileType(DataFileType fileType, boolean create)
fileType
- The file type to get information forcreate
- If TRUE, the file type will be added to the subtype if it doesn't already exists
ItemSubtypeFileType
objectpublic void removeAssociatedDataFileType(DataFileType fileType)
fileType
- The file type to removepublic void setOnItem(Subtypable item)
Subtypable.setItemSubtype(ItemSubtype)
method.
item
- The item which must be a subtypeable itempublic void checkItemType(Item itemType)
itemType
- The item type to check
|
3.2.1: 2012-12-13 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |