Professional Documents
Culture Documents
2015
Alfresco ECM Citeck EcoS
Table of contents
What is content modeling .........................................................................................................................3
Who is engaged in content modeling .......................................................................................................3
Standard modeling options in Alfresco ............................................................................................... 3
Types .........................................................................................................................................................4
Properties and associations ......................................................................................................................5
Child associations ......................................................................................................................................6
Aspects ......................................................................................................................................................7
Names and name spaces ...........................................................................................................................8
Constraints ................................................................................................................................................8
Redefinitions .............................................................................................................................................9
Localization of models.............................................................................................................................10
Heritage ...................................................................................................................................................10
Downloading models...............................................................................................................................11
Official Alfresco documentation .............................................................................................................12
Rules and recommendations ............................................................................................................ 12
Name spaces ...........................................................................................................................................13
Naming ....................................................................................................................................................13
Constraints ..............................................................................................................................................13
Inheritance ..............................................................................................................................................13
Other .......................................................................................................................................................14
Modeling resources in Citeck EcoS ................................................................................................... 14
What do Alfresco models lack ? ..............................................................................................................14
Definition of invariants............................................................................................................................14
Files of invariants ....................................................................................................................................16
Downloading of invariants ......................................................................................................................19
Invariants processing...............................................................................................................................20
Criteria language .....................................................................................................................................20
2
Alfresco ECM Citeck EcoS
Alfresco ECM system allows it by the means of content modeling function. Alfresco administrator sets
models (XML files), in which data types and their attributes are defined. The attributes also have some
characteristics (mandatory status, default value etc.), which are also set during the modeling.
3
Alfresco ECM Citeck EcoS
<model name="letters:lettersModel"
xmlns="http://www.alfresco.org/model/dictionary/1.0">
<author>Citeck</author>
<version>1.0</version>
<imports> </imports>
<namespaces> </namespaces>
<constraints> </constraints>
<types> </types>
<aspects> </aspects>
</aspect>
Mandatory elements of a model are name, xmlns and namespaces. Practically, each model also has
imported name spaces (imports) and type (types) or aspect (aspects) definitions, for which this model
is intended.
Types
The model allows definition of data types (types). For example, Incoming document type can be
defined. For the type properties (e.g. reference number) and associations (e.g. contractor), as well as
aspects (e.g. classified) can be defined.
Each object is defined by one (and only one) type (i.e. an object cannot be an incoming document and
an order simultaneously). However, parent type (parent) is always specified for the type, which inherits
all its properties, associations and aspects.
Types are allocated in types section of the model. name is a mandatory element for type definition;
practically, each definition includes also parent, other elements can be omitted. Each type definition
has the following aspect:
4
Alfresco ECM Citeck EcoS
<type name="letters:income">
<title>Incoming</title>
<description>Incoming Document</description>
<parent>idocs:doc</parent>
</type>
Along with data type, it can be specified in a model, if the property (association) is mandatory
(mandatory) and if the property (association) can contain multiple values (multiple, many). For
properties, default values (default), constraints (constraints) and index control directives (index) can
be specified.
Definitions of the properties are listed in properties section of the model. Mandatory elements of
property definition are name and type, other elements can be omitted. Example:
<property name="letters:deliveryMethod">
<title>Delivery Method</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>false</multiple>
<default>express</default>
</property>
Definitions of the associations are listed in associations section of the model. Mandatory elements of
each association are name and target.class. In the field target.class the required type or aspect of
the target object shall be specified. Practically, absence of constraints for a source object
(mandatory=false, many=true) are also specified.
5
Alfresco ECM Citeck EcoS
<association name="letters:addressee">
<title>Destinee</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>idocs:contractor</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
Elements source and target in an association definition stand for two linked objects. An association
can be represented as an arrow linking two objects, then source is from where the arrow comes and
target is where the arrow points. As it is clear from the definition, class shall be assigned for a target
object and shall not be assigned for a source object. The reason is the fact that class for source object is
type or object, in which this association is defined.
Mandatory and Many settings determine arity of the link on each end. Example:
if mandatory = true and many = true, than link arity is: 1*;
if mandatory = false and many = true, than link arity is: 0*;
if mandatory = false and many = false, than link arity is: 01;
if mandatory = true and many = false, than link arity is: 1...1.
Child associations
Each association sets a link between two objects, and this link can be hierarchical of non-hierarchical.
Associations that set a hierarchical link are called child associations, others are called peer associations.
In child associations linked objects are parent and child, in peer associations they are just source and
target object.
6
Alfresco ECM Citeck EcoS
In the model, child associations are located in associations section, like common associations, but
instead of association child-association is written:
<child-association name="cm:contains">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>sys:base</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>false</duplicate>
<propagateTimestamps>true</propagateTimestamps>
</child-association>
In case of child associations, source object stands for parent, and target object for child. The setting
duplicate=false allows activation of name uniqueness control, and the setting
propagateTimestamps=true allows activation of change time stamp propagation.
Aspects
Aspects allow adding supplementary properties and associations, as well as other aspects to the objects.
In this respect, they are similar to types, but, unlike the types, an object can have multiple various
aspects. An aspect can also have parent aspect, but, unlike the types, it is not mandatory. If type names
are usually a noun (order, contract), aspect names are adjectives or verbs (classified, has an author).
Definitions of the aspects are listed in aspects section of the model. Each definition looks similar to type
definition:
7
Alfresco ECM Citeck EcoS
<aspect name="letters:hasDelivery">
<title></title>
<description></description>
<parent></parent>
</aspect>
The only mandatory element of aspect definition is the name. An aspect can be created, which only has
a name; such aspect is called marker aspect. By means of this, objects can be distinguished by presence
or absence of such marker aspect. For example, standard model has an aspect cm:personDisabled,
which is superposed to the object cm:person (user), if it is not active.
If the model uses names from other models (it is an ordinary case), they are imported in the similar
manner in imports section:
Constraints
Constraints can be specified for property values (constraints). The following constraint types are
supported in the models:
8
Alfresco ECM Citeck EcoS
LIST the property shall have a value from the list of allowable values (allowedValues)
MINMAX the property shall have a value not less than (not more than) the preset one (for
numeric properties)
LENGTH the property shall have a length not less than (not more than) the preset one (for
string properties)
REGEX the property shall correspond to a regular expression
Example of a constraint set in the model:
<parameter name="allowedValues">
<list>
<value>snailmail</value>
<value>courier</value>
<value>fax</value>
<value>express</value>
</list>
</parameter>
</constraint>
Constraints can be specified both within the model and within the property, the value of which is to be
constrained. If a constraint is specified within the model, a name is set for it, so that this constraint can
be referred to using this name:
<property name="letters:deliveryMethod">
...
<constraints>
</constraints>
</property>
Redefinitions
Redefinitions allow specification of properties in child types or aspects.
For example, if we have document data type, for which a number property is defined, we can set
this property as mandatory in order child data type, set a default value for it or add a constraint for it.
9
Alfresco ECM Citeck EcoS
<overrides>
<property name="letters:deliveryMethod">
<mandatory>true</mandatory>
</property>
</overrides>
Localization of models
If model operation in one language is sufficient, attributes title and description can be used; they
can be set for all named objects of the model: types, aspects, properties and associations.
<type name="letters:income">
<title>Incoming</title>
<description>Incoming Document</description>
...
If translations of the model to other languages are required, these translations are located in individual
files with extension *.properties one file for each target language.
Properties files are also required for localization of LIST type constraints.
listconstraint.letters_deliveryMethod.snailmail=Mail
letters_lettersModel.type.letters_income.title=Incoming
letters_lettersModel.property.letters_deliveryMethod.title=Delivery Method
letters_lettersModel.association.letters_addressee.title=Destinee
Heritage
It is a frequently appearing task to create the same property (association) in multiple various types.
However, the mechanism of the models allows only one definition of each property (association), in any
type or aspect. Therefore, in order to solve this problem, we have to involve heritage mechanism.
There are two options of property (association) heritage: inheriting from parent type (aspect) with
specification of parent element, or inheriting from mandatory aspects, specifying mandatory-aspects.
The main difference is that the parent type can be only one, and mandatory aspects can be multiple;
that is why aspects are more convenient option for data structuring.
10
Alfresco ECM Citeck EcoS
Downloading models
Actual Alfresco models are stored in RAM memory of the repository, so an XML file shall be downloaded
in Alfresco in order to begin to work. The system offers two options to do this:
<beans xmlns="http://www.springframework.org/schema/beans">
<property name="models">
<list>
<value>alfresco/extension/model/lettersModel.xml</value>
</list>
</property>
<property name="labels">
<list>
<value>alfresco/extension/messages/letters</value>
</list>
</property>
</bean>
</beans>
11
Alfresco ECM Citeck EcoS
http://docs.alfresco.com/4.2/concepts/content-modeling-about.html
http://wiki.alfresco.com/wiki/Data_Dictionary_Guide
http://wiki.alfresco.com/wiki/Constraints
http://ecmarchitect.com/images/articles/alfresco-content/content-article.pdf
In the section below we give some recommendations on modeling based on our experience.
Name spaces
A model can set multiple name spaces.
A good classification of names in spaces contributes to better code quality (it is more readable
etc.)
In a model names can be defined only with the name space defined in the same model.
12
Alfresco ECM Citeck EcoS
It is allowed to define a name from an imported name space, but it can lead to conflicts, if an
object (e.g. property) with the same name is added in other model.
Naming
Names should contain only Latin letters.
Names of type and aspect should differ.
It is recommended not to duplicate names of type (aspect) and associations.
Otherwise CMIS search and therefore integration with many applications wouldnt work.
Conclusions from the above-mentioned information: its better to make all names unique. In
order to achieve this you can develop some system for names formation.
Constraints
It is recommended to avoid creating mandatory constraints (mandatory), especially for
associations.
In case some mandatory association is programmed in a model, it is impossible to create an
object without this association. If this constraint is applied after the creation of object (i.e.
model has been updated), one might be totally unable to work with objects without this
association.
Inheritance
It is mandatory for parent type and should be represented by another type.
Formally it is permitted to create a type without parent type but system will work improperly
with such an object, in the worst case such objects are not available even for a system
administrator.
Parent is not mandatory for aspect. If its set, it should be some other aspect.
In case its necessary to use property (association) in several types, its better to place this
property (association) into a separate aspect and define this aspect as mandatory.
Redefinitions (overrides) are effective only for properties inherited from a type
In order to make a property inherited from aspect mandatory you can use functional of Citeck
EcoS modeling.
13
Alfresco ECM Citeck EcoS
Other
Please dont try to add new primitive data-type (data-type).
At the present moment its impossible to create an object that has a property with non-standard
data-type, there is no exception for data-types which correspond with supported Java class (for
example, a line).
Sequence order of elements plays an important role in models. For example, elements are
placed in a model in the following order: imports, namespaces, constraints, types, aspects.
Detailed information about elements order is in XSD-scheme of models, see the file
modelSchema.xsd. If the order of elements is violated, you cannot read or download the model.
Definition of invariants
Invariant is some kind of affirmation about the attributes characteristic that should be true. An example
of invariant: property Number is mandatory if status of the document is not New. In this example
attribute is Number, characteristic is mandatory, affirmation is mandatory if .
With the help of invariants you can set the following attributes characteristic:
14
Alfresco ECM Citeck EcoS
In addition to characteristics of properties and associations you can control characteristics of such
special attributes as:
javascript
freemarker
criteria
explicit
Languages JavaScript and FreeMarker are common for Alfresco; the system has quite diverse API for
these languages. Criteria language is a search language, its added in EcoS in order to simplify search.
It is an alternative for standard Alfresco languages that are used for search such as Lucene and FTS.
Explicit language is just explicitly set constant values: true, false, free strings, numbers and values
lists.
For example, invariant property Number is mandatory if status of the document is not New can be
easily described in the language JavaScript:
<property name="idocs:registrationNumber">
node.properties['idocs:documentStatus'] != 'new'
</invariant>
</property>
15
Alfresco ECM Citeck EcoS
Its quite easy to describe arbitrary values in javascript, including logical values, numeric values,
repository objects and arrays of such values. Freemarker is more suitable for setting of strings, for
example:
${node.properties["idocs:registrationNumber"]!'/'}
${node.assocs['contracts:contractor'][0].properties['idocs:juridicalTitle']
</invariant>
At the present moment support of the language FreeMarker is still very limited thats why it is
recommended to use the language JavaScript.
For invariants description the subset JavaScript API and FreeMarker API is available:
Description of these properties and methods you can find in the Alfresco documentation open for
public:
http://docs.alfresco.com/4.2/concepts/API-JS-intro.html
http://docs.alfresco.com/4.2/references/API-FreeMarker-intro.html
Properties and methods of access available in invariants allow performing only reading operations, it is
quite enough to set arbitrary expressions for invariants.
Files of invariants
Usage of invariants doesnt mean that you dont need to download models, vice versa, this option is
extended. Invariants are downloaded to Alfresco as separate XML-files that accompany models files.
<invariants xmlns="http://www.citeck.ru/ecos/invariants/1.0">
</invariants>
Instead of the comment <!-- definitions of invariants --> definitions of invariants are listed in
the file in the following way:
16
Alfresco ECM Citeck EcoS
<type name="letters:income">
<association name="idocs:legalEntity">
node.assocs["letters:outcome"][0]
.assocs["idocs:legalEntity"][0]
</invariant>
</association>
</type>
It is written in this invariant that the legal entity of the incoming document (receiver) is equivalent on
default to the legal entity of the outgoing document (sender).
Invariants are placed in the definite area of action (scope) that can be restricted by special elements:
type restricts invariants scope by the type that is defined by name (name);
aspect aspect defined by name;
property property defined by name;
association association defined by name;
properties all properties with the specified type (type), for example, all properties of strings
or all properties in general if the type isnt specified;
associations all associations with the specified type, for example, all associations with users
or all associations in general if the type isnt specified.
In the invariants scope there should be one (and only one) attribute constraint (one of property,
association, properties, associations). Several attribute constraints are prohibited. In the
invariants scope there can be a class constraint (type or aspect), several class constraints are not to be
supported. In case there are no class constraints for the invariant, it is applied to the specified attributes
regardless to the class (type or aspect).
17
Alfresco ECM Citeck EcoS
<type name="type1">
<association name="assoc1">
</association>
<property name="prop1">
</property>
<properties type="d:text">
</properties>
</type>
<property name="prop2">
<type name="type2">
</type>
<aspect name="aspect2">
</property>
All names defined in the attributes name and type should be from namespaces listed in the section
imports. In this section namespaces are listed in a manner similar to the same of models:
In the invariant itself you should specify for what characteristic (on) and in which language (language)
this invariant is written. Expression in the specified language is placed as a text inside the element
invariant.
18
Alfresco ECM Citeck EcoS
node repository object for which the invariant sets the attributes characteristic;
value current value of the attribute;
Other standard objects:
Downloading of invariants
You can download invariants right after start of the server with the help of the bootstrap mechanism
(similar to the models download method). In order to do so in the file *-context.xml please set the
following strings:
<bean parent="invariantsDeployer">
<property name="location"
value="alfresco/extension/invariants/letters-invariants.xml"
/>
</bean>
In the property location you define where the XML-file with invariants is located in relation to the
classpath root (folder tomcat/shared/classes). In the property priority you define priority of the
invariants file. The priority allows redefining of existing invariants in files having higher priority. The
following priorities are supported in the invariants (from the lowest to the highest):
You can use attribute final in the invariant in order to prohibit redefining. Though
final-invariants can redefine other final-invariants.
19
Alfresco ECM Citeck EcoS
Invariants processing
Support of invariants means that in certain parts of the system their values are calculated and taken into
consideration in the logic of documents processing.
For example, when you save a document the following invariants are taken into consideration:
Invariants are also supported in the forms of the system EcoS. Besides, expressions of invariants are
calculated when user fulfills the form, thus, user can see at work all rules written in a form of invariants.
When invariants for a certain attribute of a certain object are calculated improper invariants are cast out
while proper ones are sorted out in the following way:
Criteria language
Criteria is a search language. It is very easy to specify invariants for characteristics value, default,
options in attributes containing references to the repository objects (mainly they are
associations) using this language. Expression in the criteria language is a search request that
includes search criteria. Each criterion consists of three parts:
20
Alfresco ECM Citeck EcoS
<type name="letters:income">
<property name="parent">
</invariant>
</property>
</type>
In this case search is performed on the basis of the special attribute path, the predicate path-equals
(equality of path) and value (value) and includes route to the folder income (Income). Thus, we
determine in what folder incoming documents should be created on default.
21
Alfresco ECM Citeck EcoS
Several criteria can be set in one invariant, in this case all of them should be executed (i.e. logic AND is
used).
Insertions in the FreeMarker language can be added to the value, for example, the following invariants
are set for the properties Type and Kind:
<property name="tk:type">
value="cm:category" />
value="workspace://SpacesStore/category-document-type-root"
/>
</invariant>
</property>
<property name="tk:kind">
value="cm:category" />
value="${node.properties['tk:type'].nodeRef}" />
</invariant>
node.properties["tk:type"] != null
</invariant>
</property>
In other words the following values, possible for the property Type, are subcategories of the special
category category-document-root-type; possible values for the property Kind are subcategories of the
specified Type. In case a type isnt specified, the property Kind isnt relevant.
22