jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peeter Piegaze <peeter.pieg...@gmail.com>
Subject Re: associations between nodes
Date Thu, 28 Jul 2005 14:21:42 GMT
On 7/28/05, Michael Wechner <michael.wechner@wyona.com> wrote:
> David Nuescheler wrote:
> 
> >does this sound like a parent child relationship?
> >
> >
> 
> no. I shouldn't have used the example "mother", "parent", "child" ;-)
> 
> >or a reference?
> >
> >
> 
> that's what I thought first, but IIUC this cannot be used, because
> it's basically just a symbolic/soft link, right?

Nope, a reference property is not a soft link (the Path property type
corresponds to a soft link). It is in fact a property that holds the
UUID of the target node--which seems to be what you invented "by
hand", as you say below :-).

The Reference property adds the additional semantic that the
repository enforces referential integrity, meaning that you cannot
delete the Reference property without first deleting the target node.

> 
> Well, it's really like associations within TopicMaps.
> 
> I have currently implemented it by creating a sub-node called "associations"
> and then using multi-valued properties for each type of association and
> using the UUID strings of the associated nodes for the values.

As I mentioned, this is exactly what a Reference property is...so you
should use those.

To resolve in the direction
(javax.jcr.Property)refProp--->(javax.jcr.Node)targetNode you would
call refProp.getNode(). To resolve in the other direction you call
targetNode.getReferences().

A minor irritant is that currently if you want to use a multi-value
Reference property then to resolve  the target set you have to get
each Value from the property array using Property.getValues()...and
cast each to String and then retrieve each target node with
Session.getNodeByUUID(String uuid). A convenience method for
multi-value Reference property resolution might be a minor improvement
for v2.0 of JCR, but other than that I think the Reference property is
exactly what you are looking for

Hope this helps,

Cheers,
Peeter

> 
> E.g. a project can be associated with multiple tasks/issues, or a
> owner/person
> can be associated with multiple projects or multiple tast/issues.
> 
> But I am sure this could be done a bit more generic ;-)
> 
> Maybe it's something for a future verision of JSR-170 ...
> 
> Thanks
> 
> Michi
> 
> >regards,
> >david
> >
> >On 7/27/05, Michael Wechner <michael.wechner@wyona.com> wrote:
> >
> >
> >>Hi
> >>
> >>I would like to create bi-directional associations between nodes, e.g.
> >>
> >>a "JIRA issue" is associated with a "JIRA project/component"
> >>
> >>or
> >>
> >>a "person" is associated with a "mother" or "father" (is child of OR
> >>has child)
> >>
> >>Is there any best practice for doing this within JCR?
> >>
> >>It seems to me kind of similar to referencable, but IIUC referencable is
> >>basically a symbolic/soft link and hence cannot be (mis-)used.
> >>
> >>Thanks
> >>
> >>Michi
> >>
> >>--
> >>Michael Wechner
> >>Wyona      -   Open Source Content Management   -    Apache Lenya
> >>http://www.wyona.com                      http://lenya.apache.org
> >>michael.wechner@wyona.com                        michi@apache.org
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> 
> 
> --
> Michael Wechner
> Wyona      -   Open Source Content Management   -    Apache Lenya
> http://www.wyona.com                      http://lenya.apache.org
> michael.wechner@wyona.com                        michi@apache.org
> 
>

Mime
View raw message