You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Luis Gervaso <lu...@gmail.com> on 2008/06/10 13:41:12 UTC

cut /copy / paste

 Hello all,

This is my first post to the list

I'm developing an application using Jackrabbit 1.4.4

I need to perform cut / copy / paste (after and inside) actions over the
resources tree and *maintain the order*

For example:

/root
  /parent-node1
     /child-node11
     /child-node12
     /child-node13
  /parent-node2
    /child-node21
    /child-node22

if i cut child-node22 and paste-after /child-node12 i want to have

/root
  /parent-node1
     /child-node11
     /child-node12
     /child-node22
     /child-node13
  /parent-node2
    /child-node21

the important thing here is maintaining the order of the elements (each nod=
e
have an index inside its collection)

My question is =BFis jackrabbit maintaining any kind of order in childNodes
out of the box?

Any help will be appreciated, actually i don't know if this is the correct
way

Regards

Luis

-- 
-------------------------------------------
Luis Alberto Gervaso Martin
Java EE Architect & Instructor
C/ Cuenca 4A, 2ºB
Getafe (Madrid)
SPAIN
mobile: (+34) 627983344
luis.gervaso@gmail.com

Re: cut /copy / paste

Posted by Stefan Guggisberg <st...@day.com>.
On Tue, Jun 10, 2008 at 7:20 PM, Alexander Klimetschek <ak...@day.com> wrote:
> On Tue, Jun 10, 2008 at 6:15 PM, Luis Gervaso <lu...@gmail.com> wrote:
>> Why is not implemented orderAfter() instead of orderBefore()?

IMO there's no reason why orderAfter() would be 'better' than orderBefore().
it all depends on the specific use case and implementing the orderAfter
use case is trivial.

>
> Decision by the JCR standards committee... not everything is perfect
> in the API, but it's not that difficult to write your own insertAt()
> method by combining addNode() and orderBefore(). Note that you need to
> use a node type that allows for child ordering.
>
>> Since we iterate a collection we can "remember" the previous item in the
>> iteration
>> and can "insert" before or after the actual item in the loop. But probably
>> I'm really missed with
>> this thinking.
>
> The orderBefore() is simply based on (string) paths, which should make
> it easier if your content model is straightforward (eg.
> orderBefore("print", "quit") to move the print action before the
> quit).
>
>> I really don't know if generate a menu from the content is the correct way
>> using JCR
>
> There is no "correct" way. Your are free to use the API according to
> your needs! Still, there are best practices and recommondations for
> many common things. Have a look at
> http://wiki.apache.org/jackrabbit/DavidsModel for tips on content
> modeling.
>
>> or it must be only on the frontend code. maybe hardcoded, configuration file
>> ...
>>
>> If i generate a menu from JCR we need a hard requirement to perform ordering
>> operations
>> on the nodes.
>>
>> I have not found enough documentation, tutorials to create a simple
>> application with menus,
>> static content and dynamic content using JCR instead of the traditional
>> approach using database
>>
>> Can anyone redirect me to a good quickstart / real application on JCR?
>
> There are many tutorials and examples on Google, for example:
>
> http://wiki.alfresco.com/wiki/Introducing_the_Alfresco_Java_Content_Repository_API

please keep in mind that this link refers to the alfresco specific
implementation of the
JCR api and alfresco specific api's. unless you're actually using
alfresco, i suggest
you have a look at the following, IMO excellent introduction:
http://www-128.ibm.com/developerworks/java/library/j-jcr/

cheers
stefan

>
> And there is a collection of jcr links on the Jackrabbit wiki:
>
> http://wiki.apache.org/jackrabbit/JcrLinks
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>

Re: cut /copy / paste

Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, Jun 10, 2008 at 6:15 PM, Luis Gervaso <lu...@gmail.com> wrote:
> Why is not implemented orderAfter() instead of orderBefore()?

Decision by the JCR standards committee... not everything is perfect
in the API, but it's not that difficult to write your own insertAt()
method by combining addNode() and orderBefore(). Note that you need to
use a node type that allows for child ordering.

> Since we iterate a collection we can "remember" the previous item in the
> iteration
> and can "insert" before or after the actual item in the loop. But probably
> I'm really missed with
> this thinking.

The orderBefore() is simply based on (string) paths, which should make
it easier if your content model is straightforward (eg.
orderBefore("print", "quit") to move the print action before the
quit).

> I really don't know if generate a menu from the content is the correct way
> using JCR

There is no "correct" way. Your are free to use the API according to
your needs! Still, there are best practices and recommondations for
many common things. Have a look at
http://wiki.apache.org/jackrabbit/DavidsModel for tips on content
modeling.

> or it must be only on the frontend code. maybe hardcoded, configuration file
> ...
>
> If i generate a menu from JCR we need a hard requirement to perform ordering
> operations
> on the nodes.
>
> I have not found enough documentation, tutorials to create a simple
> application with menus,
> static content and dynamic content using JCR instead of the traditional
> approach using database
>
> Can anyone redirect me to a good quickstart / real application on JCR?

There are many tutorials and examples on Google, for example:

http://wiki.alfresco.com/wiki/Introducing_the_Alfresco_Java_Content_Repository_API

And there is a collection of jcr links on the Jackrabbit wiki:

http://wiki.apache.org/jackrabbit/JcrLinks

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: cut /copy / paste

Posted by Luis Gervaso <lu...@gmail.com>.
Thanks Jukka,

Why is not implemented orderAfter() instead of orderBefore()?

Since we iterate a collection we can "remember" the previous item in the
iteration
and can "insert" before or after the actual item in the loop. But probably
I'm really missed with
this thinking.

I really don't know if generate a menu from the content is the correct way
using JCR
or it must be only on the frontend code. maybe hardcoded, configuration file
...

If i generate a menu from JCR we need a hard requirement to perform ordering
operations
on the nodes.

I have not found enough documentation, tutorials to create a simple
application with menus,
static content and dynamic content using JCR instead of the traditional
approach using database

Can anyone redirect me to a good quickstart / real application on JCR?

Thanks in advance

Luis

On Tue, Jun 10, 2008 at 2:57 PM, Jukka Zitting <ju...@gmail.com>
wrote:

> Hi,
>
> On Tue, Jun 10, 2008 at 2:41 PM, Luis Gervaso <lu...@gmail.com>
> wrote:
> > My question is =BFis jackrabbit maintaining any kind of order in
> childNodes
> > out of the box?
>
> Yes. See the Node.orderBefore() method [1] for details on how to use
> this feature.
>
> [1]
> http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Node.html#orderBefore(java.lang.String,%20java.lang.String)<http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Node.html#orderBefore%28java.lang.String,%20java.lang.String%29>
>
> BR,
>
> Jukka Zitting
>



-- 
-------------------------------------------
Luis Alberto Gervaso Martin
Java EE Architect & Instructor
C/ Cuenca 4A, 2ºB
Getafe (Madrid)
SPAIN
mobile: (+34) 627983344
luis.gervaso@gmail.com

Re: cut /copy / paste

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

On Tue, Jun 10, 2008 at 2:41 PM, Luis Gervaso <lu...@gmail.com> wrote:
> My question is =BFis jackrabbit maintaining any kind of order in childNodes
> out of the box?

Yes. See the Node.orderBefore() method [1] for details on how to use
this feature.

[1] http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Node.html#orderBefore(java.lang.String,%20java.lang.String)

BR,

Jukka Zitting