cancel
Showing results for 
Search instead for 
Did you mean: 

ProcessInstance.getName() and getDescription() are NULL

jwestra
Champ in-the-making
Champ in-the-making
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?


<?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>
8 REPLIES 8

martin_grofcik
Confirmed Champ
Confirmed Champ
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

jwestra
Champ in-the-making
Champ in-the-making
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?

jwestra
Champ in-the-making
Champ in-the-making
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>

martin_grofcik
Confirmed Champ
Confirmed Champ
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

jwestra
Champ in-the-making
Champ in-the-making
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.

jbarrez
Star Contributor
Star Contributor
Hmm very odd, that description on execution. I'll have a look why, as it's also no persisted.

jbarrez
Star Contributor
Star Contributor
Seems to be linked to the description of the activity in the bpmn20.xml

jwestra
Champ in-the-making
Champ in-the-making
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.