Alfresco Custom Model

6,322 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,322
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
85
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Alfresco Custom Model

  1. 1. Alfresco Custom Model Università del Salento, 2012 Andrea Leo www.alfresco.com www.qbreng.it
  2. 2. Estendere il modello dei contenutiAlfresco permette di personalizzare e estendere il modello dei contenti persoddisfare le diverse esigenze dell’OrganizzazioneIl Dizionario dei Dati di default è pre-popolato con le definizioni che descrivonoi contenuti con cui è inizialmente popolato il repository (Cartelle, Documenti,Nomi)Il Dizionario dei Dati di Alfresco è estendibile, consente all’utente di dichiararenuovi Tipi di Dati Personalizzati (Custom Content Type) che soddisfano ibisogni dell’Organizzazione.
  3. 3. 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 lereditarietà. 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.
  4. 4. 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)
  5. 5. 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.
  6. 6. 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
  7. 7. 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> ...
  8. 8. Alfresco Namespaces
  9. 9. 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>
  10. 10. 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>
  11. 11. Additional Property Capabilities<property name="my:property"> <type>d:text</type> <mandatory enforced=true>true</mandatory> <default>my default value</default> </property>….Its 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>
  12. 12. Data TypesThe following data types are supported: 5
  13. 13. 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
  14. 14. 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. Alfrescos search languages do not yet support joins across non-child associations.
  15. 15. 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>...
  16. 16. 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>...
  17. 17. built-in constraintsThese 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>
  18. 18. built-in constraintsThe built-in constraints are present in the packageorg.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.ListOfValuesConstraintThe <parameter> definitions correspond directly to setter methods on the classes
  19. 19. 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>
  20. 20. Out-of-the-box Aspects Classifiable Aspect: Enable Categorization so that categories can be linked to thedocument. Dublin Core Aspect: Add Dublin core metadata to the document. Dublin coremetadata includes properties such as Publisher, Contributor, Subject, and Rights. Effectivity Aspect: Add effectivity properties called Effective From and EffectiveTo to the document. Emailed Aspect: Add a set of properties called Email Data to the document. This isuseful 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.
  21. 21. ADAMO
  22. 22. Content Model UML Class Diagram
  23. 23. Dynamic modelEnables 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 Extensionshttp://localhost:8080/alfresco/faces/jsp/admin/webclientconfig-console.jsp → reloadNOTES: 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.
  24. 24. Estendere il modello Avanzato 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”.Tomcat: <TOMCAT_HOME>/shared/classes/alfresco/extension
  25. 25. 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

×