cancel
Showing results for 
Search instead for 
Did you mean: 

TaskEntity.getCandidates() NPE

arkadi
Champ in-the-making
Champ in-the-making
I'm trying to show task's candidate information in the GUI by invoking TaskEntity.getCandidates() in the following piece of code but then only NPE comes out

Caused by: java.lang.NullPointerException
    at org.activiti.engine.impl.persistence.entity.TaskEntity.getIdentityLinks(TaskEntity.java:339)
    at org.activiti.engine.impl.persistence.entity.TaskEntity.getCandidates(TaskEntity.java:281)

Task t = engine.getTaskService()
    .createTaskQuery()
    .taskId(id).singleResult();
String names = assignee(t);

String assignee(Task task) {
    String assignee = task.getAssignee();
    if (assignee != null)
        return user(assignee);
    if (!(task instanceof TaskEntity))
        return null;
    List<String> candidates = new ArrayList<String>();
    for (IdentityLink c : ((TaskEntity) task).getCandidates()) {
        if (c.getGroupId() != null)
            candidates.add(group(c.getGroupId()));
        else if (c.getUserId() != null)
            candidates.add(user(c.getUserId()));
    }
    return join(candidates.toArray(strings), ", ");
}
Activiti v5.6.
Is it me doing it wrong or I should raise an issue for that?
The required functionality is not exposed via interface, but as I learned from activiti-rest component, to obtain current process instance diagram you need to cast to impl, so my approach is legal until public API is created, I believe.
2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
If it's not in the public API (ie .impl package), then things like this NPE can happen.

The public method to do what you want is on the taskService:  List<IdentityLink> getIdentityLinksForTask(String taskId);

arkadi
Champ in-the-making
Champ in-the-making
Thank you. That works. Somehow I missed the function while reading the API doc.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.