Technical News | Page 1

Create a new AnnotationAccessor

Written by Marye | Jan 6, 2016 5:00:00 AM

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 :

  1. Implement the interface AnnotationAccessor
  2. Create constructors
  3. Methods to implement

1. Implement the interface AnnotationAccessor

public class CustomAnnotationAccessor implements AnnotationAccessor {

2. Create constructors

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());
}

3. Methods to implement

Method create

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
{

Method update

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
{

Method get

This method returns a list of Annotation to fetch. Define here how to fetch them.

@Override
public synchronized List<Annotation> get() throws AnnotationsNotSupportedException,
        InvalidAnnotationFormatException
{

Method delete

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
{

Method getAnnotationCreationPolicy

This method returns an Object AnnotationCreationPolicy defining:

  • If the user can create or not annotations
  • The user stamp catalog
@Override
public AnnotationCreationPolicy getAnnotationCreationPolicy()
{
    return annotationCreationPolicy;
}

Useful links :