Documentation
Add and remove links between elements
Add dependencies to a new element :
<CREATE>
<MEDIA>
<INFO>
<MEDIATYPE>Gallery</MEDIATYPE>
</INFO>
<DEPENDENCIES>
<DEPENDENCY type="mediaContent">
<MEDIA ID="25"/>
<MEDIA ID="26"/>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</CREATE>
Medias 25 and 26 are two existing Pictures that we add in a new Gallery.
Add dependencies on an existing element :
<UPDATE>
<MEDIA ID="12>
<DEPENDENCIES>
<DEPENDENCY type="mediaContent">
<MEDIA ID="25"/>
<MEDIA ID="26"/>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
Notice that any former dependencies of the same type are suppressed and replaced by the new ones. If you want to add a dependency without suppressing the existing ones, do it this way :
<UPDATE>
<MEDIA ID="12">
<DEPENDENCIES>
<DEPENDENCY type="mediaContent" operation="append">
<MEDIA ID="27"/>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
In the same way if you only want to remove a former dependency on an element and leave the other dependencies of this element untouched, you will write :
<UPDATE>
<MEDIA ID="12">
<DEPENDENCIES>
<DEPENDENCY type="mediaContent" operation="remove">
<MEDIA ID="27"/>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
Put an element in the dependencies of another :
A dependency is oriented from the parent to the child, when you assign a dependency on an element, it means it becomes the parent of the other element. In some cases, you'll want the opposite : to mark an element as the child of another.
<UPDATE>
<MEDIA ID="27">
<DEPENDENCIES>
<DEPENDENCY type="mediaContent" mode="reverse">
<MEDIA ID="12"/>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
This query executes exactly the same operation as the previous example (see upper) : the Media 27 is now a child of the Media 12. Notice that in reverse mode, the new child is automatically appended to the other ones, it doesn't replace them.
Additional Information about a dependency
If you want to save information that concerns the relationship between two elements, you can save it in the dependency.
Ex 1: the numbers of items of a certain product in a shopping basket
Ex 2: the number of times a client downloaded a document
<UPDATE>
<MEDIA ID="12">
<DEPENDENCIES>
<DEPENDENCY type="mediaContent" operation="append">
<MEDIA ID="27">
<DEPINFO>3</DEPINFO>
</MEDIA>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
This system is ideal for shopping basket : you create a Basket mediatype , a Product mediatype and you create dependencies between the basket and the products, with the number of items on the dependency.
The DEPINFO field will be returned when you use a SEARCH or a GET. It can be a number or a string.
If you already have saved a number on a dependency and only want to increase it (instead of giving its new value litterally), you can use this notation :
<UPDATE>
<MEDIA ID="12">
<DEPENDENCIES>
<DEPENDENCY type="mediaContent" operation="append">
<MEDIA ID="27">
<DEPINFO operator="++"/>
</MEDIA>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
You can use all the operators available for UPDATE : discover them here.
Ex: <DEPINFO operator="+">9</DEPINFO>
If you need to save a second information, you can use the second field called COMMENT.
<UPDATE>
<MEDIA ID="12">
<DEPENDENCIES>
<DEPENDENCY type="mediaContent" operation="append">
<MEDIA ID="27">
<DEPINFO operator="++"/>
<COMMENT>Made on 2006-05-03</COMMENT>
</MEDIA>
</DEPENDENCY>
</DEPENDENCIES>
</MEDIA>
</UPDATE>
It can be a number or a string.