This article explains how to use the API AnnotationAccessor useful to define a customized way to fetch, add, update and remove annotations in a connector.
When you create your own connector you have to define how to fetch, add, update and remove annotations. To do this ARender offers an API that defines four main methods to implement: create, update, get and delete.
Below the three main steps to initialize your own AnnotationAccessor :
public class CustomAnnotationAccessor implements AnnotationAccessor {
The good practice is to define two constructors.
One default generic constructor, based only on the documentId:
public CustomAnnotationAccessor(DocumentService documentService, DocumentId documentId)
{
if (documentId == null)
{
throw new IllegalArgumentException("Invalid null documentId provided !");
}
this.documentId = documentId;
}
And another one based on the documentAccessor:
public CustomAnnotationAccessor(DocumentService documentService, DocumentAccessor documentAccessor)
{
this(documentService, documentAccessor.getUUID());
}
This method takes in parameter a list of Annotation that has been created and saved.
Define here where and how to store these new annotations.
@Override
public void create(List<com.arondor.viewer.annotation.api.Annotation> annotations)
throws AnnotationsNotSupportedException, InvalidAnnotationFormatException, AnnotationCredentialsException,
AnnotationNotAvailableException
{
This method takes in parameter a list of Annotation that has been updated and saved.
Define here where and how to save these updated annotations.
@Override
public void update(List<com.arondor.viewer.annotation.api.Annotation> annotations)
throws AnnotationsNotSupportedException, InvalidAnnotationFormatException, AnnotationNotAvailableException,
AnnotationCredentialsException
{
This method returns a list of Annotation to fetch. Define here how to fetch them.
@Override
public synchronized List<Annotation> get() throws AnnotationsNotSupportedException,
InvalidAnnotationFormatException
{
This method takes in parameter a list of Annotation that have been removed. Define here where and how to remove them.
@Override
public void delete(List<com.arondor.viewer.annotation.api.Annotation> annotations)
throws AnnotationsNotSupportedException, InvalidAnnotationFormatException, AnnotationNotAvailableException,
AnnotationCredentialsException
{
This method returns an Object AnnotationCreationPolicy defining:
@Override
public AnnotationCreationPolicy getAnnotationCreationPolicy()
{
return annotationCreationPolicy;
}
Useful links :