Right now, I donβt think step-by-step instructions will help you implement the Grails Activiti plugin. I am in a similar boat (a development store using Grails that would like to implement a workflow mechanism), and so far the Activiti plugin has not been really useful. Those who use it do not actually use the integration that it provides between GORM and Activiti .
In general, here are the steps that I would recommend using Activiti in Grails; you could take or leave the Activiti plugin.
- Create an Activiti engine in your database . If you use the H2 database in memory and let Grails do the create / drop statements, you may need to add h2 scripts to your application startup process.
- Map the process you want in your Grails application to the XML format of BPMN 2.0. You can use Activiti Eclipse Designer , which will be perfectly connected to GGTS, launch Explorer Activiti somewhere and use a web designer or raw XML code to your own bad self.
- Enable Activiti as a dependency in the Grails app. You can do this by turning on the Activiti Grails plugin in BuildConfig.groovy or simply by turning on the Activiti core jar as an independent dependency (see below).
- Use the Activiti API calls (preferably from Grails) to deploy your process model, run individual instances of the process (s), and navigate through the various stages of the workflow.
- You may need to pass information about your Grails domain objects as process variables, and then output them again. Tempting where to let Grails store data in a domain object, and where to get Activiti to save it as a process variable, just think about the developer part.
Typically, my rule of thumb is to let Activiti handle this process, and Grails handles everything else (user interface, data persistence and manipulation, validation, etc.).
I recommend this approach so that you can still use Grails to control the entire user interface through controllers and GSPs and most of the object model through domain objects and services. There is nothing wrong with the user interface created by the Activiti team, but it is based on Vaadin , which is its own Java / UI infrastructure with its own character and philosophy. I am sure that the super-developer could combine them without problems and probably already had them, but if he / she does not go down the mountain and does not teach me, I will have to limit the number of tools that I will try to master immediately. :)
How to enable Activiti as a dependency
Your BuildConfig.groovy file in your dependencies and repository repositories has the following:
repositories { inherits true // Whether to inherit repository definitions from plugins mavenRepo "https://maven.alfresco.com/nexus/content/groups/public/" //any other repositories you need go here, including grailsCentral(), etc. } dependencies { compile("org.activiti:activiti-engine:5.13"){ excludes "spring-beans" } }
You do not need to rule out spring-context dependencies, but Grails 2.3.1 uses a later version of Spring than Activiti 5.13. On 2/3 machines, I tried this, it is fine, and Grails just uses a later version of Spring, ignoring the old Activiti required. However, on one machine, the difference caused an opaque exception that was difficult to track .