cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic models- Solved.

miguel_martins
Champ in-the-making
Champ in-the-making
Hello there, I am trying to add a dynamic content type

This is my type



<model name="my:alunos" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Alunos</description>
   <author>Mmartins</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.alunos" prefix="my"/>
   </namespaces>


   <!– Type and Aspect definitions go here –>
   <types>
      <type name="my:alunos">
         <title>Alunos</title>
         <parent>cm:content</parent>
         <properties>
       <property name="my:Nome">
   <title>Nome</title>
                  <type>d:text</type>
               </property>
   <property name="my:DocumentodeID">
   <title>Documento de ID</title>
                  <type>d:text</type>
               </property>
            <property name="my:NumdocdeID">
   <title>Numero de documento de ID</title>
               <type>d:text</type>
            </property>
      <property name="my:datanascimento">
   <title>Data de nascimento</title>
               <type>d:datetime</type>
            </property>
            <property name="my:morada">
   <title>Morada</title>
               <type>d:text</type>
            </property>
    <property name="my:email">
   <title>Email</title>
               <type>d:text</type>
            </property>
<property name="my:telefone">
<title>Telefone</title>
               <type>d:number</type>
            </property>
<property name="my:curso">
<title>Curso</title>
               <type>d:text</type>
            </property>
<property name="my:Escola">
<title>Escola/Instituição</title>
               <type>d:text</type>
            </property>
<property name="my:Bolseiro">
   <title>Bolseiro</title>
   <type>d:boolean</type>
   <default>false</default>
</property>
      <property name="my:datadebolseiro">
<title>Data de Bolseiro( Bolseiro desde)</title>
               <type>d:datetime</type>
            </property>
            <property name="my:nib">
<title>Nib</title>
               <type>d:text</type>
            </property>
<property name="my:numconta">
<title>Numero de conta</title>
               <type>d:text</type>
            </property>
<property name="my:numbanco">
<title>numero do banco</title>
               <type>d:text</type>
            </property>
         </properties>

   </types>

   <aspects>
      <aspect name="my:imageClassification">
         <title>Image Classification</title>
         <properties>
            <property name="my:width">
               <type>d:int</type>
            </property>
            <property name="my:height">
               <type>d:int</type>
            </property>
            <property name="my:resolution">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>
   </aspects>


</model>

Its supposed to be a content model called alunos, that has several text fields ( and some date ones) .
What am I doing wrong? Everytime I try to load it up onto data dictionary models it gives me a parsing error.

Any help would be welcomed since I am pretty new at this and might have interpreted the wiki tutorials wrong.
18 REPLIES 18

maqsood
Confirmed Champ
Confirmed Champ
Miguel,

Did you define your customModel file in cusstom-model-context file?
there is one more file require i.e. custom-model-context apart form customModel and web-client-config-custom.

check it once, Is that file is in place?

miguel_martins
Champ in-the-making
Champ in-the-making
those are the only two files I have edited/added

Company Home > Data Dictionary > Models >alunos.xml
Company Home > Data Dictionary > Web Client Extension >web-client-config-custom.xml


I dont have a custom-model-context folder  on data dictionary, should there be one? Where should I add that file and what should be its contents?
(Thank you yet again for all the precious help you are giving me, really.)

maqsood
Confirmed Champ
Confirmed Champ
Yes, there is one more file custom-model-context.xml you need to have.

You can add custom meta data to a document in 3 steps:
1. Create customModel.xml, define your custom metadata types, which you already done.
2. Create custom-model-context.xml and include following code:
<?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/customModel.xml</value>
            </list>
        </property>
    </bean>
         
</beans>
Note: customModel is your custom metadata filename.
3. Place these two file at <Alfresco>\tomcat\shared\classes\alfresco\extension. And modify web-client-config-custom.xml, which is at same location, you alreday done this.

Then start the server and create or upload a document; and select your custom type as document type.
I guess the second step is missing in your process.
Hope this helps.

miguel_martins
Champ in-the-making
Champ in-the-making
1. Create customModel.xml, define your custom metadata types, which you already done.- yes, alunos xml
2. Create custom-model-context.xml and include following code:=snip= done so.  =(done so, used that exact name.
Note: customModel is your custom metadata filename.
3. Place these two file at <Alfresco>\tomcat\shared\classes\alfresco\extension. And modify web-client-config-custom.xml, which is at same location, you alreday done this.-confirmed

Then start the server and create or upload a document; and select your custom type as document type.-
when i get to this step, however, nothing shows on the dropdown.

Could it be some basic error on my code? It was posted whole above.

maqsood
Confirmed Champ
Confirmed Champ
2. Create custom-model-context.xml and include following code:=snip= done so. =(done so, used that exact name.

customModel should be your alunos.xml and custom-model-context.xml should be alunos-model-context.xml. And context file should contain the below code:
<?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/alunos.xml </value>
            </list>
        </property>
    </bean>
         
</beans>

Check your files are they same as I mentioned above. let me know incase of any issue.

miguel_martins
Champ in-the-making
Champ in-the-making
alunos.xml
<model name="mgo:alunos" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Alunos</description>

   <author>Mmartins</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="mgo.alunos" prefix="mgo"/>

   </namespaces>

<!– Type and Aspect definitions go here –>

   <types>

      <type name="mgo:osalunos">

         <title>Os Alunos</title>

         <parent>cm:content</parent>

         <properties>

       <property name="mgo:Nome">

   <title>Nome</title>

                  <type>d:text</type>

               </property>

<property name="mgo:DocumentodeID">

   <title>Documento de ID</title>

                  <type>d:text</type>

               </property>

            <property name="mgo:NumdocdeID">

   <title>Numero de documento de ID</title>

               <type>d:text</type>

            </property>

      <property name="mgo:datanascimento">

   <title>Data de nascimento</title>

               <type>d:datetime</type>

            </property>

<property name="mgo:morada">

   <title>Morada</title>

               <type>d:text</type>

            </property>



    <property name="mgo:email">

   <title>Email</title>

               <type>d:text</type>

            </property>

<property name="mgo:telefone">

<title>Telefone</title>

               <type>d:int</type>

            </property>

<property name="mgo:curso">

<title>Curso</title>

               <type>d:text</type>

            </property>





<property name="mgo:Escola">

<title>Escola/Institui??o</title>

               <type>d:text</type>

            </property>

<property name="mgo:Bolseiro">

   <title>Bolseiro</title>

   <type>d:boolean</type>

   <default>false</default>

</property>

      <property name="mgo:datadebolseiro">

<title>Data de Bolseiro( Bolseiro desde)</title>

               <type>d:datetime</type>

            </property>

            <property name="mgo:nib">

<title>Nib</title>

               <type>d:text</type>

            </property>

<property name="mgo:numconta">

<title>Numero de conta</title>

               <type>d:text</type>

            </property>

<property name="mgo:numbanco">

<title>numero do banco</title>

               <type>d:text</type>

            </property>





         </properties>




<associations>
   <association name="mgo:alImage">
      <title>Alunos Image</title>
      <source>
         <mandatory>false</mandatory>
         <many>true</many>
      </source>
      <target>
         <class>cm:content</class>
         <mandatory>false</mandatory>
         <many>false</many>
      </target>
   </association>
   <association name="mgo:alFiles">
      <title>alunos Files</title>
      <source>
         <mandatory>false</mandatory>
         <many>true</many>
      </source>
      <target>
         <class>cm:content</class>
         <mandatory>false</mandatory>
                              <many>true</many>
                          </target>
                      </association>
                 </associations>



</type><!– added the type here–>

   </types>

    <aspects>

<!– <aspect name="mgo:imageClassification">

         <title>Image Classification</title>



         <properties>

            <property name="mgo:width">

               <type>d:int</type>

            </property>

            <property name="mgo:height">

               <type>d:int</type>

            </property>

            <property name="mgo:resolution">

               <type>d:int</type>

            </property>

         </properties>




</aspect>–>

   </aspects>

</model>


alunos-model-content.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/alunos.xml</value>
            </list>
        </property>
    </bean>
        
</beans>


web-client-config-custom.xml

<alfresco-config>

<config evaluator="node-type" condition="mgo:alunos">
   <property-sheet>
      <show-property name="mimetype"
        display-label-id="content_type"
        component-generator="MimeTypeSelectorGenerator" />
      <show-property name="size"
        display-label-id="size"
        converter="org.alfresco.faces.ByteSizeConverter"
        show-in-edit-mode="false" />
      <show-property name="mgo:Nome" />
      <show-property name="mgo:DocumentodeID" />
      <show-property name="mgo:NumdocdeID" />
      <show-property name="mgo:datanascimento" />
      <show-property name="mgo:morada" />
      <show-property name="mgo:email" />
      <show-property name="mgo:telefone" />
      <show-property name="mgo:curso" />
      <show-property name="mgo:Escola"/>
      <show-property name="mgo:Bolseiro"/>
      <show-property name="mgo:datadebolseiro"/>
      <show-property name="mgo:nib"/>
      <show-property name="mgo:numconta"/>
      <show-property name="mgo:numbanco"/>
<show-association name="mgo:alImage"/>
<show-association name="mgo:alFiles"/>
   </property-sheet>

</config>

<config evaluator="string-compare" condition="Content Wizards">
   <content-types>
      <type name="mgo:alunos" />
   </content-types>
</config>


<config evaluator="string-compare" condition="Action Wizards">
   <aspects>
      <aspect name="mgo:osalunos"/>
   </aspects>
<subtypes>
   <type name="mgo:alunos"/>
</subtypes>
</config>
</alfresco-config>


It all seems to load flawlessly, no "obvious" errors in the xml but whenever I attempt to create a new content, there is no sign of this model on the dropdown menu.
Can you load these same on your system?

hailpam
Champ in-the-making
Champ in-the-making
Hi maqsood,

I've had the same problem which is described in initial post. I resolved thanks to your help: my main error was the not inclusion of custom-model-context.xml at the extension path with customModel.xml and web-client-config-custom.xml.

Thanks for your indirect help,

–Paolo

maqsood
Confirmed Champ
Confirmed Champ
Martin,

Check your context filename, you got it wrong, that should be alunos-model-context.xml

miguel_martins
Champ in-the-making
Champ in-the-making
I had already detected that one, but it wasnt working out, in the end i started from another already working custom model and started adding the data i needed to it, one by one. Its working out so far. Thank you all.