cancel
Showing results for 
Search instead for 
Did you mean: 

import a custom model inside another custom model to inherit

dmralfing
Champ in-the-making
Champ in-the-making
I´ve created in Alfreso two new custom models, father and child. I have to put in the XML child file that imports the model father, but I don´t know how I have to do it. For example if I inherit from cm:content, it´s very easy and typical, I put <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>. But if I inherit from a custom type, what should I have to put?. In the father namespace i put <namespace uri="aaa.bbb.father" prefix="fat">, so I though that I have to put in the child file <import uri="aaa.bbb.father" prefix="fat">, so I guess I´m wrong because it doesn´t works…
what I have to do??
7 REPLIES 7

lotharmärkle
Champ in-the-making
Champ in-the-making
Hi,

Your description looks fine, so for further insight
maybe you could provide some error message or exception trace from the logs?

Also make sure to first load the parent model. Sometimes you have to force it using a spring depends-on.

Lothar

dmralfing
Champ in-the-making
Champ in-the-making
the parent model loads OK when I reboot, so I´m sure it´s right configurated
it says:
Caused by: org.alfresco.service.namespace.NamespaceException: URI aaa.bbb.father cannot be imported as it is not defined (with prefix fat
   at org.alfresco.repo.dictionary.CompiledModel.createLocalPrefixResolver(CompiledModel.java:203)
   at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:128)
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:88)
   … 48 more
I´m sure I´m referencing bad the father. I repeat: the father namespace is <namespace uri="aaa.bbb.father" prefix="fat">, and I import in the child writing exactly the same ULR: <import uri="aaa.bbb.father" prefix="fat">. I don´t know if is necesary to include a reference tothe father in the child-context.XML, but if I do it, it doesn´t works too.
  I only want to configurate an inheritance, it should be easy!!
Thanks

lotharmärkle
Champ in-the-making
Champ in-the-making
It looks like the parent model is not loaded before the child model and is therefore unknown.
Try to make the child model loading bean depends-on the parent model loading bean.

my working example:
<model name="ecm4uChild:ecm4uChildModel" xmlns="http://www.alfresco.org/model/dictionary/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd">
   <version>1.1</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://ecm4u.de/model/parent/1.0" prefix="ecm4uParent"/>
   </imports>
   <namespaces>
      <namespace uri="http://ecm4u.de/model/child/1.1" prefix="ecm4uChild"/>
   </namespaces>
   <types>
      <type name="ecm4uChild:InfoDoc">
         <title>InfoDoc</title>
         <description/>
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>ecm4uParent:InfoAspect</aspect>
         </mandatory-aspects>
      </type>
   </types>


child dict-bootstrap bean depends-on parent bootstrap bean

<bean id="ecm4u.child" parent="dictionaryModelBootstrap" depends-on="ecm4u.parentBootstrap">
      <property name="models">
         <list>
            <value>ecm4uChildModel.xml</value>
         </list>
      </property>
   </bean>

dmralfing
Champ in-the-making
Champ in-the-making
I´ve resolved my problem, I did something bad in the context files, it´s so easy.
Thanks!

gomez0711
Champ in-the-making
Champ in-the-making
Hi, dmralfing

I have the same problem you had, could you tell me how you solved it?

Ando very desperate with this, help me, please.

You can put your code? thanks

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

Below is my details model which is imported by main model.

Details Model


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

   
<model    name="gtindet:gtindetailsmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0/modelSchema.xsd">


   <!– 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"/>
     <!– Import Alfresco Data List Model Definitions –>
      <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>

   <namespaces>
      <namespace uri="http://www.tescoplc.com/model/ucs/gtin/details/1.0" prefix="gtindet"/>
   </namespaces>

     
   <!–      U C S   T Y P E   D E F I N I T I O N S      –>
   <types>  
      <!– Definition of new Content Type: Details Object Type  –>
      <type name="gtindet:object">
         <title> Details Object</title>
         <parent>cm:content</parent>
         <properties>
         <property name="gtindet:ID">
            <description> Details ID</description>
               <type>d:int</type>
            <mandatory>true</mandatory>
            </property>
         <property name="gtindet:providerId">
            <description> Provider ID</description>
               <type>d:int</type>
            <mandatory>true</mandatory>
            </property>
         <property name="gtindet:color">
            <description> Details Color</description>
               <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="gtindet:weight">
            <description> Details Weight</description>
               <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         </properties>             
      </type>   
   </types>
</model>

Main model.


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

   
<model    name="gtinmain:gtinmainmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0/modelSchema.xsd">

   <!– 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"/>
     <!– Import Alfresco Data List Model Definitions –>
      <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
     <!– Import GTIN Details Model –>
      <import uri="http://www.tescoplc.com/model/ucs/gtin/details/1.0" prefix="gtindet"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>

   <namespaces>
      <namespace uri="http://www.tescoplc.com/model/ucs/gtin/main/1.0" prefix="gtinmain"/>
   </namespaces>

     
   <!–      U C S      D E F I N I T I O N S      –>
   <types>  
      <!– Definition of new Content Type:  Main Object Type  –>
      <type name="gtinmain:object">
         <title> Main Object</title>
         <parent>cm:content</parent>
         <properties>
         <property name="gtinmain:ID">
            <description> Main ID</description>
               <type>d:int</type>
            <mandatory>true</mandatory>
            </property>
         <property name="gtinmain:Title">
            <description> Main Title</description>
               <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         </properties>   
        <associations>
            <child-association name="gtinmain:association">
            <source>
                  <mandatory>true</mandatory>
                  <many>true</many>
            </source>
            <target>
                  <class>gtindet:object</class>
                  <mandatory>true</mandatory>
                  <many>true</many>
            </target>
            </child-association>
                 </associations>
      </type>   
   </types>
</model>


Details object is associated as child with parent type.Its working fine. You just need to define models in context file separately.

Regards.

ashtaka
Champ in-the-making
Champ in-the-making
i want to inherit a content model into new content model so please tell me where i need to make changes. ?
i have created a new content model in which i have defined a new type  i have imported parent in to new content model . i have added entry of new content model in context file.
but no luck.
econtract.xml is my child-content-model
error
Could not import bootstrap model alfresco/extension/model/econtract.xml
Failed to compile model dm:econtractmodel