|
2.10.1: 2009-03-24 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.core.BasicItem<AnnotationSetData>
net.sf.basedb.core.AnnotationSet
public class AnnotationSet
An annotation set is the container for all annotations on an item. An item can have one annotation of each annotation type that is defined for it.
An item can also inherit annotation from it's parents. It is possible to inherit all annotations or only specific ones. In the first case this means that if the parent gets new annotations those are automatically inherited. In the second case the inherticane is lost if the annotation is deleted. If a new annotation of the same annotation type is creted later, it is NOT automatically inherited again.
AnnotationType
,
Annotation
Nested Class Summary | |
---|---|
private static class |
AnnotationSet.QueryRuntimeFilterImpl
|
Field Summary | |
---|---|
private Annotatable |
item
The item this annotation set belongs to. |
private static QueryRuntimeFilter |
RUNTIME_FILTER
This filter gives everybody read permission to annotations. |
static Item |
TYPE
The type of item represented by this class. |
Constructor Summary | |
---|---|
AnnotationSet(AnnotationSetData annotationSetData)
Regular constructor if the item is not known beforehand. |
|
AnnotationSet(AnnotationSetData annotationSetData,
Annotatable item)
Special constructor to avoid getItem() to hit the database
when the item is known beforehand. |
Method Summary | |
---|---|
int |
autoInherit(DbControl dc,
AnnotationType annotationType,
boolean preferAnnotationSet)
Automatically inherit all annotations of the specified annotation type from parent items unless this annotation set already contains an annotation of the specified type. |
void |
copyFrom(Annotatable item,
boolean overwrite)
Copy annotations from another annotatable item to this annotation set. |
Annotation |
findAnnotation(AnnotationType annotationType)
Deprecated. Use findAnnotations(DbControl, AnnotationType, Boolean) instead |
List<Annotation> |
findAnnotations(DbControl dc,
AnnotationType annotationType,
Boolean findInherited)
Find annotations of the specified annotation type among all annotations including the inherited annotations. |
ItemQuery<Annotation> |
getAllInheritedAnnotations()
Get a query that returns all inherited (directly and indirectly) annotations in this annotation set. |
Annotation |
getAnnotation(AnnotationType annotationType)
Get the Annotation object of the specified annotation type. |
ItemQuery<Annotation> |
getAnnotations()
Get a query that reurns all primary annotations in this annotation set. |
static AnnotationSet |
getById(DbControl dc,
int id)
Get an AnnotationSet item when you know the id. |
ItemQuery<Annotation> |
getInheritedAnnotations()
Get a query that returns directly inherited annotations in this annotation set. |
ItemQuery<AnnotationSet> |
getInheritedAnnotationSets()
Get a query that returns all inherited annotation sets in this annotation set. |
ItemQuery<AnnotationSet> |
getInheritingAnnotationSets()
Get a query that returns all annotation sets inheriting from this annotation set. |
Annotatable |
getItem()
Get the item this annotation set belongs to. |
Annotatable |
getItem(DbControl dc)
Get the item this annotation set belongs to using a specific DbControl for database access. |
Item |
getItemType()
Get the Item type of the item this annotation set belongs to. |
(package private) static AnnotationSet |
getNew(DbControl dc,
Annotatable item)
Create a new annotation set for the specified item. |
(package private) PluginPermission |
getPluginPermissions()
|
(package private) static ItemQuery<AnnotationSet> |
getQuery()
Get a ItemQuery object configured to retrieve AnnotationSet
items. |
Item |
getType()
Get the type of item represented by the object. |
Set<ItemProxy> |
getUsingItems()
Get the item this annotation set belongs to. |
boolean |
hasAnnotation(AnnotationType annotationType)
Check if the annotation set contains an annotation of the specified type. |
void |
inheritAnnotation(Annotation annotation)
Inherit an annotation. |
void |
inheritAnnotationSet(AnnotationSet annotationSet)
Inherit an annotation set. |
(package private) void |
initPermissions(int granted,
int denied)
READ permission is granted to all users. |
boolean |
isInherited(Annotation annotation)
Check if an annotation is inherited or not by this annotation set. |
boolean |
isInherited(AnnotationSet annotationSet)
Check if an annotation set is inherited or not by this annotation set. |
boolean |
isUsed()
Always return TRUE. |
void |
removeAnnotation(AnnotationType annotationType)
Delete the annotation of the specified annotation type. |
void |
removeInheritedAnnotation(Annotation annotation)
Remove an inherited an annotation. |
void |
removeInheritedAnnotationSet(AnnotationSet annotationSet)
Remove an inherited an annotation set. |
(package private) void |
setItem(Annotatable item)
Set the item this annotation set belongs to. |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, 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 |
Field Detail |
---|
public static final Item TYPE
Item.ANNOTATIONSET
,
getType()
private static final QueryRuntimeFilter RUNTIME_FILTER
private Annotatable item
Constructor Detail |
---|
AnnotationSet(AnnotationSetData annotationSetData)
AnnotationSet(AnnotationSetData annotationSetData, Annotatable item)
getItem()
to hit the database
when the item is known beforehand.
AnnotatedItem.getAnnotationSet()
Method Detail |
---|
static AnnotationSet getNew(DbControl dc, Annotatable item) throws BaseException
BaseException
AnnotatedItem.getAnnotationSet()
public static AnnotationSet getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
AnnotationSet
item when you know the id.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The id of the item to load
AnnotationSet
item
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 errorstatic ItemQuery<AnnotationSet> getQuery()
ItemQuery
object configured to retrieve AnnotationSet
items. This query may return items which the logged in user doesn't have
read permission to. At the moment there is no way to solve this problem.
ItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.
public boolean isUsed() throws BaseException
isUsed
in class BasicItem<AnnotationSetData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems() throws BaseException
getUsingItems
in class BasicItem<AnnotationSetData>
BaseException
- If there is an error loading the itemsBasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<AnnotationSetData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- If the permissions couldn't be initialisedPluginPermission getPluginPermissions()
getPluginPermissions
in class BasicItem<AnnotationSetData>
public Annotatable getItem() throws PermissionDeniedException, BaseException
Annotatable
item
PermissionDeniedException
- If the logged in user doesn't have
read permission to the item
BaseException
- If there is another errorpublic Annotatable getItem(DbControl dc) throws PermissionDeniedException, BaseException
dc
- An open DbControl, or null to use the current DbControl associated
with this annotation set
Annotatable
item
PermissionDeniedException
BaseException
void setItem(Annotatable item)
public Item getItemType()
Item
type of the item this annotation set belongs to.
public Annotation getAnnotation(AnnotationType annotationType) throws PermissionDeniedException, InvalidDataException, BaseException
Annotation
object of the specified annotation type.
If the annotation set doesn't contain an annotation of the specified type
a new object is created and automatically saved to the database when
DbControl.commit()
is called. To check if an annotation of a certain
annotation type exists without creating a new annotation use the
hasAnnotation(AnnotationType)
method.
annotationType
- The annotation type
Annotation
object
PermissionDeniedException
- If a new annotation must be created
and the logged in user doesn't have write permission
InvalidDataException
- If a new annotation must be created
and the annotation type isn't valid for this type of item
BaseException
- If there is another errorfindAnnotations(DbControl, AnnotationType, Boolean)
public boolean hasAnnotation(AnnotationType annotationType)
annotationType
- An AnnotationType
object
public Annotation findAnnotation(AnnotationType annotationType) throws PermissionDeniedException
findAnnotations(DbControl, AnnotationType, Boolean)
instead
annotationType
- The annotation type to look for
Annotation
object or null
PermissionDeniedException
public List<Annotation> findAnnotations(DbControl dc, AnnotationType annotationType, Boolean findInherited) throws PermissionDeniedException
Note! This method only looks in the database. Changes that have been made in the current transaction and not yet committed to the database are not included in the result.
dc
- The DbControl to use for database accessannotationType
- The annotation type to look forfindInherited
- TRUE if the method always should try to find inherited annotations,
FALSE if it never should try, or null if it only should try if it hasn't found any
annotation so far
Annotation
objects (may be empty)
PermissionDeniedException
- If the logged in user don't have the
proper permissions to access the database.public void removeAnnotation(AnnotationType annotationType) throws PermissionDeniedException, InvalidDataException, BaseException
annotationType
- The type of the annotation to delete
PermissionDeniedException
- If the logged in user
doesn't have write permission
InvalidDataException
- If the annotation type is null
BaseException
- If there is another errorpublic ItemQuery<Annotation> getAnnotations()
ItemQuery
objectpublic void inheritAnnotation(Annotation annotation) throws PermissionDeniedException, InvalidDataException
annotation
- The annotation to inherit
PermissionDeniedException
- If the logged in user
doesn't have write permission for this annotation set or
use permission for the annotation
InvalidDataException
- If the annotation is nullpublic void removeInheritedAnnotation(Annotation annotation) throws PermissionDeniedException, InvalidDataException
annotation
- The annotation to remove
PermissionDeniedException
- If the logged in user
doesn't have write permission for this annotation set
InvalidDataException
- If the annotation is nullpublic boolean isInherited(Annotation annotation) throws InvalidDataException
annotation
- The annotation to check
InvalidDataException
- If the annotation is nullpublic ItemQuery<Annotation> getInheritedAnnotations() throws BaseException
ItemQuery
object
BaseException
- If getting the query fails.inheritAnnotation(Annotation)
public ItemQuery<Annotation> getAllInheritedAnnotations()
inheritAnnotation(Annotation)
, the indirectly inherited annotations
include annotations in annotation sets added by
inheritAnnotationSet(AnnotationSet)
ItemQuery
objectgetInheritedAnnotations()
public void inheritAnnotationSet(AnnotationSet annotationSet) throws PermissionDeniedException, InvalidDataException
annotationSet
- The annotation set to inherit
PermissionDeniedException
- If the logged in user
doesn't have write permission for this annotation set or
use permission for the annotation set to inherit
InvalidDataException
- If the annotation set is nullpublic void removeInheritedAnnotationSet(AnnotationSet annotationSet) throws PermissionDeniedException, InvalidDataException
annotationSet
- The annotation set to remove
PermissionDeniedException
- If the logged in user
doesn't have write permission for this annotation set
InvalidDataException
- If the annotation set is nullpublic boolean isInherited(AnnotationSet annotationSet) throws InvalidDataException
annotationSet
- The annotation set to check
InvalidDataException
- If the annotation set is nullpublic ItemQuery<AnnotationSet> getInheritedAnnotationSets()
ItemQuery
object
BaseException
- If there is an errorpublic int autoInherit(DbControl dc, AnnotationType annotationType, boolean preferAnnotationSet)
This method will only consider parent items that the logged in user has access to with USE permission.
This method may result in inheriting multiple annotations (from different parent items) of the specified annotation type.
dc
- The DbControl to use for database accessannotationType
- The annotation type to look forpreferAnnotationSet
- If TRUE, the entire annotation set containing the
found annotation is inherited, otherwise only the found annotation is inheritedpublic void copyFrom(Annotatable item, boolean overwrite)
item
- The item to copy annotation fromoverwrite
- TRUE to overwrite existing valuespublic ItemQuery<AnnotationSet> getInheritingAnnotationSets()
ItemQuery
object
|
2.10.1: 2009-03-24 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |