Adsence

viernes, 20 de febrero de 2015

Contenidos Personalizados en Alfresco



TIPO DOCUMENTAL EN ALFRESCO

Resultado de imagen para alfresco

Alfresco es una plataforma de gestion documental (ECM) en la cual se puede hacer entre otras cosas manejo de procesos documentales (BPMS), maneja gestores de contenido (CMS) y toda una plataforma de integracion para servicios.

Por esta ocacion nos vamos a centrar en la creacion de contenido personalizado en Alfresco, la version de alfresco que se esta usando es la version 5 de Alfresco sobre un servidor Ubuntu.
Para crear un tipo documental en Alfresco se deben realizar los siguientes pasos:
Primero crear los archivos de configuración, estos deben tener cualquier nombre pero se debe colocar al final de los archivos de contexto la cadena “–context” para que sean reconocidos por el aplicativo.

El siguiente ejemplo crea un tipo de contenido y un aspecto con tres cadenas cada uno.

En la ruta %ALFRESCO_HOME%/tomcat/shared/clases/alfresco/extensión crear los siguientes archivos:

AgreementModel.xml
(Contiene el modelo del contenido, se puede agregar contenido y aspectos)
<?xml version = "1.0" encoding = "UTF-8"?>
<model name = "reinsurance:agreementmodel" xmlns = "http://www.alfresco.org/model/dictionary/1.0">
                <description>Custom Model para Contratos</description>
                <author>Christian Villavicencio</author>
                <version>1.0</version>
                <imports>
                               <import uri = "http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
                               <import uri = "http://www.alfresco.org/model/content/1.0" prefix = "cm"/>
                </imports>
                <namespaces>
                               <namespace uri = "modelo.agreement" prefix = "reinsurance"/>
                </namespaces>
                <types>
                               <type name = "reinsurance:agreement">
                                               <title>Contratos</title>
                                               <parent>cm:content</parent>
                                               <properties>
                                                               <property name = "reinsurance:nombrecontenido">
                                                                              <title>Nombre Principal</title>
                                                                              <type>d:text</type>
                                                                              <mandatory>false</mandatory>
                                                               </property>
                                                               <property name = "reinsurance:cedentecontenido">
                                                                              <title>Nombre Cedente Completo</title>
                                                                              <type>d:text</type>
                                                                              <mandatory>false</mandatory>
                                                               </property>
                                                               <property name = "reinsurance:fechacontenido">
                                                                              <title>Fecha Creacion documento</title>
                                                                              <type>d:text</type>
                                                                              <mandatory>false</mandatory>
                                                               </property>                                                                          
                                               </properties>
                                               <!--mandatory-aspects>
                                                               <aspect>reinsurance:aspectAgreement</aspect>
                                               </mandatory-aspects-->
                               </type>
                </types>
                <aspects>
                               <aspect name = "reinsurance:aspectAgreement">
                                               <title>Agreement</title>
                                               <properties>
                                                               <property name = "reinsurance:nombre">
                                                                              <title>Nombre</title>
                                                                              <type>d:text</type>
                                                                              <mandatory>false</mandatory>
                                                               </property>
                                                               <property name = "reinsurance:cedente">
                                                                              <title>Nombre Cedente</title>
                                                                              <type>d:text</type>
                                                                              <mandatory>false</mandatory>
                                                               </property>
                                                               <property name = "reinsurance:fecha">
                                                                              <title>Fecha Creacion</title>
                                                                              <type>d:text</type>
                                                                              <mandatory>false</mandatory>
                                                               </property>                                                                          
                                               </properties>
                               </aspect>
                </aspects>
</model>

AgreementModel-context.xml

(mapeo del modelo en el contexto de Alfresco)
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans default-lazy-init="false" default-autowire="no" default-dependency-check="none">
                <bean id = "extension.dictionaryBootstrap" parent = "dictionaryModelBootstrap" depends-on = "dictionaryBootstrap">
                               <property name = "models">
                                               <list>
                                                               <value>alfresco/extension/AgreementModel.xml</value>
                                               </list>
                               </property>
                </bean>
</beans>

web-client-config-custom.xml

(despliegue de contenido en Alfresco Explorer)
<?xml version="1.0" encoding="UTF-8"?>
<alfresco-config>
                <config evaluator = "string-compare" condition = "Action Wizards">
                               <subtypes>
                                               <type name = "reinsurance:agreement"/>
                               </subtypes>
                               <aspects>
                                               <aspect name = "reinsurance:aspectAgreement"/>
                               </aspects>
                               <especialise-types>
                                               <type name = "reinsurance:agreement"/>
                               </especialise-types>
                </config>
               
                <config evaluator = "string-compare" condition = "Content Wizards">
                               <content-types>
                                               <type name = "reinsurance:agreement" />
                               </content-types>
                </config>
               
                <config evaluator = "node-type" condition = "reinsurance:agreement">
                               <property-sheet>
                                               <show-property name = "reinsurance:nombrecontenido"/>
                                               <show-property name = "reinsurance:cedentecontenido"/>
                                               <show-property name = "reinsurance:fechacontenido"/>                                    
                               </property-sheet>
                </config>

                <config evaluator = "aspect-name" condition = "reinsurance:aspectAgreement">
                               <property-sheet>
                                               <show-property name= "reinsurance:nombre"/>
                                               <show-property name= "reinsurance:cedente"/>
                                               <show-property name= "reinsurance:fecha"/>                                      
                               </property-sheet>
                </config>
               
                <config evaluator= "string-compare" condition = "Advanced Search">
                               <advanced-search>
                                               <content-types>
                                                               <type name= "reinsurance:agreement" />
                                               </content-types>
                                               <custom-properties>
                                                               <meta-data aspect= "reinsurance:aspectAgreement" property= "reinsurance:nombre" />
                                                               <meta-data aspect= "reinsurance:aspectAgreement" property= "reinsurance:cedente" />
                                                               <meta-data aspect= "reinsurance:aspectAgreement" property= "reinsurance:fecha" />                                                      
                                               </custom-properties>
                               </advanced-search>
                </config>

</alfresco-config>

web-client-custom-context.xml

(Mapeo de archivo en el contexto del Alfresco)
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
     <bean id="myproject-extension-webclient-configBootstrap" class="org.alfresco.web.config.WebClientConfigBootstrap" init-method="init">
      <property name="configs">
            <list>
                <value>alfresco/extension/web-client-config-custom.xml</value>
            </list>
        </property>
    </bean>
</beans>

myproject-extension-module-context.xml

(Import  de los archivos de contexto)
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<!-- references to XML configurations -->
<beans>
    <import resource="AgreementModel-context.xml"/>
    <import resource="web-client-custom-context.xml"/>
</beans>

En la ruta %ALFRESCO_HOME%/tomcat/shared/clases/alfresco/web-extensión  modificar el archivo con las líneas en rojo y los nuevos nodos:

share-config-custom.xml

(contiene el despliegue del contenido en la visualización de Alfresco Share)

<aspects>
         <!-- Aspects that a user can see -->
         <visible>
            <aspect name="cm:generalclassifiable" />
            <aspect name="cm:complianceable" />
            <aspect name="cm:dublincore" />
            <aspect name="cm:effectivity" />
            <aspect name="cm:summarizable" />
            <aspect name="cm:versionable" />
            <aspect name="cm:templatable" />
            <aspect name="cm:emailed" />
            <aspect name="emailserver:aliasable" />
            <aspect name="cm:taggable" />
            <aspect name="app:inlineeditable" />
            <aspect name="cm:geographic" />
            <aspect name="exif:exif" />
            <aspect name="audio:audio" />
            <aspect name="cm:indexControl" />
            <aspect name="dp:restrictable" />
                                               <aspect name="reinsurance:aspectAgreement" />
         </visible>

         <!-- Aspects that a user can add. Same as "visible" if left empty -->
         <addable>
         </addable>

         <!-- Aspects that a user can remove. Same as "visible" if left empty -->
         <removeable>
         </removeable>
      </aspects>

      <!--
         Used by the "Change Type" action

         Define valid subtypes using the following example:
            <type name="cm:content">
               <subtype name="cm:mysubtype" />
            </type>

         Remember to also add the relevant i18n string(s):
            cm_mysubtype=My SubType
      -->
      <types>
         <type name="cm:content">
                                               <subtype name="reinsurance:agreement" />
         </type>

         <type name="cm:folder">
         </type>
                                
         <type name="trx:transferTarget">
            <subtype name="trx:fileTransferTarget" />
         </type>
      </types>


Aumentar los nodos para realizar búsquedas y visualizar contenido:

<config evaluator="node-type" condition="reinsurance:agreement">
                   <forms>
                                <form>
                                               <field-visibility>
                                                  <show id="reinsurance:nombrecontenido" />
                                                  <show id="reinsurance:cedentecontenido" />
                                                  <show id="reinsurance:fechacontenido" />
                                               </field-visibility>
                                </form>
                   </forms>
                </config>

                <config evaluator="model-type" condition="reinsurance:agreement">
                   <forms>
                                <form id="search">
                                               <field-visibility>
                                                               <show id="reinsurance:nombrecontenido" />
                                                               <show id="reinsurance:cedentecontenido" />
                                                               <show id="reinsurance:fechacontenido" />
                                                </field-visibility>
                                </form>
                   </forms>
                </config>
               
                <config evaluator="string-compare" condition="AdvancedSearch">
                   <advanced-search>
                                 <!-- Forms for the advanced search type list -->
                                 <forms>
                                                <!-- Añadimos el contrato en la búsqueda avanzada -->
                                                <form label="Contratos" description="Búsqueda de Contratos">reinsurance:agreement</form>
                                 </forms>
                   </advanced-search>
                </config>

Reiniciar Alfresco con el comando:
./alfresco.sh stop
Y con el comando:
./alfresco.sh start

Se debe crear una regla a nivel de fichero en donde se depositarán los archivos, por ejemplo se tiene la siguiente regla: