cancel
Showing results for 
Search instead for 
Did you mean: 

Found duplicate property definition...

kbryd
Champ in-the-making
Champ in-the-making
Hi

I have just started looking into Alfresco and here is a problem I have. I have created these three types:

* fa:base_document - this is a base type which contains some common attributes:

   
 
       <type name="fa:base_document">
         <title>Base Document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="fa:documentType">
               <type>d:text</type>
            </property>
            <property name="fa:productRef">
               <type>d:text</type>
            </property>
            <property name="fa:description">
               <type>d:text</type>
            </property>
         </properties>
       </type>

* fa:document - this is my document type, this adds only approvedOn attribute

     <type name="fa:document">
         <title>Document</title>
         <parent>fa:base_document</parent>
         <properties>
            <property name="fa:approvedOn">
               <type>d:date</type>
            </property>
         </properties>
      </type>

* fa:folder - this is my new folder type, adds two attributes (approvedOn can be set when all documents in this folder are also approved)


    <type name="fa:folder">
         <title>Folder</title>
         <parent>cm:folder</parent>
         <properties>
            <property name="fa:productRef">
               <type>d:text</type>
            </property>
            <property name="fa:approvedOn">
               <type>d:date</type>
            </property>
         </properties>
      </type>

As you can see there is a faSmiley TongueroductRef attribute both in fa:document and in fa:folder - this is a field which is common for these two types.

Now, when I validate this model I get:

kbryd@mob:~/tmp/alfresco/tomcat$ ./modelValiddate.sh
Testing dictionary model definitions…
alfresco/model/dictionaryModel.xml
alfresco/model/systemModel.xml
org/alfresco/repo/security/authentication/userModel.xml
alfresco/model/contentModel.xml
alfresco/model/wcmModel.xml
alfresco/model/applicationModel.xml
alfresco/model/bpmModel.xml
alfresco/extension/testModel.xml
Found an invalid model…
Could not import bootstrap model alfresco/extension/testModel.xml
Failed to compile model fa:testmodel
Found duplicate property definition faSmiley TongueroductRef within class fa:folder and class fa:base_document


I have read somewhere that the name of attribute must be globally unique, but I don't understand why and first of all how one should proceed in such situations like mine (I don't like the idea to change name of a property each time)? Should I create an aspect instead of that attribute?

Thanks
Karol
1 REPLY 1

jbarmash
Champ in-the-making
Champ in-the-making
The real issue here is the namespace applied in your model to make things unique, not the types per se.  If I define

   <namespaces>
      <namespace uri="custom.model" prefix="custom"/>
   </namespaces>

     <types>
         <type name="customSmiley Tongueressrelease">

Then I can only have one customSmiley Tongueressrelease in that model.  If you need to utilize the same attribute name across types, you should either leverage:
•   Subtyping / inheritance
•   aspects
If applicable, or in any case – you can always create a separate model with its own namespace to avoid the clash.