You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Cosmin Zamfir <co...@yahoo.com> on 2006/11/16 10:28:28 UTC

Creating NodeType with dynamic, linked properties

Hello all,

Suppose I want to create several NodeTypes, each of them containing  a Property called "category" whose value is constrained to a List of values.

The constraint  list  will  need to be expanded as more categories will be added. This change should be reflected then in all NodeTypes which contain the "category" property.
Unfortunately, it seems that the PropertyDefinition is somehow static, getValueConstraints() only allows to define one time the constraints. There is no functionality to create a link to a dynamic Property, so that all changes made in the Property will be reflected in all NodeTypes using this Property.

The only solution I see at the moment is to create a custom implementation, outside the repository, to mimic the NodeType interface,
 including inheritance. But doing so will create a lot of disadvantages; including the fact that there will be no checks done by the repository itself for compliance to the NodeType of new Nodes. 

Are you aware of any posibility to create such a functionality using the repository?

Thanks a lot,
Cosmin








 
____________________________________________________________________________________
Sponsored Link

Mortgage rates near 39yr lows. 
$510k for $1,698/mo. Calculate new payment! 
www.LowerMyBills.com/lre

Re: Creating NodeType with dynamic, linked properties

Posted by Ted Roeloffzen <te...@gmail.com>.
Okay than that was the problem. i was using Jackrabbit 1.0.1

Ted

Re: Creating NodeType with dynamic, linked properties

Posted by Tobias Bocanegra <to...@day.com>.
yes, but the CND parser automatically adds nt:base as supertype, if needed.

for jackrabbit 1.1, this is automatically done when registering the nodetype.
see: http://issues.apache.org/jira/browse/JCR-433

regards, toby

On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> But when we extend from mix:referenceable we also have to extend from
> nt:base, right? Because every primarytype should directly or indirectly
> extend from nt:base and mix:referenceable has no supertype.
>
> Ted
>
> 2006/11/16, Ted Roeloffzen <te...@gmail.com>:
> >
> > I copied it from the jackrabbit example on the site.
> > So the example on the site should be altered, because it isn't correct.
> >
> > Ted
> >
> > 2006/11/16, Tobias Bocanegra < tobias.bocanegra@day.com>:
> > >
> > > > mix:referencable
> > > < mix:referenceable
> > >
> > > :-)
> > >
> > > On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > > > When I extend my nodetype from mix:referencable I get an exception.
> > > > Invalid supertype.
> > > >
> > > > Do you have any idea what this could be?
> > > >
> > > > Ted
> > > >
> > > > 2006/11/16, Stefan Guggisberg <st...@gmail.com>:
> > > > >
> > > > > On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > > > > > So that would mean that those nodetype are referenceable by
> > > default?
> > > > >
> > > > > yes
> > > > >
> > > > > >
> > > > > > Ted
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > -----------------------------------------< 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 >---
> > >
> >
> >
>
>


-- 
-----------------------------------------< 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: Creating NodeType with dynamic, linked properties

Posted by Ted Roeloffzen <te...@gmail.com>.
But when we extend from mix:referenceable we also have to extend from
nt:base, right? Because every primarytype should directly or indirectly
extend from nt:base and mix:referenceable has no supertype.

Ted

2006/11/16, Ted Roeloffzen <te...@gmail.com>:
>
> I copied it from the jackrabbit example on the site.
> So the example on the site should be altered, because it isn't correct.
>
> Ted
>
> 2006/11/16, Tobias Bocanegra < tobias.bocanegra@day.com>:
> >
> > > mix:referencable
> > < mix:referenceable
> >
> > :-)
> >
> > On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > > When I extend my nodetype from mix:referencable I get an exception.
> > > Invalid supertype.
> > >
> > > Do you have any idea what this could be?
> > >
> > > Ted
> > >
> > > 2006/11/16, Stefan Guggisberg <st...@gmail.com>:
> > > >
> > > > On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > > > > So that would mean that those nodetype are referenceable by
> > default?
> > > >
> > > > yes
> > > >
> > > > >
> > > > > Ted
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> >
> > --
> > -----------------------------------------< 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: Creating NodeType with dynamic, linked properties

Posted by Ted Roeloffzen <te...@gmail.com>.
I copied it from the jackrabbit example on the site.
So the example on the site should be altered, because it isn't correct.

Ted

2006/11/16, Tobias Bocanegra <to...@day.com>:
>
> > mix:referencable
> < mix:referenceable
>
> :-)
>
> On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > When I extend my nodetype from mix:referencable I get an exception.
> > Invalid supertype.
> >
> > Do you have any idea what this could be?
> >
> > Ted
> >
> > 2006/11/16, Stefan Guggisberg <st...@gmail.com>:
> > >
> > > On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > > > So that would mean that those nodetype are referenceable by default?
> > >
> > > yes
> > >
> > > >
> > > > Ted
> > > >
> > > >
> > >
> >
> >
>
>
> --
> -----------------------------------------< 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: Creating NodeType with dynamic, linked properties

Posted by Tobias Bocanegra <to...@day.com>.
> mix:referencable
< mix:referenceable

:-)

On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> When I extend my nodetype from mix:referencable I get an exception.
> Invalid supertype.
>
> Do you have any idea what this could be?
>
> Ted
>
> 2006/11/16, Stefan Guggisberg <st...@gmail.com>:
> >
> > On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > > So that would mean that those nodetype are referenceable by default?
> >
> > yes
> >
> > >
> > > Ted
> > >
> > >
> >
>
>


-- 
-----------------------------------------< 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: Creating NodeType with dynamic, linked properties

Posted by Ted Roeloffzen <te...@gmail.com>.
When I extend my nodetype from mix:referencable I get an exception.
Invalid supertype.

Do you have any idea what this could be?

Ted

2006/11/16, Stefan Guggisberg <st...@gmail.com>:
>
> On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> > So that would mean that those nodetype are referenceable by default?
>
> yes
>
> >
> > Ted
> >
> >
>

Re: Creating NodeType with dynamic, linked properties

Posted by Stefan Guggisberg <st...@gmail.com>.
On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> So that would mean that those nodetype are referenceable by default?

yes

>
> Ted
>
>

Re: Creating NodeType with dynamic, linked properties

Posted by Ted Roeloffzen <te...@gmail.com>.
So that would mean that those nodetype are referenceable by default?

Ted

Re: Creating NodeType with dynamic, linked properties

Posted by Stefan Guggisberg <st...@gmail.com>.
On 11/16/06, Ted Roeloffzen <te...@gmail.com> wrote:
> Can a nodetype extend from a mixintype and be a primarytype?

yup, see e.g.

[nt:resource] > mix:referenceable
  - jcr:encoding (string)
  - jcr:mimeType (string) mandatory
  - jcr:data (binary) primary mandatory
  - jcr:lastModified (date) mandatory ignore

cheers
stefan

>
> Ted
>
>

Re: Creating NodeType with dynamic, linked properties

Posted by Ted Roeloffzen <te...@gmail.com>.
Can a nodetype extend from a mixintype and be a primarytype?

Ted

Re: Creating NodeType with dynamic, linked properties

Posted by Marcel Dullaart <ma...@gmail.com>.
Hi all,

This definitely seems to be a good idea for several occasions.
I'd like to re-use this idea for defining locales, and using them to
determine the locale for content items.
But how can I restrict the type of a reference in the cnd file?

Thanks,
Marcel

On 11/16/06, Jukka Zitting <ju...@gmail.com> wrote:
>
> Hi,
>
> On 11/16/06, Stefan Guggisberg <st...@gmail.com> wrote:
> > you could e.g. create a node type myapp:Category that extends from
> > mix:referenceable. now for each category (e.g. book, dvd, etc) you can
> > create a node of type myapp:Category.
> >
> > in your custom node types make your "category" property a REFERENCE
> > property and restrict it to myapp:Category.
> >
> > you can add new categories (nodes of type myapp:Category) at any time.
>
> This is one of my favourite JCR patterns. Not only it gives you nice
> and controlled extensibility, it allows you to easily attach whatever
> information to the category nodes *and* gives you a blazing-fast
> mechanism to list all nodes that link to a given category.
>
> BR,
>
> Jukka Zitting
>

Re: Creating NodeType with dynamic, linked properties

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 11/16/06, Stefan Guggisberg <st...@gmail.com> wrote:
> you could e.g. create a node type myapp:Category that extends from
> mix:referenceable. now for each category (e.g. book, dvd, etc) you can
> create a node of type myapp:Category.
>
> in your custom node types make your "category" property a REFERENCE
> property and restrict it to myapp:Category.
>
> you can add new categories (nodes of type myapp:Category) at any time.

This is one of my favourite JCR patterns. Not only it gives you nice
and controlled extensibility, it allows you to easily attach whatever
information to the category nodes *and* gives you a blazing-fast
mechanism to list all nodes that link to a given category.

BR,

Jukka Zitting

Re: Creating NodeType with dynamic, linked properties

Posted by Stefan Guggisberg <st...@gmail.com>.
hi cosmin

On 11/16/06, Cosmin Zamfir <co...@yahoo.com> wrote:
> Hello all,
>
> Suppose I want to create several NodeTypes, each of them containing  a Property called "category" whose value is constrained to a List of values.
>
> The constraint  list  will  need to be expanded as more categories will be added. This change should be reflected then in all NodeTypes which contain the "category" property.
> Unfortunately, it seems that the PropertyDefinition is somehow static, getValueConstraints() only allows to define one time the constraints. There is no functionality to create a link to a dynamic Property, so that all changes made in the Property will be reflected in all NodeTypes using this Property.
>
> The only solution I see at the moment is to create a custom implementation, outside the repository, to mimic the NodeType interface,
>  including inheritance. But doing so will create a lot of disadvantages; including the fact that there will be no checks done by the repository itself for compliance to the NodeType of new Nodes.
>
> Are you aware of any posibility to create such a functionality using the repository?

you could e.g. create a node type myapp:Category that extends from
mix:referenceable. now for each category (e.g. book, dvd, etc) you can
create a node of type myapp:Category.

in your custom node types make your "category" property a REFERENCE
property and restrict it to myapp:Category.

you can add new categories (nodes of type myapp:Category) at any time.

cheers
stefan


>
> Thanks a lot,
> Cosmin
>
>
>
>
>
>
>
>
>
> ____________________________________________________________________________________
> Sponsored Link
>
> Mortgage rates near 39yr lows.
> $510k for $1,698/mo. Calculate new payment!
> www.LowerMyBills.com/lre
>