Home

When we think about Content Management Systems and all of the content stored in that, or going to be stored there, it is some or other type of relations between a few of those contents. So, how do you deal with those kinds of relationships? Alfresco has associations to manage this issue!

Example of Out of box association is Folder and all contents residing under particular folder. If you observe below entry of folder content type within Alfresco contentModel.xml there is a child-association named “cm:contains” is available, So whenever we upload any new content to alfresco folder internally it creates this child association between new content and existing folder nodeRef

Here Parent Node= Folder Node

Child Node= Content Being uploaded

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<type name="cm:folder">
         <title>Folder</title>
         <parent>cm:cmobject</parent>
         <archive>true</archive>
         <associations>
           <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>
         </associations>
     </type>

Importance of Association

Associations have very important role in maintaining integrity of Repository and able to handle inter relationship between multiple contents.

Primarily there are two types of associations

  • Parent-Child Association

In this type of association one node act as parent and other node act as child node when associated with each other.

  • Normal Association

In this type of association both associated nodes are only associated with given association type It is also called as peer to peer association.Associations are always between two types a source type and a target type where the source type is inherently the type that defines the association. The only feature of an association that must be specified is its target type via the class element on the target end.

Fine-tune each end of the association by specifying features such as cardinality via the mandatory and many elements:

  1. 0 or 1 => mandatory = false and many = false
  2. 1 => mandatory = true and many = false
  3. 0 or more => mandatory = false and many = true
  4. 1 or more => mandatory = true and many = true

 

How to Define Association in Content Model?

For more details on creating custom content model you can refer previous articles on

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<associations>
    <association name="custom:relatedImages">
            <title>Thumbnail Image</title>
            <source>
                <mandatory>false</mandatory>
                <many>true</many>
            </source>
            <target>
                <class>cm:content</class>
                <mandatory>false</mandatory>
                <many>true</many>
            </target>
      </association>
    <child-association name="custom:childnodes">
                <source>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </source>
                <target>
                    <class>cm:content</class>
                    <mandatory>false</mandatory>
                    <many>true</many>
                </target>
                <duplicate>false</duplicate>
                <propagateTimestamps>true</propagateTimestamps>
            </child-association>
</associations>

 

As we can see in above example of custom association defined in custom content type in new model there are few attributes which are very important.

In target tag we can manage dependency of source and target, allowing control over whether a transaction can commit or not based on missing associations. As per value of “duplicate” flag child nodes of same are allowed to associate with parent node.

Hope this gives good insight about associations in alfresco.

Further Reading:

http://blog.arvixe.com/content-modeling-in-alfresco/

http://docs.alfresco.com/4.2/concepts/metadata-model-assoc.html

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Publicités

Laisser un commentaire

Choisissez une méthode de connexion pour poster votre commentaire:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s