We want to show related annotations and forum posts in the first tab of the object (Object Details). Related annotations/posts for an object are the ones that mention it or its fields.
Annotation's content is stored as text and we need to parse it and find out if any links to objects are present. We will do that when saving annotation/post.
If any linked objects are present in text, we need to refresh a list of related objects for the annotation/post in OWLIM. That is, each time annotation/post is edited we need to parse and recreate the list per annotation/post.
Annotations are identified by their URIs. Forum posts have numeric IDs. Forum posts are not currently stored in OWLIM. We need to generate URIs for them, for example: http://researchspace.com/jforum/123 where '123' isthe post's ID.
1. When annotation or forum post are saved, we need to parse the text. We search for links like:
The first (linkMO) is a link to Museum Object while the second (linkStatement) is a link to annotation point.
We collect the URIs of the MO/AP. If is Annotation Point, the we load it and get URI if the object it belongs to. (See APLink class and APLink.annotationPoint.main)
After annotation is saved (so that we have the annotation's URI for new annotations), we recreate the list for related objects for this annotation. That is, we delete all related objects and create a new list that contains the latest ones.
Same goes for the forum posts.
Related objects are stored using a method in the DMS2RDF class.
There will be 2 methods in DMS2RDF:
Annotation getReferringAnnotations(URI uri): returns all annotations that mention the MO with this uri or its data fields (annotation points);
String getReferringForumPosts(URI uri): returns all forum posts that mention the MO with this uri or its data fields (annotation points); IDs for the forum posts are returned as Strings.