2018/04/24

jBPM Work Items repository tips + tricks

In his previous post, Maciej showcased the updates to the jBPM Work Items module and how easy it is now to get up and running with creating new workitems and start using them in your business processes right away.

In this post I wanted to leverage on what Maciej showed and add a couple of cool features that the jBPM Work Item repository gives you out of the box, specifically related to the repository content generation.

1. Skinning
By default the work item repository generates static content including all workitem info, documentation and download links. Here is what they look like out of the box:

1. Default repository index page

2. Default workitem documentation page

Using the default look/feel is fine, but there are cases you might want to change it to fit your company/business better by changing the colors, adding your logo, or even completely change the layout of these pages and here is how you can do it. 

The jBPM work items module includes a sub-module called template-resources. In this module you can find all related templates that are used to build your final repository content. Lets take a look at these files to find out what each dose:

a) repoheader.html and repofooter.html - responsible for the top and bottom part of your repository index page. You can change these to for example define different page colors, add your logo to it, etc. Whatever you feel like. 
b) repoindex.part- defines each workitem information (each table row on the repository index page). You can change this to change the display for each of your workitems, add/remove download links etc.
c) indextemplate.st - this is a StringTemplate file that is used by each workitem module to generate its documentation page. Again you have free reign to change the look/feel of your workitem documentation as you wish.

With little knowledge of html (and power of jQuery and Boostrap that are built in) you can customize your workitem repository, for example (I'm not a designer btw :):

3) "Skinned" workitem repository index page

2. Excluding workitems from generated repository content
By default all workitems in the jBPM work items module will be displayed in the generated repository. You may not want to expose all of the available ones to your clients and can control which ones you wish to expose via the repository Maven assembly descriptor.
Here in the dependencySet section you can define excludes on the workitems you do not wish to display. Let's say you do not want to show the Archive and Dropbox workitems, you would do:

<excludes>
  <exclude>${project.groupId}:repository-springboot</exclude>
  <exclude>${project.groupId}:archive-workitem</exclude>
  <exclude>${project.groupId}:dropbox-workitem</exclude>
</excludes>

and those will not show up in the generated repository content any more. 
3. Generating additional download content using workitem handler information
By default each workitem in the repository might have one or more handler implementations. Each handler describes itself via the @Wid annotation, here is an example handler for sending Twitter messages.  During compilation step of your handlers repository gathers the info from this annotations and uses it to generate the workitem defintion configuration, the json config, the deployment descriptor xml, etc etc. You may want to generate additional configuration files that currently do not exist. 
This can be configured in the main project's pom.xml file. Here you can add more or remove existing config files generated from the annotation information in your workitem handlers.
I hope this info will be of some help to you guys. As always if there are any questions or if you have ideas on how to further enhance the workitem repository feel free to ask.