Automation

Automation Chain

You can use Nuxeo Studio for contributing new automation chain graphically.

This page explains all the details of the necessary Platform contribution (that Studio produces) for an in-depth comprehension of the framework. Reading it is not necessary if you start with Automation.

An automation chain is a pipe of parametrized atomic operations. This means the automation chain specifies the parametrization of each operation in the chain and not only the list of operations to execute. Because of this, when executing an automation chain, you should only specify the chain's name. The chain will be fetched from the registry and operations will be executed one after the other using the parametrization present in the chain.

Chain contribution is done via the Nuxeo extension point mechanism. The extension point name is chains and the component exposing the extension point is org.nuxeo.ecm.core.operation.OperationServiceComponent .

Here is an example of a chain extension:

  <extension target="org.nuxeo.ecm.core.operation.OperationServiceComponent" point="chains">
    <chain id="downloadAllChain">
     <param type="string" name="chainParameterName">chainParameterValue</param>
     <operation id="Context.FetchDocument"/>
      <operation id="Context.SetVar">
        <param type="string" name="name">aoname</param>
        <param type="object" name="value">expr:@{Document["dc:title"]}</param>
      </operation>
      <operation id="Document.GetChildren"/>
      <operation id="Blob.Get">
        <param type="string" name="xpath">file:content</param>
      </operation>
      <operation id="Blob.CreateZip">
        <param type="string" name="filename">expr:@{aoname}.zip</param>
      </operation>
      <operation id="Seam.DownloadFile"/>
    </chain>
  </extension>

This is defining a chain that will do the following:

  • Fetching the current document in user interface and setting it as the input of the next operation.
  • Setting a context variable named "aoname" to the value of the input document title. The input document is returned as the input for the next operation.
  • Getting the children of the input document. The list of children documents is returned as the input of the next operation.
  • For each document in the list getting the attached blob (the blob property to use is specified using the xpath parameter) and returning the list of blobs as the input of the next operation.
  • Creating a zip from the input list of blobs. The filename parameter is setting the file name to be used for the zip. The value of the file name is retrieved from the "aoname" context variable that was set before in the chain. Returning the zip blob as the input of the next operation.
  • Showing the download file to download the input zip from the browser (this is a UI operation).

To summarize, this chain gets the current document in the user interface, extracts all blobs from its direct children, zips these blobs and offers to download the resulted zip file in the web browser.

You can see that the chain is specifying in order each operation that should be executed along with the parameter values to be used at runtime. The parameters are either hard coded strings or EL expressions that allow dynamic computation of actual values.

An atomic operation in a chain is uniquely identified by its ID. Each parameter should specify the name of the operation parameter to set (see @Param annotation in Contributing an Operation) and the type of the value to inject. The type is a hint to the chain compiler to correctly transform the string into an injectable Java object.

Since 5.7.2, all chains can contain parameters as operation to be used from the automation context along their execution (such as the chainParameterName which can be fetched from the automation sub-context @{ChainParameters['chainParameterName ']}).

You can find the complete list of the supported types in Contributing an Operation.

Since 5.7.2, it is possible to create "composite operations": putting some chains into chain.

Here is an example of how to contribute this kind of automation chain:

<extension point="chains"
    target="org.nuxeo.ecm.core.operation.OperationServiceComponent">
    <chain id="contributedchain">
      <operation id="contributedchainLeaf" />
      <param type="string" name="messageChain" />
      <operation id="operation1">
        <param type="string" name="message">Hello 1!</param>
      </operation>
      <operation id="operation2">
        <param type="string" name="message">Hello 2!</param>
      </operation>
      <operation id="operation3">
        <param type="string" name="message">expr:@{ChainParameters['messageChain']}</param>
      </operation>
    </chain>
    <chain id="contributedchainLeaf">
      <operation id="operation1">
        <param type="string" name="message">Hello 1!</param>
      </operation>
      <operation id="operation2">
        <param type="string" name="message">Hello 2!</param>
      </operation>
    </chain>
  </extension>

The contributedchainleaf chain is contributed with its operations and is included as an operation into contributedchain. During the execution of this chain, a validation is running to check if all inputs/outputs of the different chains/operations in the stack are matching.

 

Related topics in other documentation

Operations Index Automation How-To Index

Automation chains in Nuxeo Studio

Automation Automation Scripting

4 months ago Andrew Goodricke Updated for 10.10
3 years ago Solen Guitter 18
5 years ago Alain Escaffre 17
5 years ago Solen Guitter 16
5 years ago Alain Escaffre 15
6 years ago Solen Guitter 14
6 years ago Solen Guitter 13
6 years ago Solen Guitter 12
6 years ago Solen Guitter 11 | Fixed formatting and typos
6 years ago Vladimir Pasquier 10
6 years ago Solen Guitter 9
6 years ago Solen Guitter 7 | Added link, formatting, replaced "operation chain" with "automation chain"
6 years ago Solen Guitter 8
6 years ago Vladimir Pasquier 6
6 years ago Vladimir Pasquier 5
8 years ago Solen Guitter 3 | corrected links
8 years ago Solen Guitter 4 | Migrated to Confluence 4.0
9 years ago Bogdan Stefanescu 2
9 years ago Bogdan Stefanescu 1
History: Created by Bogdan Stefanescu

We'd love to hear your thoughts!

All fields required