cancel
Showing results for 
Search instead for 
Did you mean: 

Association avec un autre modèle de document

jgautier
Champ in-the-making
Champ in-the-making
Bonjour,

j'ai crée deux nouveaux modèles de document : newModel1 et newmodel2.

J'ai les fichiers suivants :

newModel1Model.xml

<?xml version="1.0" encoding="UTF-8"?>
    <!–Definition of new Model –>
    <model name="myModel1:model" xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <!–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="myModel1.model" prefix="myModel1" />
    </namespaces>
   
   <types>
    <type name="myModel1:myModel1">
       <title>MyModel1</title>
        <parent>cm:content</parent>
      </type>
   </types>
    </model>

myModel2Model.xml

<?xml version="1.0" encoding="UTF-8"?>
    <!–Definition of new Model –>
    <model name="myModel2:model" xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <!–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 uri="myModel1.model" prefix="myModel1" />
    </imports>

    <!–Introduction of new namespaces defined by this model –>
    <namespaces>
       <namespace uri="myModel2.model" prefix="myModel2" />
    </namespaces>
   
    <types>
       <type name="myModel2:myModel2">
          <title>myModel2</title>
          <parent>cm:content</parent>
        <properties>
         <property name="myModel2:width">
            <title>Width</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="myModel2:length">
            <title>Length</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
        </properties>
        <associations>
            <association name="myModel2:myAssociation">
                    <title>myassociation</title>
                    <source>
                        <mandatory>false</mandatory>
                  <many>false</many>
                    </source>
                    <target>
                        <class>myModel1:myModel1</class>
                        <mandatory>false</mandatory>
                  <many>true</many>
                    </target>
            </association>
         </associations>
        </type>
    </types>
    </model>

web-client-config-custom.xml



   <config evaluator="node-type" condition="myModel2:myModel2">
          <property-sheet>    
         <show-association name="myModel2:myAssociation" />
          </property-sheet>     
      </config>



Je veux ainsi que lorsque je crée un document myModel2 je puisse lier un (ou plusieurs) documents de type myModel1.
Mais j'ai l'erreur suivante :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\example-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 03280001 Could not import bootstrap model alfresco/extension/myModel2.xml
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:519)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 03280001 Could not import bootstrap model alfresco/extension/myModel2.xml
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:158)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:105)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1529)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1468)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
   … 37 more
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 03280000 Failed to compile model myModel2:model
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:106)
   at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:128)
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:270)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:154)
   … 45 more
Caused by: org.alfresco.service.namespace.NamespaceException: URI myModel1.model cannot be imported as it is not defined (with prefix myModel1
   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

Quelqu'un aurait-il une idée d'où l'erreur peut provenir ?

Merci d'avance.
20 REPLIES 20

jgautier
Champ in-the-making
Champ in-the-making
J'ai finalement résolu le problème en définissant les deux types de documents dans le même fichier et je peux ainsi faire l'association.

Merci de votre aide.