Projet

General

Profil

Data models and forms

Introduction

This document introduces the setting and the administration of data models and forms for the beCPG software. It is intended to beCPG administrators. A video presents the creation of models and forms.

Data models (manually)

It’s possible to enrich the beCPG model by adding :
  • Properties: text values, integers, data lists etc...
  • Associations: association to an object type ;
  • Objects types: a compound of several properties/associations ;
  • Aspects: group of properties and/or associations which can be added to a type of object. This allows the re utilisation of a group of properties, common to many object types, for example a group of properties « Saleable products ».

This necessitates knowledge of XML and knowledge of content modelisation.

Files

The modification of the data model necessitates the modification of 3 files :

  1. <installLocation>/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/module/becpg-{$client}-core/model/{$client}Model.xml to modify the data model (addition of properties, associations) ;
  2. <installLocation>/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/module/becpg-{$client}-core/model/{$client}Model.properties to define the properties wordings ;
  3. <installLocation>/tomcat/webapps/share/WEB-INF/classes/alfresco/{$client}-form-config.xml to define the formatting of edition and consultation forms.

Where {$client}, is the name of the client.

The modified files Model.xml et Model.properties can be copied and pasted in the repertory <installLocation>/tomcat/shared/classes/alfresco/extension/ to facilitate the identification of the modified files. The naming convention is the following :
  • ext-{$client}Model.xml
  • ext-{$client}Model.properties

The modified file -form-config.xml can be copied and pasted in the repertory <installLocation>/tomcat/shared/classes/alfresco/web-extension to facilitate it’s identification. The naming convention is the following :
ext-{$client}-form-config.xml

In order to take into account the modifications, the application must be restarted by typing : sudo service alfresco restart

Setting of a property

Properties types are :

  • d:date
  • d:text
  • d:content
  • d:int
  • d:long
  • d:any
  • d:float
  • d:datetime
  • d:double
  • d:boolean
  • d:category
  • d:noderef
  • d:path

A property is defined by :

  <property name="...">
    <type>Type de données</type>
    <mandatory>obligatoire ou non</mandatory>
    <multiple>Valeur multiple ou non</multiple>
    <default>Valeur par défaut</default>
    <constraints>
       <constraint ref="ID" />
    </constraints>
  </property>

Example :

<property name="bcpg:productType">
    <type>d:text</type>
    <mandatory>true</mandatory>
    <multiple>true</multiple>
    <constraints>
    <constraint ref="bcpg:systemProductType" />
    </constraints>
</property>

Setting of a constraint

Constraints are defined in the section <contraints/> of the file {$client}Model.xml.

Here are some examples of constraints :

  • Regular expression :
<constraint name="test:regex1" type="REGEX">
       <parameter name="expression"><value>[A-Z]*</value></parameter>
       <parameter name="requiresMatch"><value>false</value></parameter>
</constraint>

  • Length Min/Max
<constraint name="test:stringLength1" type="LENGTH">
        <parameter name="minLength"><value>0</value></parameter>
        <parameter name="maxLength"><value>256</value></parameter>
</constraint>

  • Number Min/Max
<constraint name="test:minMax1" type="MINMAX">
        <parameter name="minValue"><value>0</value></parameter>
        <parameter name="maxValue"><value>256</value></parameter>
</constraint>

  • Data lists
<constraint name="test:list1" type="LIST">
        <parameter name="allowedValues">
            <list>
                <value>ABC</value>
                <value>DEF</value>
            </list>
        </parameter>
        <parameter name="caseSensitive"><value>true</value></parameter>
</constraint>

More details : http://wiki.alfresco.com/wiki/Constraints

Aspects

An aspect is a group of properties or associations which can be applied to a type. An aspect can be mandatory or not.

     <aspect name="cm:auditable">
         <title>Auditable</title>
         <properties>
            <property name="cm:created">
               <type>d:datetime</type>
            </property>
            <property name="cm:creator">
               <type>d:text</type>
            </property>
            <property name="cm:modified">
               <type>d:datetime</type>
            </property>
            <property name="cm:modifier">
               <type>d:text</type>
            </property>
            <property name="cm:accessed">
               <type>d:datetime</type>
            </property>
         </properties>
</aspect>

The addition of a mandatory aspect to a type is done in the section : <mandatory-aspects/>.

Example :

<type name="XXX">
    <parent>YYY</parent>
    <mandatory-aspects>
        <aspect>ZZZ</aspect>
    </mandatory-aspects>
</type>

Where ZZZ is the mandatory aspect defined on the type XXX.

Logs

The logs file is situated in the following repertory of the server: /var/log/alfresco/alfresco.log

Consultation, edition, creation and search forms

Forms are defined in the file :

<installLocation>/tomcat/webapps/share/WEB-INF/classes/alfresco/{$client}-form-config.xml

« Forms » refer to:
  • Creation form ;
  • Edition form ;
  • Consultation form ;
  • Search form ;
  • Bulk edition form

A form is defined by :

The form type :

  • Creation
<config evaluator="model-type" condition="bcpg:finishedProduct">
  <forms>
    <form id="create">

  • Edition
<config evaluator="node-type" condition="bcpg:finishedProduct">

* Recherche
<config evaluator="model-type" condition="bcpg:product">
   <forms>
      <form id="search"/>

  • Bulk edition
<config evaluator="model-type" condition="bcpg:product">
   <forms>
     <form id="bulk-edit"/>

  • Object type 
<config evaluator="node-type" condition="bcpg:finishedProduct">

  • Fields displayed in the section <field-visibility/>
<show id="bcpg:legalName" />

  • The formatting in the section <appearance/>
<field id="bcpg:meatCharacts" set="charact">
    <control template="/fr/becpg/components/form/controls/textarea.ftl" >
        <control-param name="rows">4</control-param>
    </control>
</field>

Where :

« set » defines the « fields » gathering ;
« template » defines the « Freemarker » template used to display the field. If nothing has been defined, the system takes the template by default ;
« control-param » defines a parameter of the « Freemarker » template.

More details : http://wiki.alfresco.com/wiki/Forms

Data models (designer)

The beCPG models designer allows the creation of data models and forms. It’s accessible from the upper band with the administrator role.

The designer is composed of 3 panels :

  • The left panel displays a tree representative of the model and a tree representative of the forms ;
  • The central panel displays the edition forms for forms and models ;
  • The right panel displays a pallette for grouping and control.

The choice of the file to display the model and the form is done thanks to the drop down menu in the tool bar of the left panel.

The models tree allows the creation of types, aspects, properties and constraints by positionning on the tree and pressing the button « New child ». The choice of the element type to be created is asked and eventually, the choice of the model type too.

Once the model has been created or modified, at the model root, press « Publish ».

Notes :

  • Every mandatory field has to be filled,
  • A type can be deleted if neither of the elements in the repository or in the bin has it ;
  • A property can only be modified by overloading the type or the aspect.

The creation of a form is done by dragging and dropping a type to the forms tree or thanks to the « New child » button. The association between controls and fields or fields grouping is done by drag and drop from the pallet to the area corresponding in the central panel.

In order to publish a form, hover over the forms tree root and press « Publish ».

The overview is done by selecting, in the models tree, a type and by pressin « Overview ». The type should be published. The form with the « Create » identifier associated to the type should be published.

For more information: http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html