/**
  * Gets the BPMN model instance for a process definition key.
  *
  * @param processDefinitionKey the process definition key of the running process
  * @return the BPMN model instance
  */
 private BpmnModelInstance getModelInstance(String processDefinitionKey) {
   String processId =
       repositoryService
           .createProcessDefinitionQuery()
           .processDefinitionKey(processDefinitionKey)
           .latestVersion()
           .singleResult()
           .getId();
   return repositoryService.getBpmnModelInstance(processId);
 }
 /**
  * Gets the current BPMN model instance.
  *
  * @return the BPMN model instance
  */
 private BpmnModelInstance getModelInstance() {
   String processDefinitionId = businessProcess.getTask().getProcessDefinitionId();
   return repositoryService.getBpmnModelInstance(processDefinitionId);
 }