|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.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
|
Nested classes/interfaces inherited from interface net.sf.basedb.core.Transactional |
---|
Transactional.Action |
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. |
private boolean |
snapshotIsInvalid
Flag to indicate if this annotation set has been modified and the snapshot must be removed. |
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)
Deprecated. In 2.15, use autoInherit(DbControl, Collection, SnapshotManager, boolean)
instead since it has better performance |
int |
autoInherit(DbControl dc,
Collection<AnnotationType> annotationTypes,
SnapshotManager manager,
boolean preferAnnotationSet)
Automatically inherit all annotations of one or more specified annotation types from parent items that are currntly missing from this annotation set This method will only consider parent items that the logged in user has access to with USE permission. |
void |
copyFrom(Annotatable item,
boolean overwrite)
Copy annotations from another annotatable item to this annotation set. |
static AnnotationSetSnapshot |
createSnapshot(DbControl dc,
int annotationSetId)
Create a new annotation snapshot for the given 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. |
int |
getItemId()
Get the ID of the item this annotation set belongs to. |
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 |
isSnapshotInvalid()
Get the status of the 'invalid snapshot' flag. |
boolean |
isUsed()
Always return TRUE. |
(package private) static int |
loadItemId(org.hibernate.Session session,
Item itemType,
int annotationSetId)
Load the id of the item that this annotation set belongs to. |
(package private) void |
onBeforeCommit(Transactional.Action action)
Remove the cached snapshot if needed. |
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. |
void |
setSnapshotInvalid()
Mark the snapshot (if it exists) of this annotation set as invalid. |
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, 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
private boolean snapshotIsInvalid
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
objectstatic int loadItemId(org.hibernate.Session session, Item itemType, int annotationSetId)
public static AnnotationSetSnapshot createSnapshot(DbControl dc, int annotationSetId)
It is recommended that snapshots are cached as files in the static cache
since they are much quiker to load. Use SnapshotManager.getSnapshot(DbControl, int)
is instead of this method.
dc
- A DbControl to use for database accessannotationSetId
- The ID of the annotation set
public Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
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>
void onBeforeCommit(Transactional.Action action) throws BaseException
onBeforeCommit
in class BasicItem<AnnotationSetData>
BaseException
- If there is an errorTransactional
,
Core API overview - Transaction handling,
Coding rules and guidelines for item classespublic 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
public int getItemId()
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.
NOTE!!!! Do not use this method if you need to find many annotation in many items.
It has bad performance. It is better to use the cached snapshots.
See SnapshotManager
.
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)
autoInherit(DbControl, Collection, SnapshotManager, boolean)
instead since it has better performance
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 int autoInherit(DbControl dc, Collection<AnnotationType> annotationTypes, SnapshotManager manager, 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 accessannotationTypes
- The annotation type to look formanager
- A snapshot manager that is used to look up annotationspreferAnnotationSet
- 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
objectpublic void setSnapshotInvalid()
public boolean isSnapshotInvalid()
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |