As part of reporting/dashboarding functions in our software, I want to provide a "process instance state" report that can be accessed via REST services that we publish. To that end, I get the "current task" for a process instance:
taskService.createTaskQuery().processInstanceBusinessKey(processInstance.getBusinessKey()).list().get(0);
Is this approach to getting the current task correct? Let's assume for a moment lack of parallelism as our processes are fairly simple. Can it be assumed that, while a process instance is active, there is always at least one active task that will be returned by this query? If not, what other information should I be fetching about the process instance state that would provide a nice snapshot of what state it is in?
Also, while the Task object gives me good information, I can't see where to get the "type" of the task (e.g. UserTask, ScriptTask, ServiceTask, etc). Is there such a getter? If not, are there internal class names that I can compare against?
Thanks
john