Here is the source code:
Here is an explanation, how we integrate Play with Activiti plus spring and hibernate!
Play! contains JPA and JDBC plugins.
But unfortunately they are not compatible with the way activiti initializes.
But , fortunately, Play allows replacing of plugins by 3-d party JPA and JDBC libs.
At the end, entire stack runs on Spring.
1. we drop Play’s jpa and jdbc support (see what dependencies I have in the /build.sbt instead)
2. We create class Global and instrument it to load the application context with all the goods of Activiti
3. DB connection specified in the application-context.xml
(note, you must install H2 database and start it before you start the app, see that DB connection string matches that of DB)
4. see conf/custom-persistence.xml to understand how I configure persistence
5. in file conf/routes notice 2 activiti relative user actions, which actually required user actions to advance the business process:
# Activiti user actions
POST /computers/saveproposal @controllers.BusinessProcessController.saveProposal()
POST /proposals/:id @controllers.BusinessProcessController.approve(id:Long)
6. see how I defined the BP in the conf/addCompRequest02.bpmn20.xml
Basically it consists of 1 gateway and 2 user tasks plus one service task.
It is a decision. If proposed computer name starts from “Apple”, then request to store it approved automatically.
Otherwise – leave it to manual approval.
7. Note class BusinessProcessController, it runs all the process logic:
a) it has 2 UI relative actions
b) it has 3 operations, invoked from the business process itself (see comments there)
8. If you open browser at localhost:9000 you will see a list of computers (initially empty)
9. If you press on “Watch available propositions from clients” you will be traveling to another window.
10. here press the “Add a new computer proposal” button.
In the new window fill the form.
Press “Propose this computer” button.
The comp will be added to the table “Computer_Proposal”
If name of the comp you entered starts from “Apple”, then this comp will be automatically added to table “Computer” and deleted from the table “Computer_Proposa”
This is the rule of the business, described in the exclusive gateway and flows.
If the comp has different name, than “Apple*”, then approval is a User Task (In Activiti way).
For its approval you need press red button “Approve!” in the row of a table of proposed computers.
Then if you return to the / URL, you will have all approved computers appearing in the table.
Looking for cross-platform e-mailing solution for your e-commerce?
Written in scala, open-source, sexy-templates, PHP, Java,.Net site friendly?
Here is the one you can easily and for free integrate in your domain: