The problems that I am facing now are related to 2 things:
= Approach 1 =
If you use only XWiki.XWikiComments (extended with annotation fileds as the
pull request is now), you lose the Annotation feature's capability to
specify a different AnnotationClass. This means that, if you want to
customize the annotation, you need to extend the XWikiComments class
directly, and nothing else.
This might break existing clients that have provided their own annotation
class and will not display their annotations. Writing a migrator for that
would imply looking at the configured annotation class that they have
provided, update XWikiComments class with the new fields that might be
present in that annotation class and convert the annotation objects to use
the updated XWikiComments class instead. Would that be enough?
This solution will ensure that both "annotation" and "comment" IDs are
in
the same namespace and are unique. This also ensures that:
- the replyTo field points to a proper object ID of class XWikiComments
- the html IDs are unique in the page so that the permalinks and anchors
for jumping to the annotation and back to the comments tab work
- the comments are naturally sorted by ID
General downside of solution 1: you lose the ability to change the
annotation backend, since you just look at XWiki objects in the page.
= Approach 2 =
The merging solution has a few problems of it's own:
a) The annotation service returns java object Annotations, while the
commentsinline.vm works with XWiki API objects.
To avoid this problem, we can just do what the old AnnotationsTab did, and
that is to directly get the XWiki objects stored in the page using the
class configured in the annotations config.
Downside: you lose the ability to change the annotation backend, since you
just look at XWiki objects in the page.
b) Merging things means that we keep both the comments and annotations as
separate entities. This means that each have their own ID namespace,
causing collisions for the replyTo and permalink features. To avoid this,
we would have to do some not-so-nice tricks and mark annotations ID (like
"annotation1") so that they are separated from regular comments IDs (when
used in the replyTo field).
b.1) One solution would be to change the replyTo field's type from Number
to String so that we can store this separation.
Downside1: This still requires a migration.
Downside2: because this means to use the solution for a), we still loose
the ability to change the annotation backend.
b.2)The other solution would be to use the annotation service API when
getting the list of annotations and make a convention when an annotation is
created so that it's numeric ID starts from a very large number (like
1.000.000 or more).
Downside: Same as problem a): we have to work with 2 types and lots of "IF
statements" when processing the comments. Ex: One type has comment.number
(for comments), while the other one has comment.id (for annotations). Same
thing for dates: comment.getProperty('date').value vs comment.date.
General downside of solution2: Since they are merged and no longer
naturally sorted by object ID, the comments and annotations also need to be
sorted by date.
= Conclusion=
As I look more into the problem, it does seem that the first approach is
the best, having the least number of compromises and doing a better job at
semantically merging the two concepts into one.
Do you agree?
Thanks for your feedback,
Eduard
On Fri, Feb 17, 2012 at 11:43 AM, Jerome Velociter <jerome(a)winesquare.net>wrote;wrote:
Le 16 févr. 2012 18:38, "Eduard Moraru"
<enygma2002(a)gmail.com> a écrit :
Hi devs,
Based on the work done by Anca and Sorin doring the XWiki 2011 Seminar
Hackaton, I`ve made the following pull request [1] to integrate their
work
with minor changes.
A summary of the changes contained by the pull request are described in
the
jira issue [2].
The problem at the current stage, as Jerome also hinted, is that we need
to
do a migration script to make the existing
annotations (in an upgrade
scenario) use the XWikiComments class instead so that they can be picked
up
by commentsinline.vm. However, this might lose
the possibility to provide
custom annotations.
An alternative would be to make commentsinline.vm use the annotation
service and handle and retrieve both Annotation and XWikiComment objects.
This way, the current annotations should need no migration script since
they are using a class configured in the AnnotationConfig page that the
annotation service knows how to handle.
WDYT?
I'm tending to prefer a proper migration. I've played in the past with
aggregation of both classes on a small "recent reviews" macro, and I recall
some (non-trivial) HQL queries were a pain to write, when doable in a
single query at all. I can look for specific examples if needed.
I fear that if we let both classes live together, some potential future UI
or service or whatever that exposes boths in a unified manner might be
harder to implement.
Jérôme
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs