cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping of Alfresco's relations in JCR.

anweber
Champ in-the-making
Champ in-the-making
Hi,

   I have defined a custom type with a relation :


      <type name="custom:ep_logical_doc">
         <title>EP's logical document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="custom:UID"> <!– uniq ID –>
               <type>d:text</type>
            </property>
            <property name="custom:legisPeriod"> <!– legislative period –>
               <type>d:text</type> <!– A5, A6, …. –>
            </property>
         </properties>
         <associations>
            <child-association name="custom:concreteDocs">
          <source>
         <mandatory>false</mandatory>
         <many>false</many>
      </source>
               <target>
                  <class>custom:ep_doc</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
       </child-association>           
         </associations>
   
    </type>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

   I try to set the association through the usage of the JCR API.
   I thought first that the relation was mapped as a multivalued JCR property.  It seems that it is not the case.  Then, how is it possible to set relations between nodes with JCR & Alfresco?

         Many thanks for your help,

                  Andr
5 REPLIES 5

davidc
Star Contributor
Star Contributor
We expose Alfresco multi-valued properties as JCR multi-valued properties.  Unfortunately, there isn't really an equivalent concept in JCR for exposing Alfresco associations (except child).

If you must have associations in your content model, then you can drop into the Alfresco native API for managing them in amongst your JCR code.  An example is given in:

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

anweber
Champ in-the-making
Champ in-the-making
OK thanks,


   I wonder if it is worth to use JCR with Alfresco : we have to mix JCR and native API calls, and the data model is not the same (for example, Alfresco create only one node to store a file, while JCR examples create two (one for a "nt:file" object and one for a "nt:content" object).  Then the code we write with JCR & Alfresco won't not usable as it if we change our JCR CMS.


              Andre

davidc
Star Contributor
Star Contributor
You only have to mix JCR and Alfresco calls if you wish to go outside of the capabilities of the JCR API.

JCR is not restricted to any particular data model.  A data model described in JCR is transportable across JCR implementations.  So, you can decide to code against the nt: model, or Alfresco's or your own. 

It's possible to define an equivalent nt: model in Alfresco.

anweber
Champ in-the-making
Champ in-the-making
Hi,

   Thanks for your answer.

   Yes, I can use any data model with JCR & Alfresco but if I do not follow the data model used by Alfresco (folder & content definition), I will lost the usage of tools furnished by Alfresco (webClient, webDav, CIFS, …).


       Regards,

              Andre

davidc
Star Contributor
Star Contributor
That's correct.

The JCR spec doesn't mandate support of a particular model, although, as you've mentioned there are some optional nt: types.  So, unless, all JCR implementations support those optional nt: types, either by mapping them to native concepts in their repository, or just supporting them inherently, you cannot achieve write once, run many. 

JSR-283 intends to provide standardised api's for data model definition.