public class ItemSubtype extends BasicItem<ItemSubtypeData> implements Nameable, Removable, Registered, SystemItem, Subtypable
Subtypable
interface. For a given item type the name
of the subtype should be unique.Modifier and Type | Field and Description |
---|---|
private static Map<Item,List<Item>> |
relatedItems |
static Item |
TYPE
The type of item represented by this class.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
MAX_SYSTEM_ID_LENGTH
Constructor and Description |
---|
ItemSubtype(ItemSubtypeData data) |
Modifier and Type | Method and Description |
---|---|
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.
|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
public static final Item TYPE
Item.ITEMSUBTYPE
,
getType()
ItemSubtype(ItemSubtypeData data)
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 typepublic 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 forpublic 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 subtypepublic 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 typeItemSubtype
itemBaseException
- 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
itemItemNotFoundException
- 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 have read permission to the itemBaseException
- 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 typeItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
public Date getEntryDate()
Registered
getEntryDate
in interface Registered
public boolean isRemoved()
Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwisePermissionDeniedException
- 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
public void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.setName
in interface Nameable
name
- The new name for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- 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 itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- 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 subclassBaseException
- 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 checkpublic 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 existsItemSubtypeFileType
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