Opened 9 years ago
Closed 9 years ago
#1992 closed defect (fixed)
The BASE core API allows annotations to be created without values
Reported by: | Nicklas Nordborg | Owned by: | everyone |
---|---|---|---|
Priority: | minor | Milestone: | BASE 3.8 |
Component: | core | Version: | |
Keywords: | Cc: |
Description (last modified by )
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 orIntegerValues
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 (5)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
comment:3 by , 9 years ago
comment:4 by , 9 years ago
comment:5 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [7106]) References #1992: The BASE core API allows annotations to be created without values
Added test code for testing this use case.