Regulate the Complexity of Nuxeo Studio for Your Users
I met this week Jack (not the real name) one of our System Integrators tech lead for a projects review. Agenda of such a meeting is pretty simple: we review and debrief each project Jack has recently worked on on both functional and technical angles. It's a win-win meeting : we alert on features the platform already provides and that Jack has missed, while Jack gives us feedback and ideas of improvements on the platform and finally we identify potential contributions from Jack's work.
One of the points of the discussion on this meeting was about the use of Automation. Jack explained to me that while automation is great for many things, sometime it is simpler to just produce a Java class than to try to chain too many operations. I obviously agreed on this point. He then explained to me what the value of the use of the duo Automation+Studio was for him: better controlling the flexibility of the app he delivers to his customer. He tries to expose most of the customization (both automated rules and user actions) as chains that use custom operations to simplify as much as possible the logic exposed to the Studio user while offering a certain level of flexibility (defined with the customer) through the custom operation parameters. That way, the customer feels comfortable to change / reuse what he needs, just adapting the parameters. That's a great vision !
To help clarify all this for Nuxeo beginners, I now give a few more details on Automation and Studio and illustrate Jack's way of using it.
Nuxeo Automation is a Nuxeo module that exposes Nuxeo API as a set of "operations". An operation is an instruction with a set of parameters. An operation is executed in a context and accepts an object or a list of objects as input. Nuxeo Platform comes with a complete library of operations (more than one hundred) so as to process documents and files: Move, Copy, Update Property, Export File, Convert in PDF, … Operations can be gathered so as to compose a "pipe", called in Nuxeo terminology a "chain". If I want to update the title of a document then move it in a specific folder and finally export the PDF conversion, I can write a chain that uses first Update property, then Move, then convert in PDF then export File. And I associate my chain to a user action that will display a button in Nuxeo DM interface.
The automation chain is edited in the Studio visual environment, just by dropping each operations in the pipe.
Main advantages of using automation for such a use case stems from the fact that automation programming is declarative (Studio generates XML) and as a consequence:
- easy to maintain (Studio is in charge of this)
- easy to handle for non developers (no compilation cycle, etc…)
Automation is also interesting because it provides complete web service API, but this is not the topic of this post.
As Jack mentioned, the fact that automation operations are gathered in a pipe where all the operations shares a same context might sometime lead to some cumbersome logic (especially when you need looping and conditional) while you feel, as a developer, that a simple Java class does the work. The framework actually allows to implement custom operations and load them in Nuxeo Studio so as to use them with user actions, triggers and workflows. So it is easy to implement your own behavior in a custom operation with some Java code, and let this behavior be customizable by a Studio user by using parameters on the operation. In our previous example, as a SI, I could have written an operation that does all the actions in Java and just expose as a parameter the path where to move the document and the path where to export the PDF. The customer would then be able to use and re-use this operation where he wants, etc … just changing the various path, which is safe and simple.
Of course, this leads to more custom Java code than in the initial solution. To minimize the custom code, it would be possible to implement an operation with the two parameters and call a subchain that does all the thing using existing operations only… As you can see the framework doesn't constrain you much, you can refine your strategy!
Category: Product & Development