3

So I have 2 models. I have a "medicalBillModel" that I would like to inherit from "clientDocument". For some reason when I do this I get errors basically saying that the namespace has already being defined. When I have a model that inherits from another in alfresco do they need to have distinct namespaces or can they share the same namespace?

I also tried to import the namespace and remove the namespace declaration but that causes this error:

Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 06210000 Cannot define class ag:medicalBill as namespace http://www.company.com/model/content/1.0 is not defined by model ag:medicalBill

I am currently in the process of googling but not finding an example of one custom model that inherits from another.

clientDocumentModel.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- Definition of new Model -->

<model name="ag:clientDocument" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!-- Optional meta-data about the model -->  

   <description>General Client Document</description>
   <author>James Pearson</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.company.com/model/content/1.0" prefix="ag"/>
   </namespaces>

   <types>

      <type name="ag:clientDocument">
         <title>General Client Document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="ag:clientName">
               <title>Client</title>
                <type>d:text</type>
            </property>
         </properties>
      </type>

    </types>

</model>

medicalBillModel.xml

<?xml version="1.0" encoding="UTF-8"?>

<model name="ag:medicalBill" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Medical Bill</description>
   <author>James Pearson</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
      <import uri="http://www.company.com/model/content/1.0" prefix="ag"/>
   </imports>


   <types>

      <!-- Definition of new Content Type: Standard Operating Procedure -->
      <type name="ag:medicalBill">
         <title>Medical Bill</title>
         <parent>ag:clientDocument</parent>
         <properties>

            <property name="ag:patientNameFirst">
               <title>Patient First Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientNameLast">
               <title>Patient Last Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientMiddleInitial">
               <title>Patient Middle Initial</title>
                    <type>d:text</type>
            </property>

            <property name="ag:totalBillCharges">
                    <title>Total Bill Charges</title>
               <type>d:double</type>
            </property>

                <property name="ag:dateAdmitted">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

                <property name="ag:dateDischarged">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

            <property name="ag:facility">
                    <title>Facility Name</title>
               <type>d:text</type>
            </property>

         </properties>
      </type>

    </types>

    <aspects>

   </aspects>

</model>
startoftext
  • 3,846
  • 7
  • 40
  • 49

1 Answers1

4

Hi Each content model can have one or multiple unique namespaces, take a look at the Wiki

I know it doesn't state clearly that it needs to be unique. But it is.

What I don't understand why do you want to use the same namespace in different xml's?

Just use multiple types in one content model aka the following:

<model name="ag:clientDocument" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!-- Optional meta-data about the model -->  

   <description>General Client Document</description>
   <author>James Pearson</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.company.com/model/content/1.0" prefix="ag"/>
   </namespaces>

   <types>

      <type name="ag:clientDocument">
         <title>General Client Document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="ag:clientName">
               <title>Client</title>
                <type>d:text</type>
            </property>
         </properties>
      </type>

<!-- Definition of new Content Type: Standard Operating Procedure -->
      <type name="ag:medicalBill">
         <title>Medical Bill</title>
         <parent>ag:clientDocument</parent>
         <properties>

            <property name="ag:patientNameFirst">
               <title>Patient First Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientNameLast">
               <title>Patient Last Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientMiddleInitial">
               <title>Patient Middle Initial</title>
                    <type>d:text</type>
            </property>

            <property name="ag:totalBillCharges">
                    <title>Total Bill Charges</title>
               <type>d:double</type>
            </property>

                <property name="ag:dateAdmitted">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

                <property name="ag:dateDischarged">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

            <property name="ag:facility">
                    <title>Facility Name</title>
               <type>d:text</type>
            </property>

         </properties>
      </type>

    </types>

</model>

Normally i have a lot of types in one content model. So you don't need to worry.

If you still want to seperate them, use different namespaces and import one and another. BTW why do you want to import ClientModel in the MedicalBill? I don't see any usage of that?

Tahir Malik
  • 6,623
  • 15
  • 22
  • It was just a small proof of concept. You know start small and work up. I think I was under the assumption based on the example namespace uri that it was going to be across many models or at least related models. Thanks for your help. – startoftext Jul 22 '11 at 14:12
  • No problem, with Content Modeling you just needs some practice. The more you do it, the better you'll get at it ;). Keep it up! – Tahir Malik Jul 22 '11 at 20:42
  • So is it fine to have many types in one model as long as they are related. Or is it best practice to only do this when one inherits from the other? – startoftext Jul 26 '11 at 16:26
  • There is no exact best practice in modeling. See it like Object Oriented Programming. You have 1 class and in that class you define several methods with empowers that class. So in Modeling you can do the same. Make one client model in which you put the all the types related to the client. So a medical bill is also a client related type and can be placed within. Then you could define a new company model, etc. If you have shared data between model, you could inherit them, or use mandatory aspects. – Tahir Malik Jul 27 '11 at 07:52