jBPM - passing additional information to process or a task
npacemo Sep 7, 2008 4:01 PMI'm trying to implement the following requirements for a hotel booking system:
- administrators should be able to mark hotels for deletion
- if there are associated bookings with the deleted hotel, the admin should notify the booking user about his booking cancellation, so in order to track this notifications I wanna introduce a TODO-list with tasks that need to be done
- on task completion if all bookings are already canceled (the interested user is notified), the hotel is deleted permanently
I want to use jBPM to represent the process with TODO-tasks, so basically I'm trying to step on the seam-todo example, but in order to achieve my goals I need to do the following:
- when I mark the booking for cancellation I'm raising an event 'bookingCancelScheduled';
for (Booking booking : deleted.getHotelBookings()) { events.raiseEvent("bookingCancelScheduled", booking); }
- the observer of this event should configure and start (this is hard part for me) a task part of a process;
- when done an event is raised to notify if the hotel is ready for permanent deletion;
What's the proper way to configure and start a task?
Let's take for an illustration the TodoList-bean from the seam-todo source with some modifications:
@Name("todoList") public class TodoList { private String description; @Observer("bookingCancelScheduled") public void scheduleBookingCancel(Booking booking) { // When I get this event I need to set the description of a task, // and attach the booking to the task, so when the task is done // to retrieve the booking back and to process it. // Start the process - just calling the createTodo() ain't gonna work } @CreateProcess(definition="todo") public void createTodo() { // What's needed to be done here??? } @StartTask @EndTask public void done() { // How to obtain the done-task in order to get the passed variables? } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }
There isn't much information in the Seam Community Documentation about more advanced usage of jBPM. Looking at the jBPM documentation can't help me much, because I want to use the most of what Seam can offer (well at least I found out I can really attach data to a task with the help of the variables-map property of TaskInstance).
If someone has any clues please let me know!
Best regards,
Vladimir Tsvetkov