Lifecycle Versus WorkflowContent lifecycle refers to the states or phases that content transitions through over time. A lifecycle can be visually represented using UML or a state transition diagram. Content states act as identifiers that can be used by search. They're also often used to control content access permissions. Additionally, the change of content state can cause actions to be triggered.
Content lifecycles shouldn't be confused with workflows. Workflows are used to manage the processes that occur within and between lifecycles. They model the flow of tasks associated with a process. Very often content will be attached to a workflow and acted on as part of the completion of the tasks that make up the workflow.
It's a best practice to cleanly separate lifecycle and workflow when implementing content management. Workflow typically is the thing that enables content to move through the different states of its lifecycle. But because lifecycles and workflows work closely together, it's easy to focus on building workflows without explicitly modeling the states of the lifecycle.
Very often lifecycle is something that is implicitly modeled in content management systems. In that case, metadata schemas or content models will be extended to include a state variable to track the state of the content. Workflows are then built to update state information as content moves through a process.
Nuxeo Content LifecycleIn Nuxeo the concept of content lifecycles comes prewired as part of the Studio web-based configuration tool. Within Studio you can define the states in the lifecycle and the transition paths between them.
Here is a screenshot from Studio of the default lifecycle state transition diagram. For the default lifecycle, possible states include project, obsolete, deleted and approved.
Using Studio, let's now define a new lifecycle called ReviewCycle with states called Draft, Review, Reject, Available, Obsolete as follows:
This new lifecycle can then be associated with a new document type definition called ReviewType using Studio configuration forms. All ReviewType documents on creation will automatically be associated with this new lifecycle definition. Within Studio, in the definition of the document type, we reference the ReviewCycle Lifecycle as follows:
In this case our new document type is defined as inheriting from the standard File type. We'll make no other changes, other than to define a different label and icons associated with the new document type.
To briefly see how our new document type and lifecycle with states work, we can create a simple demonstration using an Automation Chain that transitions a ReviewType document that is in the initial state Draft to the state Review. Note that the name of the transition between these two states is called to_Review.
Next let's create a button in the UI that the user can press that we can program to change the state of the document. To do that we create a User Action as follows:
Here we've uploaded a new icon of a right-pointing arrow that will be visible as a button to click on that will then run our Automation Chain. Note that we specify that the button should be visible only when a document is in the lifecycle state of Draft. At the bottom of the definition form we specify the Automation Chain that the button is associated with: setReviewLifeCycle.
Now let's run our test. We first create our new document type called ReviewType (label is Review):
On the summary page for the document we can see that the state of the document is initially Draft. Next to the permanent link icon on the document Title header we can see a new icon that we've added that when clicked on will automatically transition the state of the lifecycle to Review.
When we click on this transition icon, the summary page refreshes and the document is then in the Review state. Note that the transition icon button is no longer displayed in the Title.
One more thing we can demonstrate is how easy it is to then programatically locate all documents that are in a specific lifecycle state. We can power up the Nuxeo shell and run an NXQL query against the repository to find all documents that are in the Review state. In our case, it will be just the one we uploaded and transitioned.
We can see that in the next screenshot where we issue an NXQL query. The query finds the document (called Application) that we've just uploaded and transitioned into the Review state.
Select * from Document where ecm:currentLifeCycleState = 'Review'.