AnsweredAssumed Answered

Adding Mandatory Child association to Custom Content Type

Question asked by asmita.hardikar on Feb 18, 2008
Latest reply on Sep 23, 2011 by ragnaroek-hh
Hello,
I have defined a custom content model as shown below.

<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model  –>
<model name="ps:ps" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!– Optional meta-data about the model –>
<description/>
<author/>
<version>1.0</version>
<!– Imports are required to allow references to definitions in other models –>
   <imports>
      <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>
<!– Introduction of new namespaces defined by this model –>
<namespaces>
            <namespace uri="http://www.test.com/model/content/1.0" prefix="ps"/>
</namespaces>
<types>
       <type name="ps:xs">
             <parent>cm:content</parent>
            <mandatory-aspects>
                               <aspect>cm:generalclassifiable</aspect>
                               <aspect>cm:versionable</aspect>
             </mandatory-aspects>
       </type>
       <type name="ps:bxs">
             <parent>ps:xs</parent>
       </type>
       <type name="ps:prof">
             <parent>cm:content</parent>
             <properties>
                         <property name="ps:Id">
                                   <type>d:text</type>
                                   <mandatory>true</mandatory>
                         </property>
             </properties>
            <mandatory-aspects>
                               <aspect>cm:generalclassifiable</aspect>
                               <aspect>cm:versionable</aspect>
             </mandatory-aspects>
       </type>
       <type name="ps:bprof">
             <parent>ps:prof</parent>
             <properties>
             <!– I want this to have a default value. "default" tag is not supported. It gives an exception. –>
                         <property name="ps:product">
                                   <type>d:text</type>
                                   <mandatory>true</mandatory>
                         </property>
             </properties>
             <!– I want this as a mandatory association. –>
             <associations>
                           <child-association name="ps:bxs_link">
                           <source>
                                   <mandatory>false</mandatory>
                                   <many>true</many>
                           </source>
                           <target>
                                   <class>ps:bxs</class>
                                   <mandatory>false</mandatory>
                                   <many>false</many>
                           </target>
                           </child-association>
             </associations>
        </type>
</types>
</model>

I am unable to achieve the following in this model:
1. Define a mandatory child association: I tried all combinations of "true-false" for source & target. When I specify "target" as mandatory, it given following error during execution

  Please correct the errors below then click OK. 
A system error happened during the operation: Unknown Exception in Transaction.
stack: ERROR [org.alfresco.repo.node.integrity.IntegrityChecker] Found 1 integrity violations:
The association target multiplicity has been violated:
   Source Node: workspace://SpacesStore/2571013d-ddee-11dc-a9c3-475304f6f2e8
   Association: Association[ class=ClassDef[name={http://www.test.com/model/content/1.0}bprof], name={http://www.test.com/model/content/1.0}bxs_link, target class={http://www.test.com/model/content/1.0}bxs, source role=null, target role=null]
   Required target Multiplicity: 1..1
   Actual target Multiplicity: 0
12:23:02,290 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: Unknown Exception in Transaction.

2. specify default value for property: when I add default tag.
Failed to parse model

Request your help at the earliest please !

Outcomes