cancel
Showing results for 
Search instead for 
Did you mean: 

Je viens de découvrir Travailler avec les modèles...

michaelh
Champ on-the-rise
Champ on-the-rise
Je viens de découvrir Travailler avec les modèles de données personnalisés, un excellent document (en Anglais) sous licence libre, par Jeff Potts.

Il est disponible ici : http://ecmarchitect.com/images/articles/alfresco-content/content-article.pdf

Je le conseille à ceux qui découvrent la définition de nouvelles propriétés (aux autres aussi d'ailleurs Smiley Wink )
30 REPLIES 30

noobfresco
Champ in-the-making
Champ in-the-making
Bon ben c est pas une réponse à ce post, c'est une autre question à la noix, mais comme çà le concerne je vais pas faire un nouveau sujet! Et pi comme çà on pourra pas dire que je lis pas le fofo avant de poser mes ptites questions ^^

J'ai donc suivi le didacticiel donné en début de post par Micheal: "Il est disponible ici : http://ecmarchitect.com/images/articles/alfresco-content/content-article.pdf"

Je vois bien les répercutions partout sauf quand je clique sur détail: je ne vois que les propriétés classique du document, et pas les propriétés "Published, Active?, Product, Version".

J'ai la version 2.1 Community, sous Tomcat 5.5.20. Alors dans mon fichier web-client-config-custom.xml, voici ce que j'ai donc ajouté:

   <!– add webable aspect properties to property sheet –>
   <config evaluator="aspect-name" condition="sc:webable">
   <property-sheet>
      <show-property name="sc:published" display-label-id="published" />
      <show-property name="sc:isActive" display-label-id="isActive" read-only="true" />
      <show-association name="sc:relatedDocuments" />
   </property-sheet>
   </config>
   <config evaluator="aspect-name" condition="sc:productRelated">
   <property-sheet>
      <show-property name="sc:product" display-label-id="product" />
      <show-property name="sc:version" display-label-id="version" />
      <show-association name="sc:relatedDocuments" />
   </property-sheet>
   </config>
  
  
   <!– add someco types to add content list –>
   <config evaluator="string-compare" condition="Content Wizards">
   <content-types>
      <type name="sc:doc" />
      <type name="sc:whitepaper" />
   </content-types>
   </config>
  
  
   <config evaluator="string-compare" condition="Action Wizards">
   <!– The list of aspects to show in the add/remove features action –>
   <!– and the has-aspect condition –>
   <aspects>
      <aspect name="sc:webable"/>
      <aspect name="sc:productRelated"/>
   </aspects>
   
   <!– The list of types shown in the issubtype condition –>
   <subtypes>
      <type name="sc:doc" />
      <type name="sc:whitepaper" />
   </subtypes>

   <!– The list of content and/or folder types shown in the specialise-type action –>
   <specialise-types>
      <type name="sc:doc" />
      <type name="sc:whitepaper" />
   </specialise-types>
   </config>
  

   <config evaluator="string-compare" condition="Advanced Search">
   <advanced-search>
      <content-types>
         <type name="sc:doc" />
         <type name="sc:whitepaper" />
      </content-types>
      <custom-properties>
         <meta-data aspect="sc:webable" property="sc:published" display-label-id="published" />
         <meta-data aspect="sc:webable" property="sc:isActive" display-label-id="isActive" />
         <meta-data aspect="sc:productRelated" property="sc:product" display-label-id="product" />
         <meta-data aspect="sc:productRelated" property="sc:version" display-label-id="version" />
      </custom-properties>
   </advanced-search>
   </config>
Sinon dans le someco-model-context.xml, j'ai:
<?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/scModel.xml</value>
         </list>
      </property>
   </bean>
</beans>
Et enfin dans mon scModel.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="sc:somecomodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <!– Optional metadata about the model –>
   <description>Someco Model</description>
   <author>Optaros</author>
   <version>1.0</version>
   
   <!– 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="http://www.someco.com/model/content/1.0" prefix="sc" />
   </namespaces>
   
   <types>
      <!– Enterprise-wide generic document type –>
      <type name="sc:doc">
         <title>Someco Document</title>
         <parent>cm:content</parent>
         <associations>
            <association name="sc:relatedDocuments">
               <title>Related Documents</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>sc:doc</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
         <mandatory-aspects>
            <aspect>cm:generalclassifiable</aspect>
         </mandatory-aspects>
      </type>

      <type name="sc:whitepaper">
         <title>Someco Whitepaper</title>
         <parent>sc:doc</parent>
      </type>
   </types>
   
   <aspects>
      <aspect name="sc:webable">
         <title>Someco Webable</title>
         <properties>
            <property name="sc:published">
               <type>d:date</type>
            </property>
            <property name="sc:isActive">
               <type>d:boolean</type>
               <default>false</default>
            </property>
         </properties>
      </aspect>

      <aspect name="sc:productRelated">
         <title>Someco Product Metadata</title>
         <properties>
            <property name="sc:product">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="sc:version">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
      </aspect>
   </aspects>
</model>
Et puis aller, pour la forme, et pour grossir un peu + inutilement mon post, le webclient.properties Smiley Very Happy :
#sc:webable
published=Published/Publié
isActive=Active?

#sc:productRelated
product=Product/Produit
version=Version
Alors alors, une ptite idée ? serait-ce simplement un problème de compatibilité avec la 2.1 ? Ou une virgule que j'aurai oublié ? Smiley Wink

egr
Champ in-the-making
Champ in-the-making
Bonjour,

A première vue dans votre modèle de contenu, vous avez un type "sc:doc" et "sc:whitepaper" mais ils n'ont aucune propriété…
Pour qu'une méta-données personnalisée s'affiche sur les détails d'un document, il faudrait que ces types aient une ou plusieurs propriétés ou que les aspects soient en "mandatory", exemple :

L'aspect "sc:webable" est obligatoire, on récupérera donc les propriétés de l'aspect (celles-ci seront affichées dans le détail).

[…]

   <type name="sc:doc">
            <title>Someco Document</title>
            <parent>cm:content</parent>
            <associations>
                <association name="sc:relatedDocuments">
                    <title>Related Documents</title>
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>sc:doc</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
            </associations>
            <mandatory-aspects>
                <aspect>cm:generalclassifiable</aspect>
                <aspect>sc:webable</aspect>
            </mandatory-aspects>
        </type>
[…]

<aspect name="sc:webable">
            <title>Someco Webable</title>
            <properties>
                <property name="sc:published">
                    <type>d:date</type>
          <mandatory>false</mandatory>
                </property>
                <property name="sc:isActive">
                    <type>d:boolean</type>
          <mandatory>false</mandatory>
                    <default>false</default>
                </property>
            </properties>
        </aspect>

[…]
Le " <mandatory>false</mandatory>" que l'on trouve pour les proprétés de l'aspect permet d'ajouter l'aspect sans avoir forcément une valeur de saisie.

Ou l'on ajoute des propriétés au type, exemple :

 
<type name="sc:doc">
            <title>Someco Document</title>
            <parent>cm:content</parent>
              <properties>
            <property name="sc:prop">
               <title>Name</title>
               <type>d:text</type>             
            </property>
         </properties>
            <associations>
                <association name="sc:relatedDocuments">
                    <title>Related Documents</title>
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>sc:doc</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
            </associations>
            <mandatory-aspects>
                <aspect>cm:generalclassifiable</aspect>
            <aspect>sc:webable</aspect>
            </mandatory-aspects>
        </type>
il faudra alors dans le web-client-config-custom.xml ajouter le paramétrage suivant :

 <config evaluator="node-type" condition="sc:doc">
      <property-sheet>        
            <show-property name="sc:prop" display-label-id="monLabel"/>        
            <show-association name="sc:relatedDocuments" display-label-id="monLabel"/>
     </property-sheet>
    </config>

noobfresco
Champ in-the-making
Champ in-the-making
Ok çà marche mieux avec vos indications. Par contre, vous avez apparement remarqué d'entrer de jeu que les types sc:doc et whitepaper n'avaient pas de propriétés. Est-ce que vous avez un modèle typique sous la main, un genre de didactitiel ou autre qui montre comment structurer un model / propriété / aspect ?

Parce que c'est comme si j'apprenais un nouveau langage sans notice là ^^ Je ne peux créer que par comparaison ou reproduction des exemples que j'ai vu. Je pose un peu le même genre de questions sur le sujet http://forum.alfresco-fr.org/viewtopic.php?id=1110 en fait.

Je vais déjà regarder + en profondeur l'impact qu'ont des modifications sur cet exemple avant de revenir poser des questions, merci encore pour ta réponse rapide!

egr
Champ in-the-making
Champ in-the-making
En fait je n'ai pas de modèle générique en particulier, je pense que c'est plus par habitude.

Je peux te conseiller le wiki Alfresco qui  traite de ce sujet :
http://wiki.alfresco.com/wiki/Data_Dictionary_Guide

ainsi que la version française :
http://wiki.alfresco.com/fr/index.php/DocumentationSmiley Tonguer%C3%A9sentation_du_mod%C3%A8le_de_donn%C3%A9es

noobfresco
Champ in-the-making
Champ in-the-making
Oui en effet, j'ai passé ma journée sur ce wiki Smiley Happy Par contre je ne savais pas qu'il existait en FR ! Et çà c'est cool, çà va me permettre d'y voir un peu + clair sur certains aspect des modèles qui reste flou, sans vilain jeu de mots Smiley Tongue

Merci Eric !

ayda
Champ in-the-making
Champ in-the-making
est ce qu'avec la version 2.2 d'alfresco et donc avec la nouveauté des modèles dynamiques je dois intervenir de la même manière concernant certains fichiers XML?
Merci

michaelh
Champ on-the-rise
Champ on-the-rise
En ce qui concerne la question relative à la version 2.2, j'ai répondu de façon préventive ici : http://forum.alfresco-fr.org/viewtopic.php?id=1175

En gros on va éviter (en tout cas moi) de traiter tout ce qui a un rapport avec la version 2.2 pour le moment, histoire de ne pas se disperser.

st
Champ in-the-making
Champ in-the-making
et mince…

lamba
Champ on-the-rise
Champ on-the-rise
Bonjour AbdEssamad,

Tu peux les mettre sous le répertoire \alfresco\tomcat\shared\classes\alfresco\extension

leperuvien
Champ in-the-making
Champ in-the-making
Bonjour les users Alfresco,

Lorsque j'essaie de mettre en place le modèle de Jeff (en ne touchant aucun contenu des fichiers présentés), j'ai une erreur qui se traduit ainsi :

12:31:35,418  ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\example-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 09190001 Could not import bootstrap model alfresco/extension/exampleModel.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:4135)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
   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:445)
   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: 09190001 Could not import bootstrap model alfresco/extension/exampleModel.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: 09190000 Failed to parse model
   at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:93)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:147)
   … 45 more
Caused by: org.jibx.runtime.JiBXException: Error accessing document
   at org.jibx.runtime.impl.XMLPullReaderFactory$XMLPullReader.nextToken(XMLPullReaderFactory.java:269)
   at org.jibx.runtime.impl.UnmarshallingContext.advance(UnmarshallingContext.java:333)
   at org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(UnmarshallingContext.java:795)
   at org.alfresco.repo.dictionary.M2Model.JiBX_root_projects_data_model_source_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_0(M2Model.java)
   at org.alfresco.repo.dictionary.JiBX_root_projects_data_model_source_java_org_alfresco_repo_dictionary_m2bindingM2Model_access.unmarshal()
   at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2773)
   at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2916)
   at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:88)
   … 46 more

A noter que mon modèle de données et le fichier associé (-context), sont déclarés dans $TOMCAT_HOME/webapps/alfresco/WEBINF/
classes/alfresco/extension

Avez vous une idée concernant cette erreur?

Cette erreur ne semble pas liée au modèle de Jeff étant donée que j'ai essayé avec d'autres exemples et elle revient à chaque coup. Peut être que je n'ai pas saisis un concept… du coup si une âme pouvait m'éclairer sur le sujet…
Merci par avance,
@++
LePeruvien