AnsweredAssumed Answered

Mapping process data to objects

Question asked by k5 on Jul 28, 2014
i really like strong typing, so using a Map<String,Object> for the object data felt errorprone. I sketched around with an orm similar approach to bind the Map<String,Object> to domain specific Task instances (each <userTask /> gets a dedicated class), classes for the ProcessInstance and the variables used in JavaDelegates.

To provide a proper example i created a simple pet project. The code of the example can be found here: https://bitbucket.org/k5_/greenfield/src/tip/strategem/. A live version can be found here: http://strategem.k5.eu/strategem/. Its a little stratego like game where the "who is allowed to do what" is implemented using bpmn. The actual game logic is implemented in java behind JavaDelegates.

Some interessting file:

https://bitbucket.org/k5_/greenfield/src/tip/strategem/strategem-core/src/main/resources/processes/strategem/Game.bpmn20.png?at=default
Screenshot of the process


https://bitbucket.org/k5_/greenfield/src/tip/strategem/strategem-core/src/main/java/eu/k5/strategem/cell/StrategemWorkflow.java?at=default

The initial class that registers/binds the relevant classes for the process.
- Binder inferface defines the allowed variables in the process variables
- Activities registers with @Task classes that are bound to specific taskdefinitionkeys.
  @Start @Data @Aspect do the same for startevent or processinstances
- Servants are used together with a JavaDelegate that forwards serviceTasks to beans that implement the interface.

https://bitbucket.org/k5_/greenfield/src/tip/strategem/strategem-core/src/main/java/eu/k5/strategem/cell/shared/MoveTask.java?at=default
- An example for a @Task, @In fields are read from the processvariables when the instance is retrieved. @Out fields that are written back when the task is completed.

https://bitbucket.org/k5_/greenfield/src/tip/strategem/strategem-core/src/main/java/eu/k5/strategem/cell/shared/StrategemAspect.java?at=default
- An example for a complete ProcessInstance with multiple possible active tasks.


Any thoughts about this approach? Anybody thinks this approach might be useful? Is there a better way of doing certain things? Is it done in a similar way in another workflow engine?

Outcomes