Trying to determine end event activity ID

Hello,

we are loading process definitions through the following call:

ProcessEngines
  .getDefaultProcessEngine
  .getRepositoryService
  .createProcessDefinitionQuery()
  .processDefinitionKey(processDefinitionKey)
  .processDefinitionVersion(version)
  .singleResult())

and we get objects back, but the lists of activities,

ProcessDefinitionEntity.flowActivities
ProcessDefinitionEntity.namedFlowActivities

are empty. But when we generate migration plans for the process definitions to rename the end activities, the migration plan validator has access to objects where these lists are filled (which is why it fails us). How do we get these lists by using the default process engine?

If anyone is interested, the solution we happened upon is using

ProcessEngines
  .getDefaultProcessEngine
  .getRepositoryService
  .getProcessModel(process.getId)

to load the xml of the process definition, and then parsing the xml to find the End Event we’re interested in.