You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "R. Ben Truitt" <bt...@rackspace.com> on 2006/07/28 23:30:08 UTC
versioning / reference question
Hi -
I am fairly new to JCR, and am trying to figure out how to do the
below scenario:
I've created two node types, myns:typeA and myns:typeB.
myns:typeA has as a supertype mix:versionable. myns:typeB has as a
property:
- myns:typeA_reference (reference) primary < 'myns:typeA'
So far so good. I can get create NodeA of type myns:typeA and NodeB
of myns:typeB, and have NodeB hold a reference to NodeA. Sweet.
But what I'd *like* to be able to do, is to have NodeB hold a
reference to any version (past or present) of NodeA. I tried
modifying my definition for myns:typeB to this:
- myns:typeA_reference (reference) primary <
'myns:typeA','nt:frozenNode'
But, when I try to add set the reference property
"myns:typeA_reference" to refer to a previous version of NodeA, I get
this exception:
javax.jcr.nodetype.ConstraintViolationException: [node path here]:
does not satisfy the value constraint myns:typeA
So my questions are:
1) Since the JCR spec says that constraints are or'd together, it
seems like I shouldn't get this exception. What am I missing here?
2) I'm not very sure I am thinking about this in the right way. Is
there a better way to refer to an arbitrary version of NodeA from NodeB?
Thanks for your help!!
-Ben
Re: versioning / reference question
Posted by "R. Ben Truitt" <bt...@rackspace.com>.
Oh and a followup on this - if I remove all property value
constraints, my tests pass as expected. Of course I'd prefer to
constrain values to nodes of type myns:typeA or versions thereof.
On Jul 28, 2006, at 4:30 PM, R. Ben Truitt wrote:
> Hi -
> I am fairly new to JCR, and am trying to figure out how to do the
> below scenario:
>
> I've created two node types, myns:typeA and myns:typeB.
> myns:typeA has as a supertype mix:versionable. myns:typeB has as a
> property:
> - myns:typeA_reference (reference) primary < 'myns:typeA'
>
> So far so good. I can get create NodeA of type myns:typeA and
> NodeB of myns:typeB, and have NodeB hold a reference to NodeA. Sweet.
>
> But what I'd *like* to be able to do, is to have NodeB hold a
> reference to any version (past or present) of NodeA. I tried
> modifying my definition for myns:typeB to this:
> - myns:typeA_reference (reference) primary <
> 'myns:typeA','nt:frozenNode'
>
> But, when I try to add set the reference property
> "myns:typeA_reference" to refer to a previous version of NodeA, I
> get this exception:
> javax.jcr.nodetype.ConstraintViolationException: [node path here]:
> does not satisfy the value constraint myns:typeA
>
> So my questions are:
> 1) Since the JCR spec says that constraints are or'd together, it
> seems like I shouldn't get this exception. What am I missing here?
> 2) I'm not very sure I am thinking about this in the right way. Is
> there a better way to refer to an arbitrary version of NodeA from
> NodeB?
>
> Thanks for your help!!
> -Ben
Re: versioning / reference question
Posted by "R. Ben Truitt" <bt...@rackspace.com>.
Dumb question answered.
nodeA.getBaseVersion() will return a node whose primary node type is
'nt:version' (not 'nt:frozenNode' as I'd thought).
By changing my property value constraint to:
>>> - myns:typeA_reference (reference) primary <
>>> 'myns:typeA','nt:version'
things started working the way I'd expected.
Thanks for the help!!
On Jul 29, 2006, at 1:08 PM, R. Ben Truitt wrote:
> It turns out I was passing the version node, which has a name of
> "*". Sorry if this is a dumb question, but how do I get the frozen
> node from the version node?
>
> Here is how I'm getting the version node:
>
> //set nodeB to refer specifically to the most recent version of nodeA
> nodeB.setProperty("myns:typeA_reference", nodeA.getBaseVersion());
>
> where nodeA.getBaseVersion() returns an object of type Version.
>
> On Jul 29, 2006, at 9:29 AM, Tobias Bocanegra wrote:
>
>> hi ben,
>> the constraints are or'd. so your example should work, if you really
>> pass the frozen node and not the version node.
>>
>> regards, toby
>>
>> On 7/28/06, R. Ben Truitt <bt...@rackspace.com> wrote:
>>> Hi -
>>> I am fairly new to JCR, and am trying to figure out how to do the
>>> below scenario:
>>>
>>> I've created two node types, myns:typeA and myns:typeB.
>>> myns:typeA has as a supertype mix:versionable. myns:typeB has as a
>>> property:
>>> - myns:typeA_reference (reference) primary < 'myns:typeA'
>>>
>>> So far so good. I can get create NodeA of type myns:typeA and
>>> NodeB
>>> of myns:typeB, and have NodeB hold a reference to NodeA. Sweet.
>>>
>>> But what I'd *like* to be able to do, is to have NodeB hold a
>>> reference to any version (past or present) of NodeA. I tried
>>> modifying my definition for myns:typeB to this:
>>> - myns:typeA_reference (reference) primary <
>>> 'myns:typeA','nt:frozenNode'
>>>
>>> But, when I try to add set the reference property
>>> "myns:typeA_reference" to refer to a previous version of NodeA, I
>>> get
>>> this exception:
>>> javax.jcr.nodetype.ConstraintViolationException: [node path here]:
>>> does not satisfy the value constraint myns:typeA
>>>
>>> So my questions are:
>>> 1) Since the JCR spec says that constraints are or'd together, it
>>> seems like I shouldn't get this exception. What am I missing here?
>>> 2) I'm not very sure I am thinking about this in the right way. Is
>>> there a better way to refer to an arbitrary version of NodeA from
>>> NodeB?
>>>
>>> Thanks for your help!!
>>> -Ben
>>>
>>
>>
>> --
>> -----------------------------------------<
>> tobias.bocanegra@day.com >---
>> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001
>> Basel
>> T +41 61 226 98 98, F +41 61 226 98 97
>> -----------------------------------------------< http://
>> www.day.com >---
>
Re: versioning / reference question
Posted by "R. Ben Truitt" <bt...@rackspace.com>.
It turns out I was passing the version node, which has a name of
"*". Sorry if this is a dumb question, but how do I get the frozen
node from the version node?
Here is how I'm getting the version node:
//set nodeB to refer specifically to the most recent version of nodeA
nodeB.setProperty("myns:typeA_reference", nodeA.getBaseVersion());
where nodeA.getBaseVersion() returns an object of type Version.
On Jul 29, 2006, at 9:29 AM, Tobias Bocanegra wrote:
> hi ben,
> the constraints are or'd. so your example should work, if you really
> pass the frozen node and not the version node.
>
> regards, toby
>
> On 7/28/06, R. Ben Truitt <bt...@rackspace.com> wrote:
>> Hi -
>> I am fairly new to JCR, and am trying to figure out how to do the
>> below scenario:
>>
>> I've created two node types, myns:typeA and myns:typeB.
>> myns:typeA has as a supertype mix:versionable. myns:typeB has as a
>> property:
>> - myns:typeA_reference (reference) primary < 'myns:typeA'
>>
>> So far so good. I can get create NodeA of type myns:typeA and NodeB
>> of myns:typeB, and have NodeB hold a reference to NodeA. Sweet.
>>
>> But what I'd *like* to be able to do, is to have NodeB hold a
>> reference to any version (past or present) of NodeA. I tried
>> modifying my definition for myns:typeB to this:
>> - myns:typeA_reference (reference) primary <
>> 'myns:typeA','nt:frozenNode'
>>
>> But, when I try to add set the reference property
>> "myns:typeA_reference" to refer to a previous version of NodeA, I get
>> this exception:
>> javax.jcr.nodetype.ConstraintViolationException: [node path here]:
>> does not satisfy the value constraint myns:typeA
>>
>> So my questions are:
>> 1) Since the JCR spec says that constraints are or'd together, it
>> seems like I shouldn't get this exception. What am I missing here?
>> 2) I'm not very sure I am thinking about this in the right way. Is
>> there a better way to refer to an arbitrary version of NodeA from
>> NodeB?
>>
>> Thanks for your help!!
>> -Ben
>>
>
>
> --
> -----------------------------------------< tobias.bocanegra@day.com
> >---
> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001
> Basel
> T +41 61 226 98 98, F +41 61 226 98 97
> -----------------------------------------------< http://www.day.com
> >---
Re: versioning / reference question
Posted by Tobias Bocanegra <to...@day.com>.
hi ben,
the constraints are or'd. so your example should work, if you really
pass the frozen node and not the version node.
regards, toby
On 7/28/06, R. Ben Truitt <bt...@rackspace.com> wrote:
> Hi -
> I am fairly new to JCR, and am trying to figure out how to do the
> below scenario:
>
> I've created two node types, myns:typeA and myns:typeB.
> myns:typeA has as a supertype mix:versionable. myns:typeB has as a
> property:
> - myns:typeA_reference (reference) primary < 'myns:typeA'
>
> So far so good. I can get create NodeA of type myns:typeA and NodeB
> of myns:typeB, and have NodeB hold a reference to NodeA. Sweet.
>
> But what I'd *like* to be able to do, is to have NodeB hold a
> reference to any version (past or present) of NodeA. I tried
> modifying my definition for myns:typeB to this:
> - myns:typeA_reference (reference) primary <
> 'myns:typeA','nt:frozenNode'
>
> But, when I try to add set the reference property
> "myns:typeA_reference" to refer to a previous version of NodeA, I get
> this exception:
> javax.jcr.nodetype.ConstraintViolationException: [node path here]:
> does not satisfy the value constraint myns:typeA
>
> So my questions are:
> 1) Since the JCR spec says that constraints are or'd together, it
> seems like I shouldn't get this exception. What am I missing here?
> 2) I'm not very sure I am thinking about this in the right way. Is
> there a better way to refer to an arbitrary version of NodeA from NodeB?
>
> Thanks for your help!!
> -Ben
>
--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---