cancel
Showing results for 
Search instead for 
Did you mean: 

Defining two name spaces in two files with associations

tico
Champ in-the-making
Champ in-the-making
Hello you all !

I have defined a new type in a name space, inheriting from folder in file1. An aspect in an other name space in file2.

File2 import name space definition from file1.

If I define an association in the aspect refering the type from file1, I get the following:

'Target class organisationSmiley Surprisedrganisation of association contactSmiley Surprisedrganisation is not found'

What is the way to refer a type from an other file ?

thanks and regards,

Eric.
3 REPLIES 3

andy
Champ on-the-rise
Champ on-the-rise
Hi

It looks like you have not got the correct prefix defined for the types to which you refer.

In one file you define types with a given prefix. You need to redefined and use his prefix in the next file when you refer to the other types. See the model files that ship with the repository for examples.

Cheers

Andy

tico
Champ in-the-making
Champ in-the-making
Hi Andy,

Thanks for your reply.

Unfortunately, I didnt find any sample in model files matching my request.

Here are my files:

yournewModel.xml:

<model name="your:yournewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Your example custom Model</description>
   <author>Me</author>
   <version>1.0</version>
   
   <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>
     
   <namespaces>
      <!– Define a Namespace for my new definitions –>
      <namespace uri="your.new.model" prefix="your"/>
   </namespaces>
   
   <!– Type and Aspect definitions go here –>
   <types>
      <!– type contact –>
      <type name="your:yourSpace">
         <title>your Space</title>
         <parent>cm:folder</parent>
      </type>
      
    </types>
</model>

mynewModel.xml

<model name="my:mynewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>My example custom Model</description>
   <author>Me</author>
   <version>1.0</version>
   
   <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>
     
   <namespaces>
      <!– Define a Namespace for my new definitions –>
      <namespace uri="my.new.model" prefix="my"/>
      <namespace uri="your.new.model" prefix="your"/>
   </namespaces>
   
   <!– Type and Aspect definitions go here –>
   <types>
      <!– type contact –>
      <type name="my:mySpace">
         <title>My Space</title>
         <parent>cm:folder</parent>
         <associations>
            <association name="my:yourSpace">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>your:yourSpace</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
      </type>
      
    </types>
</model>

custom-model-context.xml:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   
<bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
   <property name="models">
      <list>
         <value>alfresco/extension/yournewModel.xml</value>
         <value>alfresco/extension/mynewModel.xml</value>
      </list>
   </property>
</bean>

</beans>

When Alfresco is launched, I got the following exception in log file:
org.alfresco.service.namespace.NamespaceException: URI your.new.model has already been defined

If I remove the namespace declaration <namespace uri="your.new.model" prefix="your"/> from mynewModel.xml, I got the following from the log file:
org.alfresco.service.namespace.NamespaceException: Namespace prefix your is not mapped to a namespace URI

Thanks and regards,

Eric.

andy
Champ on-the-rise
Champ on-the-rise
Hi

In the second model definition you need to import the first model - the configuration you have says you are defining modesl for the two name spaces.

Andy