Opened 9 years ago

Last modified 9 years ago

#1992 closed defect

The BASE core API allows annotations to be created without values — at Version 1

Reported by: Nicklas Nordborg Owned by: everyone
Priority: minor Milestone: BASE 3.8
Component: core Version:
Keywords: Cc:

Description (last modified by Nicklas Nordborg)

This is something that is not possible to reproduce with the web client since if no values has been specified it will never try to create any annotations. However, the BASE core API allows an annotation to be created but never checks that values have been set for it.

On the other hand, trying to set an existing annotation to null will throw an exception (as expected).

The code for creating the empty annotations go something like this (assuming that we have an annotatable item and an annotation type):

Annotatable item = ...
AnnotationType at = ...
AnnotationSet as = item.getAnnotationSet();
Annotation a = as.getAnnotation(at); // <-The empty annotation is created here

// a.setValue(aValue) must be called to create a non-empty annotation

dc.commit(); // <- We must check that annotation values has been set here

The annotation information is spread out over multiple database tables. If the Annotation.setValue() method is called to set the annotation, here is what happens:

  • An entry in the Annotations table is created
  • An entry in the ParameterValues table is created
  • An entry in the actual data table is created. The actual table depends on the data type. For example StringValues for string annotations or IntegerValues for integer annotations.

If the Annotation.setValue() method is not called only the first two entries are created but not the third. This can result in some strange behavior in other places since if an annotation entry exists it is expected to have at least one value.

Change History (1)

comment:1 by Nicklas Nordborg, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.