Association avec un autre modèle de document

cancel
Showing results for 
Search instead for 
Did you mean: 
jgautier
Member II

Association avec un autre modèle de document

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
bertrandf
Active Member

Re: Association avec un autre modèle de document

Vous pourriez afficher le contenu du fichier example-model-context.xml également svp ?
jgautier
Member II

Re: Association avec un autre modèle de document

Bonjour,

voici le contenu de exemple-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>
    <!– Registration of new models –>   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/newModel1Model.xml</value>
                <value>alfresco/extension/newModel2Model.xml</value>
            </list>
        </property>
    </bean>
</beans>
jayjayecl
Active Member II

Re: Association avec un autre modèle de document

ce fichier "context" importe un fichier myModel1.xml, hors vous avez dit (dans le premier message), que le fichier du model 1 s'appelle "newModel1Model.xml".
jgautier
Member II

Re: Association avec un autre modèle de document

Oui au temps pour moi, j'ai repris un ancien fichier.

J'ai corrigé !
jgautier
Member II

Re: Association avec un autre modèle de document

Une petite idée ?

J'avais commencé par faire l'inverse à savoir une association de myModel2 dans myModel1 et cela fonctionnait très bien.
J'ai voulu changer et cela ne fonctionne plus…
jayjayecl
Active Member II

Re: Association avec un autre modèle de document

En relisant l'ensemble du sujet, je ne comprends pas votre dernier message …
jgautier
Member II

Re: Association avec un autre modèle de document

J'ai tout d'abord implémenté le modèle myModel1 dans lequel j'avais une association vers le modèle myModel2.
Cela fonctionnait très bien.

Je me suis ensuite aperçu qu'il fallait que ce soit l'inverse à savoir une association vers le modèle myModel1 dans le modèle myModel2.

En espérant que ce soit plus clair.
jayjayecl
Active Member II

Re: Association avec un autre modèle de document

Je comprends bien, mais sans traces de logs, ou sans information supplémentaire, on a du mal à vous aider.
On vous a précédemment aidé en montrant le problème des noms des fichiers, vous avez affirmé avoir corrigé le point.
Mais quelles sont les nouvelles traces d'erreur ?
jgautier
Member II

Re: Association avec un autre modèle de document

Les noms de fichier mis initialement sont une erreur de ma part.
Le log que je vous montre plus haut est celui que j'ai actuellement (les mauvais noms des fichiers n'y étant pour rien) !

Ce que j'ai du mal à comprendre c'est pourquoi cela a fonctionné dans un sens (modèle myModel1 avec association vers myModel2) et non dans l'autre alors que j'ai fait exactement les mêmes manipulations.
Est-ce possible qu'il y ait eu une sorte de "cycle" entre les modèles et associations et que cela pose problème ?

J'ai pourtant simplifier au maximum le modèle myModel1.