cancel
Showing results for 
Search instead for 
Did you mean: 

Clarification Please between Types and Aspects

arnieaustin
Champ in-the-making
Champ in-the-making
Between the online docs and the several books I have, I am now completely and thoroughly confused.

I have created types and aspects to apply to these classes but I'm not entirely sure that is what I want to do. But then again maybe it is?

I really like the concept of an Aspect - the ability to add meta data to an already existing object. The types I created were good examples but DO I really need to create an entire new type in Alfresco when all I want to do is apply those same fields to existing content? (Hence this Aspect question.)

So, I commented out the types in my model file and moved the properties down to the aspects - because I saw an example with them. But is that the right way to do this?

So I guess my questions are:

1) Do I have to create types if all I want to do is add fields to existing objects (cm:content)?

2) If so, does an aspect HAVE to have an association if I want to be able to apply it to anything?

3) Searching: will I be able to search on said metadata if it is only part of an aspect and not part of a type?

Does any one have such an example?

Thanks in advance!
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
Ways types and aspects are the same:
<ul>
<li>Both are modeled using XML.</li>
<li>Both are ways to define properties and associations</li>
<li>Both are ways to extend the out-of-the-box content model</li>
<li>Properties defined in types and aspects are indexed by default</li>
</ul>

Ways types and aspects are different:
<ul>
<li>An object can only be of one type whereas an object can have multiple aspects</li>
<li>An aspect can be removed from an object</li>
<li>When you create an object, you must select a type. Aspects can be added to an object later in its lifecycle.</li>
<li>CMIS 1.0 lacks native support for aspects. There are extension projects that can be used to work with aspects via CMIS. CMIS 1.1 supports aspects through something called "Secondary Types". CMIS 1.1 is not yet a fully-ratified spec.</li>
<li>Types inherit from one and only one parent. Therefore if you have a property you'd like to have in multiple places in your content model, you have to either define it twice or place it in a common ancestor type. If that property was in an aspect, you could add it where it is needed</li>
</ul>

It can be hard to decide whether to model something as a type or an aspect. You could use cm:content for everything and then use aspects for all of your custom metadata. You could use types for everything and never use aspects (although you may end up with some repetition in your model or unnecessary properties which is something aspects are designed to eliminate).

Aspects are commonly used for "common characteristics". Think about an image. The characteristics of an image (height, width, resolution, etc.) are the same regardless of the type of image (headshot, scanned document, corporate logo). So the metadata for an image makes a lot of sense to put in an aspect.

There is no strictly right or wrong answer. Hopefully this has given you a few things to think about as you decide what works best for your solution.

Jeff