Workflow & BPM

Table of Contents

14.1. Introduction
14.2. Architecture
14.2.1. Big picture
14.2.2. Nuxeo Core Workflow
14.2.3. Nuxeo Workflow Document API and services
14.3. Deploying process definitions
14.3.1. Using extension points
14.3.2. Using the workflow POJO service
14.3.3. Using EJB remoting
14.4. Nuxeo Core document integration
14.4.1. Security policy
14.4.2. Application level rules and filters
14.5. Document Versioning
14.5.1. Setting the version of a document
14.5.2. Modifying automatically the version of a document
14.5.3. Accessing document from previous version
14.5.4. The versioning service implementation
14.6. jBPM integration
14.6.1. Process definition deployment
14.6.2. Business handlers and Nuxeo Core integration
14.7. Nuxeo Workflow Web Client
14.8. Auditing workflow related events
14.9. Notification on workflow related events
14.10. Example of a document review process

14.1. Introduction

TODO

14.2. Architecture

TODO

14.2.1. Big picture

14.2.2. Nuxeo Core Workflow

14.2.3. Nuxeo Workflow Document API and services

14.3. Deploying process definitions

A workflow definition is designed for a given workflow engine backend and not for the Nuxeo workflow service itself. Nuxeo workflow doesn't specify a new process definition language. Thus it has no Nuxeo specificities speaking of format or process definition language. For instance, if you use jBPM as a backend with Nuxeo 5 then the workflow definition should be a standard jpdl file that you may have designed using your favorite editor or still if you are using Shark as a backend then the workflow definition will be a standard WFMC process definition.

Once your workflow definition has been designed and is ready you can deploy it in Nuxeo workflow. Of course, the target workflow engine backend plugin should be deployed and registered against the workflow service.

14.3.1. Using extension points

The Nuxeo workflow service provides a dedicated extension point for workflow definition deployment. The extension point is called definition.

In this case, the workflow definition will be deployed at application server deployment time (For now, this is the case when the application server is starting up since hot deployment is not yet possible using Nuxeo Runtime at the time of writing this document).It means this way of deploying workflow definition is not suitable for all cases. See the next subsections for other ways of deploying workflow definitions.

Below is an example of a jPDL workflow definition contribution for the jBPM backend. This XML fragment would be defined in a contribution registered as a component in a bundle:

<?xml version="1.0"?>

<component name="com.company.workflow.sample.contributions">

  <extension target="org.nuxeo.ecm.platform.workflow.service.WorkflowService"
             point="definition">
    <definition>
      <engineName>jbpm</engineName>
      <mimetype>text/xml</mimetype>
      <definitionPath>workflows/process_definition.xml</definitionPath>
    </definition>
  </extension>

</component>    
  • engineName: name specified for the target backend at workflow service registration time (see workflow service backend extension point)

  • mimetype: mimetype of the workflow definition. This is especially interesting in case of the format is binary. (serialization issue at deployment time)

  • definitionPath: bundle relative path of the workklow definition to deploy.

In this situation here is how would look the tree:

com.company.workflow /
  META-INF /
    workflows /
      process_definition.xml
      MANIFEST.MF
  OSGI-INF /
    workflow-definitions-contrib.xml

14.3.2. Using the workflow POJO service

TODO: provides code sample

14.3.3. Using EJB remoting

TODO: provides code sample

14.4. Nuxeo Core document integration

TODO

14.4.1. Security policy

14.4.2. Application level rules and filters

14.5. Document Versioning

14.5.1. Setting the version of a document

The versioning information are stored in the DocumentModel under the fields major_version and minor_version of the uid.xsd schema. Set the version as you would any other field:

documentModel.setProperty("uid","major_version",1);
documentModel.setProperty("uid","minor_version",1);

The field used for version is adaptable via the properties extension point of the org.nuxeo.ecm.platform.versioning.service.VersioningService component. It allows to define which properties should be used to set versions for a given document type.

<versioningProperties>
  <majorVersion>my:major_version</majorVersion>
  <minorVersion>my:minor_version</minorVersion>
  <documentType>File</documentType>
  <documentType>Note</documentType>
</versioningProperties>

14.5.2. Modifying automatically the version of a document

Event such as saving a document or following a life cycle transition can change the document's version number. To use this feature you need first to define which event should be listened to and then how the version number should behave.

The CoreEventListenerService is used to define which event to listen to. The default declaration is in nuxeo-platform-versioning-core:

<listener name="versioninglistener"
    class="org.nuxeo.ecm.platform.versioning.listeners.DocVersioningListener">
  <eventId>lifecycle_transition_event</eventId>
  <eventId>documentCreated</eventId>
  <eventId>beforeDocumentModification</eventId>
  <eventId>documentUpdated</eventId>
  <eventId>documentRestored</eventId>
</listener>
<listener name="versioningChangelistener"
  class="org.nuxeo.ecm.platform.versioning.listeners.VersioningChangeListener" />

The class org.nuxeo.ecm.platform.versioning.listeners.DocVersioningListener implements the behavior of the versioning when those events happen.

To modify the version of a document when a life cycle state is reach you need to define rules with the behavior(increment major, minor or do nothing) using the extension rules from org.nuxeo.ecm.platform.versioning.service.VersioningService:

<versioningRuleEdit name="sampleEditRuleProject" action="ask_user"
    lifecycleState="project">
  <option value="no_inc" default="true" />
  <option value="inc_minor" />
  <option value="inc_major" />
</versioningRuleEdit>

The default behavior for all type but File and Note is to increase the minor version for each life cycle change. You need to override one of the default rules if you add a new type. The order is important, the list of rules is read and the first match is used.

<versioningRuleEdit name="sampleEditRuleAnyState" action="ask_user"
      lifecycleState="*">
  <includeDocType>File</includeDocType>
  <includeDocType>Note</includeDocType>
  <includeDocType>MyNewType</includeDocType>
  <option value="no_inc" default="true" />
  <option value="inc_minor" />
  <option value="inc_major" />
</versioningRuleEdit>

14.5.3. Accessing document from previous version

The CoreSession or the seam component documentVersioning and versionedActions allow to access document from previous version. On CoreSession, the method getVersions return all the versions of a document.

14.5.4. The versioning service implementation

The versioning service manages the version inside Nuxeo. Two implementations are available:

  • The custom Nuxeo service, more flexible and used by default

  • The default JackRabbit implementation.

To modify this setting edit the file config/default-versioning-config.xml:

<!--property name="versioningService" value="org.nuxeo.ecm.core.repository.jcr.versioning.JCRVersioningService"/-->
<property name="versioningService" value="org.nuxeo.ecm.core.versioning.custom.CustomVersioningService"/>

This section shows how to use the versioning module, how to modify the version of a document automatically or manually and how to use a document from a previous version.

14.6. jBPM integration

TODO

14.6.1. Process definition deployment

jBPM comes with a simple servlet allowing one to deploy jPDL process definitions and monitor running process instances. (NB: this is not yet activated on stock Nuxeo 5 instance).

14.6.2. Business handlers and Nuxeo Core integration

14.7. Nuxeo Workflow Web Client

TODO

14.8. Auditing workflow related events

TODO

14.9. Notification on workflow related events

TODO

14.10. Example of a document review process

TODO