AnsweredAssumed Answered

Code to assign type not working

Question asked by cperez on Jul 1, 2014
Latest reply on Jul 9, 2014 by cperez
Hello I'm creating a code to add a type to a NodeRef, everything seems to work fine however when we review the type of the document in alfresco (checking the metadata assigned to the document in the details view). None of the following properties shown in the custom-model attached appears to be linked to the Node.
This is the java code i'm using and the configuration i have created. could you please let me know what can be wrong?

Just to let you know the code does not return any error, and in the log the operation seems to ended succesfully but not.

private void addTypeContract(NodeRef nodeRef) {
      
      if((nodeRef != null) && this.getServiceRegistry().getNodeService().exists(nodeRef)){
         // Especializar tipo de documento a factura
         // Get the type of the node
         QName currentType = this.getServiceRegistry().getNodeService().getType(nodeRef);
         
         // Ensure that we are performing a specialise
         if ((currentType.equals(DigitalizacionModel.Alf_Type_Contratos) == false)
               && this.getServiceRegistry().getDictionaryService().isSubClass(DigitalizacionModel.Alf_Type_Contratos,
                     currentType) == true) {
            // Specialise the type of the node
            this.getServiceRegistry().getNodeService().setType(nodeRef, DigitalizacionModel.Alf_Type_Contratos);
            logger.info("Ha introducido el tipo de contratos");
         }
         else {logger.info("No ha entrado en el if de asignacion");}
      }
   }


This is my custom-model.xml:


      <types>
          <type name="dig:Contratos">
               <title>Contratos</title>
            <parent>cm:content</parent>
            <properties>
               <property name="dig:Nombre">
                  <title>Nombre del contrato</title>
                  <type>d:text</type>
                  <mandatory>true</mandatory>
               </property>
               <property name="dig:Num">
                  <title>Número de Contrato</title>
                  <type>d:text</type>
                     <mandatory>false</mandatory>
               </property>
                  <property name="dig:CIF">
                     <title>CIF Empresa Emisora</title>
                     <type>d:text</type>
                     <mandatory>true</mandatory>
                  </property>
               <property name="dig:FechaContrato">
                  <title>Fecha de realización de las operaciones</title>
                  <type>d:date</type>
                  <mandatory>true</mandatory>
               </property>
               <property name="dig:Descripcion">
                  <title>Descripción contrato</title>
                  <type>d:text</type>
                     <mandatory>false</mandatory>
               </property>
            </properties>
         </type>
      </types>


this is my web-client-config-custom.xml:

<alfresco-config>
   <config evaluator="node-type" condition="dig:Digitalizacion">
      <property-sheet>
        
         <show-property name="title" show-in-edit-mode="false" show-in-view-mode="false"/>
         <show-property name="description" show-in-edit-mode="true" show-in-view-mode="true"/>
         <show-property name="author" show-in-edit-mode="false" show-in-view-mode="false"/>
         <show-property name="mimetype" show-in-edit-mode="false" show-in-view-mode="false"/>
         <show-property name="size"
            display-label-id="size"
            converter="org.alfresco.faces.ByteSizeConverter"
            show-in-edit-mode="false" />
           
         <separator name="sep0" display-label="Datos generales Contrato" component-generator="HeaderSeparatorGenerator" />
         <show-property name="dig:Nombre"/>
         <show-property name="dig:Num"/>
         <show-property name="dig:CIF"/>
         <show-property name="dig:FechaContrato"/>
         <show-property name="dig:Descripcion"/>
      </property-sheet>
   </config>
       
    <config evaluator="string-compare" condition="Content Wizards">
        <content-types>
            <type name="dig:Digitalizacion" />
        </content-types>       
    </config>
       
    <config evaluator="string-compare" condition="Action Wizards">
        <subtypes>
            <type name="dig:Digitalizacion"/>
        </subtypes>
    </config>
   
    <config evaluator="string-compare" condition="Advanced Search Dig">
        <advanced-search>
            <content-types>
                <type name="dig:Digitalizacion" />
            </content-types>
            <custom-properties>
                <meta-data type="dig:Digitalizacion" property ="dig:Nombre" />
                <meta-data type="dig:Digitalizacion" property ="dig:Num" />
                <meta-data type="dig:Digitalizacion" property ="dig:FechaContrato"/>              
                <meta-data type="dig:Digitalizacion" property ="dig:CIF" />
                <meta-data type="dig:Digitalizacion" property ="dig:Descripcion" />
            </custom-properties>
        </advanced-search>
    </config>
</alfresco-config>

Outcomes