AnsweredAssumed Answered

Association / Child-association

Question asked by felipe on Apr 28, 2006
Can anybody tell me if I'm right in the following lines:
I've got a simple sample model using associations and child associations

<type name="tm:Provider">
         <title>Provider</title>
         <parent>cm:cmobject</parent>
         <properties>
            <property name="tm:code">
               <type>d:int</type>
            </property>
         </properties>
         <associations>
            <child-association name="tm:special_user">
               <target>
                  <class>usr:user</class>
                  <mandatory>true</mandatory>
                  <many>false</many>
               </target>
            </child-association>   
            <association name="tm:users">
               <target>
                  <class>usr:user</class>
                  <mandatory>true</mandatory>
                  <many>true</many>
               </target>
            </association>        
         </associations>
      </type>

The model works fine, but I've many questions on JCR use:
//Java source code
Node provider = _root.addNode("tm:provider1","tm:Provider");
Node user = provider.addNode("tm:special","usr:user");
user.setProperty("usr:username","toto");
user.setProperty("usr:password","toto");
_session.save();

This code works too, but :

1) Am I mandatory to use only child-associations in order to run this code  (when I use an association for the "tm:special_user" it doesn't work and an exception is thrown) ???

2) If "tm:users" was a child-assoc too, how to reference this association exactly and the "tm:special_user" when adding a new user???

And another question:
3) How can I populate repository data with XML files (without jcr access or the web client)

Thanks,

Outcomes