cancel
Showing results for 
Search instead for 
Did you mean: 

What is the correct place for custom Task & Process Def attributes?

jwestra
Champ in-the-making
Champ in-the-making
I need to add few 'metadata' fields to my Process and Task Definitions.  Just wondering if ExtensionAttributes are where I'd do this?

Here are two examples:

1. PermissionToStartProcess - we need to indicate a "Permission" to start the process (example: "Manage Special Events" permission).  It is a String that points to a valid "Permission" name in our own security realm.  If the User does not have the permission "configured" in the ProcessDefinition, they will be denied the ability to start the process.

2. AutoAssignOnCreate - we want to tag a UserTask as either AutoAssignOnCreate  = true/false.  If True, we have an AutoAssignTaskListener assign it immediately.  Otherwise, ignore and let the User belonging to the ProcessDefinition's candidate groups/users fight it out to get an assignee.


So, should I be using an ExtensionAttribute in the XML (or BpmnModel Java class) to configure these?

Or, do I need to build some kind of custom table to hold these configuration fields & look them up using the TaskDefinitionKey and ProcessDefinitionKeys?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
That would need to go into the extensionElements (or maybe extensionAttributes). That's what they are for in the BPMN specification.
You indeed will need to go via the BpmnModel to look these up.

jwestra
Champ in-the-making
Champ in-the-making
OK.  Here's the plan then:

In task listeners that need access to my custom extensions (e.g. AutoAssignTaskListener), I will take the ProcessDefinition ID from the DelegateTask and query the RepositoryService to get the BpmnModel containing these extensions.

<code>
BpmnModel model = RepositoryService.getBpmnModel(processDefinitionId)

// get Process from model
// get FlowElement for the DelegateTask my task listener is handling
// get ExtensionElements and/or ExtensionAttributes for the FlowElement
// verify the value and run logic on it (e.g., isAutoAssignOnCreate == true)  then auto-assign it!
</code>

My concern is that loading the BpmnModel each time my AutoAssignTaskListener.notify() is invoked will be costly.  Does Activiti have a "cache by ProcessDefinitionId" for the BpmnModels , which would eliminate call to the Repository DB tables constantly?

jbarrez
Star Contributor
Star Contributor
Yes, all process definitions are cached, so no database call will be made.