In the following blog post, I have highlighted the matter of embedding Activiti BPMS inside a Liferay Portal. With Activiti Explorer built in Vaadin and Spring, it is fairly easy to use entire components in a totally different environment.
Proof of concept fork with Tasks and Admin portlets is available in
https://github.com/tlipski/Activiti/tree/master/modules/activiti-portlets.
Porting Activiti Explorer to Liferay Portal
Activiti is a popular Open Source, BPMN2.0-compliant BPMS that provides a great overall package. Not only there is a library that can be embedded inside your application, but Activiti also comes with an Explorer web application, which provides an ergonomic user interface for basic operations:
But, Activiti is "just" a BPMS - you can run your processes with it, maybe even connect to Active Directory, Alfresco or ESB - but if you want to embed it in your intranet/extranet portal, you are almost on your own.
Please note, that embedding Activiti in portal is not the same as using it to manage portal assets - for example, as a replacement for Liferay's Kaleo Workflow. The matter discussed here is more focused on using all of Activiti features, including user interface.
Luckily, this is when frameworks used in Activiti pay off - Activiti Explorer is written in Vaadin 6 and Spring. With component oriented approach from Spring and UI modularity encouraged by Vaadin, it is fairly easy to port this application to Liferay. We can extract entire components from Activiti Explorer (e.g. Tasks panel) and use them in a whole new environment.
Extracting and re-using entire components requires much more work in a classical MVC approach and even may not always be possible. Also, portlet support in Vaadin makes a whole task much more pleasant.
Extracting and re-using entire components requires much more work in a classical MVC approach and even may not always be possible. Also, portlet support in Vaadin makes a whole task much more pleasant.
For the impatient: The code is available in my fork of Activiti 5.13-SNAPSHOT: http://github.com/tlipski/Activiti, especially in activiti-portlets module https://github.com/tlipski/Activiti/tree/master/modules/activiti-portlets.
Necessary steps
"Fairly easy" does not mean without any effort. There are differences between a standard Vaadin application and a portletized one:
- Portlet descriptors are necessary
- GUI should be divided into separate portlets
- Spring-Vaadin integration is different due to a portal-specific request life-cycle
- Navigation can be provided by portal - including friendly URLs, which makes for a more standard user experience.
In addition to that, some mechanisms used by Activiti are already provided by Liferay Portal and we need to bridge them:
- Users and Groups should be managed by Liferay Portal
- Authentication data should be taken from a portlet container
- Mail notifications could possibly use Liferay Mail API
Some other things have to be taken into account as well:
- Distribution and management of Vaadin widgetset and version - we should use Vaadin Control Panel portlet and Liferay to manage Vaadin dependencies. This requires special handling, since Activiti Explorer 5.13 utilizes dCharts Vaadin Add-on.
- Vaadin theme used in portlets - which is also customized by Activiti, but should be coherent with portal's look & feel.
Current state of work
It is nice to theorize, but certain things need to be verified in practice. At this moment, my fork at http://github.com/tlipski/Activiti provides:
- Activiti Tasks portlet, which works in a user's context as if the user would log in to Activiti Explorer app. The portlet provides full functionality, including operations as starting a new task, fetching it from a task list, displaying task's events, assignment/ownership transfers, file attachments and so on.
- Activiti Admin portlet in Liferay Control Panel - most tabs seem to work fine - except Users and Groups, which should be disabled as we are using Liferay Portal to do that.
Implementation details:
On the implementation side, most noteworthy changes which have been implemented in activiti-portlets module: https://github.com/tlipski/Activiti/tree/master/modules/activiti-portlets are:
- IdentityProvider implementation utilizing Liferay API (need to work on user photos though!)
- Spring-Vaadin bridging for portal (see my previous post).
- Custom portlet applications and main Window class. The interesting detail here is that with Vaadin portlets, you should not set width of components to 100%, as it will result in 0px height. Generally speaking, the height in Vaadin portlet components should be set to undefined - null, or a preset value in pixels.
Next steps?
Connecting Liferay with Activiti brings a myriad of new possibilities, but before that, some basic things need to be done:
- More portlets! Reporting and Processes tabs need their respective portlets, but also "start process" portlet might be worth considering since we can manage UI contents in a more flexible way.
- More testing! If anyone is interested in testing Activiti portlets in Liferay, let me know and I will provide prebuilt applications. So far, I've used Liferay 6.1 GA2 CE and H2 in-memory database for Activiti.
- Friendly urls - especially for tasks resolved by id, and for interportlet communication - e.g. when starting a process.
I want to add activiti explorer with in liferay itself.
ReplyDeleteso how i can integrate it.
Hi,
ReplyDeleteThat's what the post is about. But if you need to use Activiti instead of Kaleo for example to manage portal assets (e.g. Web Content), you can might be able to do that using http://www.emforge.net/web/activiti-liferay
I can not build with maven because i get these error:
ReplyDeletePlease refer to D:\gitRepo\Activiti\modules\activiti-engine\target\surefire-reports for the individual test results.
Is there some war file available to deploy it directly into my liferay installation?
Reinaud - the regression tests should pass correctly, have you checked what's in surefire-reports? You can always skip them with -Dtest.skip=true option to maven.
ReplyDeleteAfter a successful build, a war file should appear in modules/activiti-portlets/target/.
Thanks for your reply. You did a great job!
ReplyDeleteBut I'm now facing the problem that some of my liferay Groups are sites. I don't want them in the Activiti portlet. My question is where did you do the selection of the Groups?
Thanks in Advance!
Well, please remember that this a PoC only rather than actual production-ready code.
ReplyDeleteAll of the modifications to activiti are in activiti-portlets module - I had some other ideas along the way, but now it seems to be cleared and just in activiti-portlets: https://github.com/tlipski/Activiti/tree/master/modules/activiti-portlets
The actual Liferay API<->Activiti interaction is placed in org.activiti.portlets.explorer.interop.liferay package:
https://github.com/tlipski/Activiti/tree/master/modules/activiti-portlets/src/main/java/org/activiti/portlets/explorer/interop/liferay
And Liferay group queries are implemented in LiferayGroupQueryImpl.java:
https://github.com/tlipski/Activiti/blob/master/modules/activiti-portlets/src/main/java/org/activiti/portlets/explorer/interop/liferay/LiferayGroupQueryImpl.java
You can just add any customization over there.