Ressources
Il s’agit d’alimenter automatiquement un champ à partir d’un ou plusieurs autres. Ce type d’abonnement ne nécessite pas de configuration XML spécifique.
La classe d’abonnement a utiliser est com.axemble.vdp.mapping.extensions.ResourceBrowserMappingExtension
.
Here is a subscription definition example based on document data:
<subscription field-id="Field_1" name="onChange" prop-id="" subscription-class="com.axemble.vdp.mapping.extensions.ResourceBrowserMappingExtension">
<action field-id="Field_2" prop-id="" update-mode="both" action-key=""/>
</subscription>
This example indicates that on modifying “Field_1” the field “Field_2” will take the value of “Field_1” since the “action-key” attribute is empty.
Tags
Subscription
The “subscription” element defines the subscription input in XML of the resource template.
Element | Description |
---|---|
field-id | Modified document field and trigger of the “onChange” event. |
name | Name of occurred event |
prop-id | Not available |
subscription-class | Extension class: com.axemble.vdp.mapping.extensions.ResourceBrowserMappingExtension |
On-stage
The “on-stage” element defines the input of a step on which the subscription will be run.
Element | Description |
---|---|
name | System name of the concerned step. The keyword sys_CreationWizard enables to indicate that the treatment will be processed only on the action of process document creation. |
Action
The “action” element defines the input of an action to be performed after an event is triggered.
Element | Description |
---|---|
field-id | System name of the subscribed field |
prop-id | Not active |
update-mode | Document update mode: “frontend”, “backend” ,“both” |
action-key | Property of trigger object obtained by introspection |
The actions
Actions define all the document fields that will be updated when subscription is run. Actions can only be defined at the XML document level of the resource template. It is possible to define 1 to n actions.
The filters
Filters on steps can be placed to restrict subscriptions running on some steps. If no step has been specified, the subscription will be valid at all steps of the document. Filters are defined at the XML document level of the resource template. The on-stage tags can be present from 0 to n times.
Introspection
Introspection will let you access the object’s intrinsic properties. These properties should be accessible through the “get” type methods. Introspection is possible at the “action-key” attribute level of the “action” tag.
Functions
Available formulas
Functions will let you perform calculations on table type fields and also let you access the extended attribute values in fields representing values of directory objects.
Function | Parameters | Concerned classes | Description |
---|---|---|---|
@total(column_name) @TOTAL is still supported |
Column name | Collection | Calculates the total of a table’s number column. Is applicable to a Collection type document field representing a dynamic table. |
@average(column_name) @AVERAGE is still supported |
Column name | Dynamic table | Calculates the average of a table’s number column. Is applicable to a Collection type document field representing a dynamic table. |
@get(key) |
Key of map element | Map | Is applicable to a Map type document field representing values stored of a JSP Browser. It lets you retrieve the value of a key. |
@toDirectoryElement(field_name) |
Field name | User, Group, Organization | Builds a DirectoryElement type object from a string stored in another field. Is applicable to a DirectoryElement type document field. |
@getOrganizationAttribute(field_name) |
Attribute name | String | Retrieves an extended attribute of an organization. Is applicable to a Character string type document field representing the name of an organization. |
@getLocalizationAttribute(field_name) |
Attribute name | String | Retrieves an extended attribute of a localization. Is applicable to a Character string type document field representing the name of a localization |
@getUserAttribute(field_name) |
Attribute name | String | Retrieves an extended attribute of a user. Is applicable to a Character string type document field representing the user login |
@trunc(value,endIndex) |
String End index | String Integer | Truncates the element content by the number of characters specified by ‘endIndex’. Applies on a document field of characters string type or on another function recovering a character string. |
@copy(field_name) |
Field name | String | Get the property back and copy its content in the subscribed field. Types must be similar. |
@toString(field_name) |
Field name | String | Get the property back and convert its content in the character string. |
@concat(value1,value2,value3,…) |
String list | String | Do the concatenation of the elements given as parameters. valueX can be :
|
Exemples
Exemple 1
<subscription field-id="Field_0" name="onChange" prop-id="" subscription-class="com.axemble.vdp.mapping.extensions.ResourceBrowserMappingExtension">
<action field-id="Field_1" prop-id="" update-mode="both" action-key="@copy(Field_2)"/>
<action field-id="Field_3" prop-id="" update-mode="both" action-key="@toString(sys_CreationDate)"/>
<action field-id="Field_4" prop-id="" update-mode="both" action-key="@concat(Field_5,'-',@toString(sys_Reference))"/>
</subscription>
On the modification of the “Field_0” field:
- The “Field_1” will get the content of the “Field_2”.
- The “Field_3”, which must be text-type, will get the content of the “sys_CreationDate” field (document creation date) changed in string.
- The “Field_4”, which must be text-type, will get the concatenation of the “Field_5” content,text-type too, of the “-” character string and of the content changed in string of the “sys_Reference” field (document reference).
Exemple 2
Soit un processus de gestion des notes de frais. On a un tableau de ressources dans lequel nous stockons des lignes de frais. Chaque ligne intègre bien sûr un montant (on a donc bien sûr une colonne “Montant” dans le tableau).
On souhaite copier dans le champ du document principal “Montant total” la somme de tous les montants de toutes les lignes de frais du tableau.
On positionnera cet abonnement au niveau du modèle de ressources du document principal et non au niveau du champ tableau.
<subscription field-id="MyTableField" name="onChange" subscription-class="com.axemble.vdp.mapping.extensions.ResourceBrowserMappingExtension">
<action field-id="MontantTotal" throw-events="false" update-mode="both" action-key="@total(Montant)" />
</subscription>
Source : https://wiki.myvdoc.net/xwiki/bin/view/Dev+Floor/ResourceSubscription