cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with 'Get Process Instance Details' Java API

madhusudanjoshi
Champ on-the-rise
Champ on-the-rise
I am using Activiti 5.12. You have provided REST API to get he details of a process instance, i.e :
GET /process-instance/{processInstanceId}
Response :
<code>
{
    "id": "2",
    "processDefinitionId": "financialReport:1",
    "businessKey": "55",
    "startTime": "2010-10-13T14:54:26.750+02:00",
    "startActivityId": "startFinancialAnalysis",
    "startUserId": "kermit",
    "completed": false,
    "tasks": [
      {
        "taskId": "3",
        "taskName": "Analyze report",
        "owner": null,
        "assignee": "Kermit",
        "startTime": "2010-10-13T14:53:26.750+02:00",
        "completed": false
      }
    ],
    "activities": [
      {
        "activityId": "4",
        "activityName": "Get report",
        "activityType": "ServiceTask",
        "startTime": "2010-10-13T14:53:25.750+02:00",
        "completed": true,
        "startTime": "2010-10-13T14:53:25.950+02:00",
        "duration": 200
      }
    ],
    "variables": [
      {
        "variableName": "reportName",
        "variableValue": "classified.pdf",
      }
    ]
    "historyVariables": [
      {
        "variableName": "reportName",
        "variableValue": "classified.pdf",
        "variableType": "String",
        "revision": 1,
        "time": "2010-10-13T14:53:26.750+02:00"
      }
    ]
   
  }
<c/ode>
Respective JAVA API as provided in user guide is :
<b>ProcessEngines.getProcessEngine(configuredProcessEngineName).getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(..).singleResult()<b>

This API returns an HistoricProcessInstance, and it does not contain any methods to get the list of tasks.
I need those list of tasks to know which state the process instance is, that means which tasks are completed or which is not.

Can you please help me in that.
2 REPLIES 2

trademak
Star Contributor
Star Contributor
That's right, you have to use the HistoricTaskInstanceQuery to get a list of tasks related to a process instance.

Best regards,

madhusudanjoshi
Champ on-the-rise
Champ on-the-rise
Thanks trademak.

List<HistoricTaskIntance> taskList = getHistoryService()
  .createHistoricTaskInstanceQuery()
  .processInstanceId(processInstanceId)
  .list()

Iterated through This task list and finding if any of its task end time is "null".

That is one way or directly accessing the db "act_hi_taskinst" to get the task.