ProcessInstance.getName() and getDescription() are NULL

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2016 05:57 PM
Hi,
I have a simple process definition XML shown below. When I deploy it, start and instance of it, and then look at ProcessInstance.getName() and getDescription(), they are both null. I do not understand what they are supposed to be set to, but I guess I expected the "getName()" would return "name_1" and the ProcessInstance.getDescription() would return the <documentation> value of "Test description".
Can someone please tell me how to set & get these fields on a ProcessInstance?
I have a simple process definition XML shown below. When I deploy it, start and instance of it, and then look at ProcessInstance.getName() and getDescription(), they are both null. I do not understand what they are supposed to be set to, but I guess I expected the "getName()" would return "name_1" and the ProcessInstance.getDescription() would return the <documentation> value of "Test description".
Can someone please tell me how to set & get these fields on a ProcessInstance?
<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> <process id="StartProcessTest_1" name="name_1" isExecutable="true"> <documentation>Test description</documentation> <startEvent id="startevent1" name="Start"></startEvent> <userTask id="usertask1" name="User Task" activiti:formKey="customForm.here"></userTask> <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow> <endEvent id="endevent1" name="End"></endEvent> <scriptTask id="scripttask1" name="Script Task" activiti:async="true" scriptFormat="groovy" activiti:autoStoreVariables="false"> <script>println "ScriptTask - Executed!"</script> </scriptTask> <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="scripttask1"></sequenceFlow> <sequenceFlow id="flow3" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_StartProcessTest_1"> <bpmndi:BPMNPlane bpmnElement="StartProcessTest_1" id="BPMNPlane_StartProcessTest_1"> <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1"> <omgdc:Bounds height="35.0" width="35.0" x="160.0" y="240.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"> <omgdc:Bounds height="55.0" width="105.0" x="300.0" y="230.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"> <omgdc:Bounds height="35.0" width="35.0" x="720.0" y="240.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1"> <omgdc:Bounds height="55.0" width="105.0" x="530.0" y="230.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> <omgdi:waypoint x="195.0" y="257.0"></omgdi:waypoint> <omgdi:waypoint x="300.0" y="257.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> <omgdi:waypoint x="405.0" y="257.0"></omgdi:waypoint> <omgdi:waypoint x="530.0" y="257.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"> <omgdi:waypoint x="635.0" y="257.0"></omgdi:waypoint> <omgdi:waypoint x="720.0" y="257.0"></omgdi:waypoint> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram></definitions>
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2016 02:42 AM
Hi,
have a look on jUnit tests. e.g.:
org.activiti.engine.test.api.runtime.RuntimeServiceTest#testStartProcessInstanceByProcessInstanceBuilder
org.activiti.engine.test.api.runtime.RuntimeServiceTest#testSetProcessInstanceName
Regards
Martin
have a look on jUnit tests. e.g.:
org.activiti.engine.test.api.runtime.RuntimeServiceTest#testStartProcessInstanceByProcessInstanceBuilder
org.activiti.engine.test.api.runtime.RuntimeServiceTest#testSetProcessInstanceName
Regards
Martin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2016 10:21 AM
Thanks for pointing that out. After digging into the junits, I see that ProcessInstanceBuilder API and the RuntimeService APIs have a way to set the ProcessInstance's "name" field.
However, I do not see anything similar to set the ProcessInstance's "description" field. How is that set on the ProcessInstance?
However, I do not see anything similar to set the ProcessInstance's "description" field. How is that set on the ProcessInstance?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2016 12:11 PM
I'm currently doing this hack to make a fetched ProcessInstance have the "description" of my bpmn model each time I find a ProcessInstance.
I don't like this approach because it uses the ExecutionEntity class in an "impl" package to call setDescription(). And, it makes an assumption that the ProcessInstance came from the BpmnModel's main Process.
Please let me know if there is a better way to persist the description of a ProcessInstance and bring it back with my singleResult() query so I can avoid these APIs and assumptions.
<code>
ProcessInstance processInstance = // go find it here
ProcessDefinition processDefinitionEntity = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(processInstance.getProcessDefinitionId())
.singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionEntity.getId());
String descriptionDefault = bpmnModel.getMainProcess().getDocumentation();
// FIXME: Requested correct API from Activiti guys here to set
// the description. This approach uses an 'impl' packaged class
// to get the job done, which is not the best
if (processInstance instanceof ExecutionEntity) {
ExecutionEntity impl = (ExecutionEntity)dataObject;
impl.setDescription(descriptionDefault);
}
</code>
I don't like this approach because it uses the ExecutionEntity class in an "impl" package to call setDescription(). And, it makes an assumption that the ProcessInstance came from the BpmnModel's main Process.
Please let me know if there is a better way to persist the description of a ProcessInstance and bring it back with my singleResult() query so I can avoid these APIs and assumptions.
<code>
ProcessInstance processInstance = // go find it here
ProcessDefinition processDefinitionEntity = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(processInstance.getProcessDefinitionId())
.singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionEntity.getId());
String descriptionDefault = bpmnModel.getMainProcess().getDocumentation();
// FIXME: Requested correct API from Activiti guys here to set
// the description. This approach uses an 'impl' packaged class
// to get the job done, which is not the best
if (processInstance instanceof ExecutionEntity) {
ExecutionEntity impl = (ExecutionEntity)dataObject;
impl.setDescription(descriptionDefault);
}
</code>
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 05:47 AM
Hi,
Process instance does not have any description. The description is only present in the process definition/model.
That's why you have to go to the BPMN model to acquire it.
Regards
Martin
Process instance does not have any description. The description is only present in the process definition/model.
That's why you have to go to the BPMN model to acquire it.
Regards
Martin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 08:21 AM
I see. The ProcessInstance interface extends Execution, which has getDescription() on it's API. So, that is why I figured they had descriptions. Thanks for clarifying.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2016 09:37 AM
Hmm very odd, that description on execution. I'll have a look why, as it's also no persisted.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2016 10:38 AM
Seems to be linked to the description of the activity in the bpmn20.xml

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2016 10:55 AM
Thanks for searching that down, Joram.
If Execution.getDescription() is the process instance's current activity's description then it sounds like I should stop using it for my purposes then. I was looking for something like the documentation on the bpmn20.xml's of the process definition.
If Execution.getDescription() is the process instance's current activity's description then it sounds like I should stop using it for my purposes then. I was looking for something like the documentation on the bpmn20.xml's of the process definition.
