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

mrogers
Star Contributor
Star Contributor
You need to post the contents of the "parsing error" for anyone to be able to help.

Just a casual inspection you have use "my:alunos" for a model and also a type.   That could be a problem.

miguel_martins
Champ in-the-making
Champ in-the-making
   
Error  Please correct the errors below then click OK.

    * A system error happened during the operation: 00180002 Failed to parse model

The error was literally this one.

I have? I thought that you had to define the model and the first type with the same name.
I will try to change the name then.


changed the type alunos, to osalunos

this is the new error.

Please correct the errors below then click OK.

    * A system error happened during the operation: 00180003 Failed to parse model

mrogers
Star Contributor
Star Contributor
Your XML is badly formed,  are missing a closing </type>

miguel_martins
Champ in-the-making
Champ in-the-making
Like this?

<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:osalunos">
         <title>Os 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>
</type><!– added the type here to close   <type name="my:osalunos">–>
   </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>
I added the type , loaded it up again
  Please correct the errors below then click OK.

    * A system error happened during the operation: 00180005 Failed to compile model my:alunos

invictus9
Champ in-the-making
Champ in-the-making
I have seen this error when there is a conflict in the namespace definition. Essentially, only one file in your system can have "my:" as the namespace identifier. Do you have more than one file with that prefix?

The parser is notoriously bad for providing useful feedback. It reminds me of using assembler on very old, very small mini-computers, and debugging them from the front panel switches.

One approach that might help is to strip down the entire file to one property and one aspect and trying to get it to be accepted. Once it is, keep adding properties until you trip on the error.

miguel_martins
Champ in-the-making
Champ in-the-making
Thank you, thats a really nice suggestion.
I changed the code to this, it loads up.

<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>
         </properties>
</type><!– added the type here–>
   </types>
    <aspects>
   </aspects>
</model>

How do I apply this content to a new file? So that I am presented with the properties to fill out in the metadata?

miguel_martins
Champ in-the-making
Champ in-the-making
I managed to load up everything onto the model folder, and activate the model, I was expecting for it to show on the create document bit, as an option to add "Os alunos", however nothing shows there, how do one properly add a dynamical model into use so that it appears?

edit: I tried adding its data to the file web-client-config-custom.xml, but it didnt work.


<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="custom:PRImage"/>
<show-association name="custom:PRFiles"/>
   </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>



I guess it doesnt work because it would be the process to add the model non dinamically, what should I do to activate the content in order to be able to create files?

invictus9
Champ in-the-making
Champ in-the-making
I presume that you have done some reading on Dynamic Content Types? You need to enable the model once you have uploaded it.

As well, the web-client-config-custom.xml has to be installed in the appropriate place, and enabled. If it is in your extensions/ directory, it will be enabled at Alfresco restart time. If it is in your Data Dictionary/Web Client space, then you need to 'reload' the configuration using the web client configuration console. This is described in the custom content type wiki page as well.

miguel_martins
Champ in-the-making
Champ in-the-making
I think i was doing it wrong, for I was putting the xml into the data dictionary/models directory and editing the phisical file in the extensions folder.
I didnt knew I could add it on data dictionary/web client.

The edit to the phisical file to add it and the restart isnt working tho, the content type simply doesnt appear on the drop down menu to select.
I will now try out the other method and update this post as soon as I do it.

edit:
it doesnt show, am I writing the code well? Am I making any mistake that might prevent it from being read?