You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-dev@incubator.apache.org by ruchi goel <Ru...@Sun.COM> on 2007/02/08 05:08:14 UTC
creating custom node types inheriting from nt:folder using jcr mapping
Hi,
I want to use jcr mapping layer for creating custom node type "folder"
which should inherit from "nt:folder"
I have following custom_nodetype.xml
<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
xmlns:mix="http://www.jcp.org/jcr/mix/1.0">
<nodeType name="folder" isMixin="false"
hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>nt:folder</supertype>
</supertypes> </nodeType>
</nodeTypes>
I have following jcrmapping descriptor
<class-descriptor className="com.sun.portal.cms.model.HeirarchyContent"
jcrNodeType="nt:hierarchyNode" discriminator="false" >
<!-- Field-descriptor is used to map simple attributes to jcr property -->
<field-descriptor fieldName="path" path="true" />
<field-descriptor fieldName="creationDate" jcrName="jcr:created" />
/>
</class-descriptor>
<class-descriptor className="com.sun.portal.cms.model.Folder"
jcrNodeType="folder"
extend="com.sun.portal.cms.model.HeirarchyContent" discriminator="false" >
<!-- Field-descriptor is used to map simple attributes to jcr property -->
<field-descriptor fieldName="path" path="true" />
/>
<collection-descriptor fieldName="children" proxy="false"
jcrNodeType="nt:hierarchyNode"
elementClassName="com.sun.portal.cms.model.HeirarchyContent"
collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl"
/>
</class-descriptor>
The problem is I am able to retrieve the items which are properties but
I do not see any child node definitions in folder. Ideally since folder
is inheriting from nt:folder , it should get a childnode definition of
type nt:heirrarchynodeType
Is there anything I am missing ?
Checked out PersistenceAutoTest.java but it uses all custom nodetypes
which are inherited from nt:base and so , it has childnodedefintions in
custom node type definition.
Help appreciated.
Thanks,
Ruchi
Re: creating custom node types inheriting from nt:folder using jcr
mapping
Posted by ruchi goel <Ru...@Sun.COM>.
Thanks. Please find attached model classes . I do not have a clearly
isolated unit test case, since I have created a netbeans project where I
am using this.
But these are the two functionalities I am trying to achieve :
public void testSaveFolder(FolderModelService folderService){
//Test Save
//insert an Ad in repository
Folder folder = new Folder();
folder.setPath("/cms/folder2");
Collection content = new ArrayList();
content.add(new Folder("subfolder2"));
folder.setChildren(content);
folderService.saveFolder(folder);
}
public void testReadFolder(FolderModelService folderService){
Folder folder = (Folder)folderService.getFolder("/cms/folder2");
System.out.print("folder Info : " + folder.getCreationDate());
}
Thanks,
Ruchi
Christophe Lombart wrote:
> Hi Ruchi,
> e
> It seems to be ok. Send me your unit tests and you model classes.
> It is a good exemple to add and I will have time to help you this
> afternoon.
>
>
> br,
> Christophe
>
>
>
>
> On 2/8/07, ruchi goel <Ru...@sun.com> wrote:
>>
>> Hi,
>> I want to use jcr mapping layer for creating custom node type "folder"
>> which should inherit from "nt:folder"
>>
>> I have following custom_nodetype.xml
>> <nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
>> xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
>> xmlns:mix="http://www.jcp.org/jcr/mix/1.0">
>> <nodeType name="folder" isMixin="false"
>> hasOrderableChildNodes="false" primaryItemName="">
>> <supertypes>
>> <supertype>nt:folder</supertype>
>> </supertypes> </nodeType>
>>
>> </nodeTypes>
>>
>>
>> I have following jcrmapping descriptor
>>
>> <class-descriptor className="com.sun.portal.cms.model.HeirarchyContent"
>> jcrNodeType="nt:hierarchyNode" discriminator="false" >
>> <!-- Field-descriptor is used to map simple attributes to jcr
>> property -->
>> <field-descriptor fieldName="path" path="true" />
>> <field-descriptor fieldName="creationDate" jcrName="jcr:created" />
>> />
>> </class-descriptor>
>>
>> <class-descriptor className="com.sun.portal.cms.model.Folder"
>> jcrNodeType="folder"
>> extend="com.sun.portal.cms.model.HeirarchyContent"
>> discriminator="false"
>> >
>> <!-- Field-descriptor is used to map simple attributes to jcr
>> property -->
>> <field-descriptor fieldName="path" path="true" />
>> />
>> <collection-descriptor fieldName="children" proxy="false"
>> jcrNodeType="nt:hierarchyNode"
>>
>> elementClassName="com.sun.portal.cms.model.HeirarchyContent"
>>
>> collectionConverter="
>> org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl
>>
>> "
>> />
>> </class-descriptor>
>>
>>
>>
>> The problem is I am able to retrieve the items which are properties but
>> I do not see any child node definitions in folder. Ideally since folder
>> is inheriting from nt:folder , it should get a childnode definition of
>> type nt:heirrarchynodeType
>>
>> Is there anything I am missing ?
>> Checked out PersistenceAutoTest.java but it uses all custom nodetypes
>> which are inherited from nt:base and so , it has childnodedefintions in
>> custom node type definition.
>>
>> Help appreciated.
>> Thanks,
>> Ruchi
>>
>
Re: creating custom node types inheriting from nt:folder using jcr mapping
Posted by Christophe Lombart <ch...@gmail.com>.
Hi Ruchi,
It seems to be ok. Send me your unit tests and you model classes.
It is a good exemple to add and I will have time to help you this afternoon.
br,
Christophe
On 2/8/07, ruchi goel <Ru...@sun.com> wrote:
>
> Hi,
> I want to use jcr mapping layer for creating custom node type "folder"
> which should inherit from "nt:folder"
>
> I have following custom_nodetype.xml
> <nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
> xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
> xmlns:mix="http://www.jcp.org/jcr/mix/1.0">
> <nodeType name="folder" isMixin="false"
> hasOrderableChildNodes="false" primaryItemName="">
> <supertypes>
> <supertype>nt:folder</supertype>
> </supertypes> </nodeType>
>
> </nodeTypes>
>
>
> I have following jcrmapping descriptor
>
> <class-descriptor className="com.sun.portal.cms.model.HeirarchyContent"
> jcrNodeType="nt:hierarchyNode" discriminator="false" >
> <!-- Field-descriptor is used to map simple attributes to jcr property -->
> <field-descriptor fieldName="path" path="true" />
> <field-descriptor fieldName="creationDate" jcrName="jcr:created" />
> />
> </class-descriptor>
>
> <class-descriptor className="com.sun.portal.cms.model.Folder"
> jcrNodeType="folder"
> extend="com.sun.portal.cms.model.HeirarchyContent" discriminator="false"
> >
> <!-- Field-descriptor is used to map simple attributes to jcr property -->
> <field-descriptor fieldName="path" path="true" />
> />
> <collection-descriptor fieldName="children" proxy="false"
> jcrNodeType="nt:hierarchyNode"
>
> elementClassName="com.sun.portal.cms.model.HeirarchyContent"
>
> collectionConverter="
> org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl
> "
> />
> </class-descriptor>
>
>
>
> The problem is I am able to retrieve the items which are properties but
> I do not see any child node definitions in folder. Ideally since folder
> is inheriting from nt:folder , it should get a childnode definition of
> type nt:heirrarchynodeType
>
> Is there anything I am missing ?
> Checked out PersistenceAutoTest.java but it uses all custom nodetypes
> which are inherited from nt:base and so , it has childnodedefintions in
> custom node type definition.
>
> Help appreciated.
> Thanks,
> Ruchi
>