Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tigerstripe-dev] Annotations Conversation

Hi Yuri,
 
Many thanks for your help earlier this morning in pointing out that I need to keep the Annotation object I create in order that any changes I make to the content can be saved back - that is, it is not correct for me to hold the content alone and to look later in the AnnotationManager for the Annotation object that wraps the content.
 
So, I tried holding the Annotation object and saving that, but this gives me a NullPointerException in  AnnotationStorage.save(Annotation a) because there is no matching ChangeRecorder in the changes Map. I have debuggedthis and I find that the reason for this lies in the way in which the id is assigned to an Annotation instance... That is, in AnnotationStorage.add(Annotation a) we have the code:
 
addToList(annotation, annotation.getUri()); // add to list for URI
trackChanges(annotation);                        // create ChangeRecorder and put in changes Map - id is null at this point
database.write(annotation);                       // assign an id to the Annotation and write to DB
fireAnnotationAdded(annotation);
 
the crucial point is that if the id is null the hash-code is computed using an algorithm in EObject and not from the id, but when I go back and pass my Annotation into the save(...) method ithas an id and so a different hash-code is computed... which means I can never match my Annotation to ind the ChangeRcorder.
 
So, what I have done as a temporary measure is to swap the order of the trachChanges(...)database.write(...) and this seems to work. However, I think the correct thing to do is to assign an id to the Annotation at the point of creation, and ideally to make that id immutable/read-only.
 
What do you think? Have I mis-interpreted?
 
Thanks again,
 
JohnW
 

John Worrell
Technical Leader

jworrell@xxxxxxxxx
Phone: +44 208824 9410
Mobile: +44 7789 922290

Cisco Systems Limited
250 Longwater Avenue
Reading
RG2 6GB
United Kingdom
Cisco home page

 
Think before you print. Think before you print.
This e-mail may contain confidential and privileged material for the sole use of the intended recipient. Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply e-mail and delete all copies of this message.


 

Back to the top