Work Items are by default placed under Service Tasks category on the palette so can be easily drag and dropped into the canvas when designing processes and cases. Location on the palette is also configurable via category property of the work item definition. So let’s have a guided tour on how to create a very simple but functional work item.
The complete process consists of following steps:
- generating maven project for work item (both definition and handler)
- implementing handler and configuring work item
- optionally provide custom icon (16×16)
- add work item project into service repository
- import work item into project in workbench
Generate work item maven project
- work item definition
- work item handler
mvn archetype:generate
-DarchetypeGroupId=org.jbpm
-DarchetypeArtifactId=jbpm-workitems-archetype
-DarchetypeVersion=7.8.0-SNAPSHOT
-DgroupId=org.jbpm.contrib
-DartifactId=custom-workitem
-DclassPrefix=Custom
-Dversion=7.8.0-SNAPSHOT
-DarchetypeCatalog=local
- groupId – org.jbpm.contrib
- artifactId – custom-workitem
- version – 7.8.0-SNAPSHOT
- with work item configuration and handler class custom-workitem/src/main/java/org/jbpm/contrib/CustomWorkItemHandler.java
If you haven’t done it yet, follow these:
- clone github project: https://github.com/kiegroup/jbpm-work-items
- go into jbpm-work-items
- check the version number of the cloned project and adjust version argument accordingly in the maven archetype:generate command
- dependencies that are already included in KIE Server – mark them as provided
- check for any conflicts with application server, KIE Server and your app dependencies and resolve them – either by adjusting your handler project dependencies or runtime environment
- name
- description
- category
- icon
- input parameters
- results
- handler
Expose your work item in Service Repository
Now to take advantage of repository generation of jbpm-work-items project you need to add your newly generated project into two pom files:
- main pom.xml file of jbpm-work-items project – one regular and one zip dependency
- repository/pom.xml – only zip dependency (but this time without the version tag)
<dependency>
<groupId>org.jbpm.contrib</groupId>
<artifactId>custom-workitem</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm.contrib</groupId>
<artifactId>custom-workitem</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.jbpm.contrib</groupId>
<artifactId>custom-workitem</artifactId>
<type>zip</type>
</dependency>
When you’re finished just build the project (assuming you’re in jbpm-work-items repository) use following:
mvn clean install -DskipTests -rf :custom-workitem
java -jar repository-springboot/target/repository-springboot-7.8.0-SNAPSHOT.jar
you’ll have your work item available there, just go to http://localhost:8090/repository
And that’s it, you have your work item implemented, built and exposed via Service Repository!!!
Use work item in workbench
- create project
- create asset – Business Process
- use the yellow repository icon in the designer menu to open service repository browser
- select work item and install it
- reopen process editor and you’ll find your installed work item under Service Tasks category (unless you changed the category when implementing work item)
- dependency to your work item jar (as maven dependency of your workbench’s project)
- deployment descriptor to register work item handler