Upload
andrea-leo
View
5.149
Download
7
Embed Size (px)
DESCRIPTION
Citation preview
Alfresco Custom Model
Andrea Leo
www.alfresco.comwww.qbreng.it
Università del Salento, 2012
Estendere il modello dei contenuti
Alfresco permette di personalizzare e estendere il modello dei contenti per soddisfare le diverse esigenze dell’Organizzazione
Il Dizionario dei Dati di default è pre-popolato con le definizioni che descrivono i contenuti con cui è inizialmente popolato il repository (Cartelle, Documenti, Nomi)
Il Dizionario dei Dati di Alfresco è estendibile, consente all’utente di dichiarare nuovi Tipi di Dati Personalizzati (Custom Content Type) che soddisfano i bisogni dell’Organizzazione.
I Blocchi elementari : Tipi e Proprietà
Tipo: il concetto di tipo è concettualmente simile al concetto di Classe dei linguaggi Object Oriented (es. Persona, Content, Folder).
Il concetto di Tipo è usato per modellare i Business Object che hanno proprietà personalizzate.
I Tipi supportano l'ereditarietà.
Proprietà: sono metadati che appartengono ad un determinato tipo (es. Nome_Persona, Telefono_Persona)
Tipi di Proprietà: sono i tipi di dato fondamentali. Descrivono i tipi di dati del Repository che saranno usati per memorizzare le proprietà (es. strings, dates, floats, boolean).
Vincoli: i Constraints possono opzionalmente essere usati per restringere/controllare il valore di alcune proprietà. Ci sono 4 tipi di vincoli di default disponibili dalla piattaforma: REGEX (espressioni regolari), LIST, MINMAX e LENGTH. Anche i vincoli possono essere estesi.
I Blocchi elementari : Aspetti e Associazioni
Aspetti: permettono di “incollare” delle Proprietà a Tipi di contenuto o anche a singole istanze di documenti quando e dove abbiamo bisogno.
Associazioni: una associazione definisce relazioni fra Tipi.
Peer Associations: definisce una relazione “alla Pari” fra due oggetti nel repository, in cui nessuno dei due è subordinato all’altro.
Child Association: definisce una relazione “Padre-Figlio” fra due oggetti, ossia l’oggetto Target (Figlio) dell’associazione potrebbe non esistere mentre l’oggetto Source (Padre) esiste sicuramente (es. associazione fra il tipo “Folder” e il tipo “Content” instaurata nel repository di Alfresco)
Content Model Overview
A Content Model is a collection of related Content Types and Aspects.
Each Content Model is described in its own XML file
It is identified by its defined Namespace and Name.
Built-in Content Model Namespaces
Out-of-the-box, the Alfresco Repository is primed with several models:
System - describes system-level Repository concepts
Content - describes the Content Domain Model (e.g. Folder, File, etc.)
Application - describes Alfresco Application Model (e.g. Glossary, …)
Dictionary - describes the Dictionary Meta-model
The above models may be found at:
<tomcat-home>/webapps/alfresco/WEB-INF/classes/alfresco/model/systemModel.xml
<tomcat-home>/webapps/alfresco/WEB-INF/classes/alfresco/model/contentModel.xml
<tomcat-home>/webapps/alfresco/WEB-INF/classes/alfresco/model/applicationModel.xml
<tomcat-home>/webapps/alfresco/WEB-INF/classes/alfresco/model/dictionaryModel.xml
Schema Namespaces
<model name="cm:contentmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Alfresco Content Model</description> <author>Alfresco</author> <published>2005-06-03</published> <version>1.0</version>
<namespaces> <namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/> </namespaces>
<imports> <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/> </imports>
...
Alfresco Namespaces
Content Types
<types>
<type name="cm:cmobject">
<title>Object</title> <parent>sys:base</parent>
<properties> <property name="cm:name"> <type>d:text</type> </property> </properties>
<mandatory-aspects> <aspect>cm:auditable</aspect> </mandatory-aspects>
</type> …</types>
Aspects
<aspects> <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> …</aspects>
Additional Property Capabilities
<property name="my:property"> <type>d:text</type> <mandatory enforced='true'>true</mandatory> <default>my default value</default> </property>
….
It's possible to describe how properties are indexed.
<property name="cm:example"> <type>d:text</type> <mandatory>false</mandatory> <index enabled="true"> <atomic>false</atomic> <!-- index in the background. Default true --> <stored>false</stored> <!-- store the property value in the index.Default false --> <tokenised>true</tokenised> <!-- Default true --> </index> </property>
Data Types
5
The following data types are supported:
Child Associations
<type name="cm:folder"> <title>Folder</title> <parent>cm:cmobject</parent> <associations> <child-association name="cm:contains"> <source> <mandatory>false</mandatory> <many>false</many> </source> <target> <class>sys:base</class> <mandatory>false</mandatory> <many>true</many> </target> <duplicate>false</duplicate> <propagateTimestamps>true</propagateTimestamps> </child-association> </associations> </type>
Note: operations like delete etc will propagate through the children
Peer Associations
<aspect name="cm:subscribable"> <associations> <association name="cm:subscribedBy"> <source> <mandatory>false</mandatory> <many>true</many> </source> <target> <class>cm:person</class> <mandatory>false</mandatory> <many>true</many> </target> </association> </associations> </aspect>
Notes :
Delete propagation does not take place.
Alfresco's search languages do not yet support joins across non-child associations.
built-in constraints
... <constraints>
<constraint name="test:regex1" type="REGEX"> <parameter name="expression"><value>[A-Z]*</value></parameter>
... </constraint>
<constraint name="test:regex2" type="REGEX"> <parameter name="expression"><value>[a-z]*</value></parameter>
... </constraint>
<constraint name="test:stringLength1" type="LENGTH"> <parameter name="minLength"><value>0</value></parameter> <parameter name="maxLength"><value>256</value></parameter> </constraint>
...
built-in constraints
...
<constraint name="test:minMax1" type="MINMAX"> <parameter name="minValue"><value>100</value></parameter> <parameter name="maxValue"><value>256</value></parameter> </constraint>
<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>
</constraints>...
built-in constraints
These constraints can be referenced in the property definitions:
<property name="test:prop1"> <type>d:text</type> <protected>true</protected> <default></default> <constraints> <constraint ref="test:regex1"/> <constraint ref="test:stringLength1"/> </constraints> </property>
Further constraints can be defined inline as well, but are not reusable: <property name="test:prop1"> <type>d:text</type> <protected>true</protected> <default></default> <constraints> <constraint ref="test:regex1"/> <constraint type="LENGTH"> <parameter name="minLength"><value>0</value></parameter> <parameter name="maxLength"><value>128</value></parameter> </constraint> </constraints> </property>
built-in constraints
The built-in constraints are present in the package org.alfresco.repo.dictionary.constraint and are:
REGEX : org.alfresco.repo.dictionary.constraint.RegexConstraint
LENGTH : org.alfresco.repo.dictionary.constraint.StringLengthConstraint
MINMAX : org.alfresco.repo.dictionary.constraint.NumericRangeConstraint
LIST : org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint
The <parameter> definitions correspond directly to setter methods on the classes
Writing Further Constraints
Implement the org.alfresco.service.cmr.dictionary.Constraint interface
Extend org.alfresco.repo.dictionary.constraint.AbstractConstraint..
<constraint name="my:FactorsOf" type="com.company.alfresco.constraints.MultiplesOfConstraint"> <parameter name="multipleOf"><value>10</value></parameter> </constraint>
Out-of-the-box Aspects
Classifiable Aspect: Enable Categorization so that categories can be linked to the document.
Dublin Core Aspect: Add Dublin core metadata to the document. Dublin core metadata includes properties such as Publisher, Contributor, Subject, and Rights.
Effectivity Aspect: Add effectivity properties called Effective From and Effective To to the document.
Emailed Aspect: Add a set of properties called Email Data to the document. This is useful to capture the email information if the document is an attachment to email.
Summarizable Aspect: Add a property called Summary to the document.
Templatable Aspect: Enable template view.
Geographic Aspect: Add two properties called Latitude and Longitude.
Versionable Aspect: Enable versioning.
ADAMO
Content Model UML Class Diagram
Dynamic model
Enables dynamic customisation of models without requiring a restart of the server
deployment/undeployment of custom models (messages) deployment/undeployment of custom workflow (process) definitions deployment/undeployment of custom web client extensions
Models in Company Home -> Data Dictionary -> Models (Model Active checkbox) Messages in Company Home -> Data Dictionary -> Messages Webclient in Company Home -> Data Dictionary -> Web Client Extensions
http://localhost:8080/alfresco/faces/jsp/admin/webclientconfig-console.jsp → reload
NOTES:
Only incremental updates are supported for an active model. If the update attempts to delete a type, aspect, property (etc) then the upload will fail.
Estendere il modello Avanzato
Tomcat: <TOMCAT_HOME>/shared/classes/alfresco/extension
Il modello dei dati può essere esteso editando 3 file di configurazione XML:
• QBR-Model-content.xml: permette di dichiarare alla piattaforma un insieme di modelli di dati personalizzati che saranno resi disponibili all’interno di Alfresco
• QBRModel.xml: permette di implementare il Content Model definito, ossia dichiarare alla piattaforma Tipi, Aspetti, e Associazioni.
• Web-client-config-custom.xml: permette di dichiarare il modello creato all’interfaccia utente di Alfresco: “Web Client”.
Resources
http://www.alfresco.com
http://wiki.alfresco.com/wiki/Category:Content_Modeling
http://www.qbreng.it
http://wiki.qbreng.it
http://sourceforge.net/projects/adamo-project/
Twitter : andrealeo83