An operation chain is a pipe of parametrized atomic operations. This means the operation chain specify the parametrization of each operation in the chain and not only the list of operation to execute. Because of this when executing an operation chain you should only specify the chain 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 Nuxeo extension 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:
This is defining a chain that will do the following:
- Fetch the current document in User Interface and set it as the input of the next operation.
- Set 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.
- Get 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 get the attached blob (the blob property to use is specified using the xpath parameter) and return the list of blobs as the input of the next operation.
- Create 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 i the chain. Return the zip blob as the input of the next operation.
- Show the download file to download the input zip from the browser. (this is a UI operation)
Briefly this chain is getting the current document in the User Interface, extract all blobs from its direct children, zip these blobs and offer 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 parameter are either hard coded strings either 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.
You can find the complete list of the supported types in Contributing an Operation.