private Workflow convertToWorkflow(ProcessInstance instance, Locale locale) {
final Workflow workflow = new Workflow(instance.getName(), instance.getId(), key);
final WorkflowDefinition definition = getWorkflowDefinitionById(instance.getProcessDefinitionId(), locale);
workflow.setWorkflowDefinition(definition);
workflow.setAvailableActions(getAvailableActions(instance.getId(), locale));
Job job = managementService.createJobQuery().timers().processInstanceId(instance.getId()).uniqueResult();
if (job != null) {
workflow.setDuedate(job.getDueDate());
}
workflow.setStartTime(historyService.createHistoryProcessInstanceQuery().processInstanceId(instance.getId()).orderAsc(HistoryProcessInstanceQuery.PROPERTY_STARTTIME).uniqueResult().getStartTime());
Object user = executionService.getVariable(instance.getId(), "user");
if (user != null) {