Last update: 2011-06-23

org.proteios.core
Class AnnotationSet

java.lang.Object
  extended by org.proteios.core.BasicItem<AnnotationSetData>
      extended by org.proteios.core.AnnotationSet
All Implemented Interfaces:
AccessControlled, Identifiable

public class AnnotationSet
extends BasicItem<AnnotationSetData>

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.

Version:
2.0
Author:
Nicklas
See Also:
AnnotationType, Annotation
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Field Summary
static Item TYPE
          The type of item represented by this class.
 
Method Summary
 boolean contentEquals(AnnotationSet as)
          Compare the AnnotationSet with another.
 ItemQuery<Annotation> getAnnotations()
          Get a query that reurns all direct annotations in this annotation set.
 ItemQuery<Annotation> getInheritedAnnotations()
          Get a query that returns all 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.
 Item getItemType()
          Get the Item type of the item this annotation set belongs to.
 Item getType()
          Get the type of item represented by the object.
 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.
 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.
 
Methods inherited from class org.proteios.core.BasicItem
checkPermission, equals, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.ANNOTATIONSET, getType()
Method Detail

getType

public 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 the Item enumeration.

Returns:
A value indicating the type of item

isUsed

public boolean isUsed()
               throws BaseException
Always return TRUE. An annotation set always has a one-to-one relation to some item. The annotation set is automatically deleted if that item is deleted.

Specified by:
isUsed in class BasicItem<AnnotationSetData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException

getItem

public Annotatable getItem()
                    throws PermissionDeniedException,
                           BaseException
Get the item this annotation set belongs to.

Returns:
The Annotatable item
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the item
BaseException - If there is another error

getItemType

public Item getItemType()
Get the Item type of the item this annotation set belongs to.


hasAnnotation

public boolean hasAnnotation(AnnotationType annotationType)
Check if the annotation set contains an annotation of the specified type.

Parameters:
annotationType - An AnnotationType object
Returns:
TRUE if the annotation set contains an annotation of the specified type, FALSE otherwise

removeAnnotation

public void removeAnnotation(AnnotationType annotationType)
                      throws PermissionDeniedException,
                             InvalidDataException,
                             BaseException
Delete the annotation of the specified annotation type.

Parameters:
annotationType - The type of the annotation to delete
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the annotation type is null
BaseException - If there is another error

getAnnotations

public ItemQuery<Annotation> getAnnotations()
Get a query that reurns all direct annotations in this annotation set.

Returns:
An ItemQuery object

inheritAnnotation

public void inheritAnnotation(Annotation annotation)
                       throws PermissionDeniedException,
                              InvalidDataException
Inherit an annotation.

Parameters:
annotation - The annotation to inherit
Throws:
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 null

removeInheritedAnnotation

public void removeInheritedAnnotation(Annotation annotation)
                               throws PermissionDeniedException,
                                      InvalidDataException
Remove an inherited an annotation.

Parameters:
annotation - The annotation to remove
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission for this annotation set
InvalidDataException - If the annotation is null

isInherited

public boolean isInherited(Annotation annotation)
                    throws InvalidDataException
Check if an annotation is inherited or not by this annotation set.

Parameters:
annotation - The annotation to check
Throws:
InvalidDataException - If the annotation is null

getInheritedAnnotations

public ItemQuery<Annotation> getInheritedAnnotations()
                                              throws BaseException
Get a query that returns all inherited annotations in this annotation set.

Returns:
An ItemQuery object
Throws:
BaseException

inheritAnnotationSet

public void inheritAnnotationSet(AnnotationSet annotationSet)
                          throws PermissionDeniedException,
                                 InvalidDataException
Inherit an annotation set.

Parameters:
annotationSet - The annotation set to inherit
Throws:
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 null

removeInheritedAnnotationSet

public void removeInheritedAnnotationSet(AnnotationSet annotationSet)
                                  throws PermissionDeniedException,
                                         InvalidDataException
Remove an inherited an annotation set.

Parameters:
annotationSet - The annotation set to remove
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission for this annotation set
InvalidDataException - If the annotation set is null

isInherited

public boolean isInherited(AnnotationSet annotationSet)
                    throws InvalidDataException
Check if an annotation set is inherited or not by this annotation set.

Parameters:
annotationSet - The annotation set to check
Throws:
InvalidDataException - If the annotation set is null

getInheritedAnnotationSets

public ItemQuery<AnnotationSet> getInheritedAnnotationSets()
Get a query that returns all inherited annotation sets in this annotation set.

Returns:
An ItemQuery object
Throws:
BaseException - If there is an error

getInheritingAnnotationSets

public ItemQuery<AnnotationSet> getInheritingAnnotationSets()
Get a query that returns all annotation sets inheriting from this annotation set.

Returns:
An ItemQuery object

contentEquals

public boolean contentEquals(AnnotationSet as)
Compare the AnnotationSet with another. To be considered as having equal content, the two annotationsets must annotate the same item type, contain the same number of annotations and all of the annotations must be equal as defined by the Annotation.equals() function. TODO: Testing. The function will only work properly if both annotationsets are in the database

Parameters:
as - The AnnotationSet to compare with
Returns:
true if equal, otherwise false;

Last update: 2011-06-23