cancel
Showing results for 
Search instead for 
Did you mean: 

Manage tasks with status

flostudent
Champ in-the-making
Champ in-the-making
Hello,

For a student project, we have to use a workflow engine. We have tasks to be validated by a system and I chose the Activiti Engine to create workflows.
These tasks are performed one after the other and have three different statuses:
Pending, In progress and Complete

The number of tasks is not fixed that's why I create dynamic process that looks like this :
start -> task1 -> task2 -> task3 -> task4 -> end
or
start -> task1 -> task2 -> end

When i receive the information from the system that a task is started I want to mark it as "In progress" in the workflow. When it is completed, I want to make it as complete.

I can create a process,  tasks, complete them but I don't know how to handle the job status, and be able to get it ?

How can I do ? Does activiti manage it ?

thanks
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
You can use task-variables for this. You can set a variable (eg. taskService.setVariableLocal("jobStatus", "pending") and retrieve it later or create queries that use that variable value…

flostudent
Champ in-the-making
Champ in-the-making
Thanks I think it will be useful. Can i create variables for each task or this is only for a given process ?

flostudent
Champ in-the-making
Champ in-the-making
Ok i can do it with :

setVariable(String taskId, String variableName, Object value)
set variable on a task.

flostudent
Champ in-the-making
Champ in-the-making
I wish I could show a diagram of my workflow that shows its progress (show completed tasks, undone tasks,…), is there a way to get it back with all its tasks? (or do I have to use the bpmn model?)

frederikherema1
Star Contributor
Star Contributor
Use the org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator for this, passing in the active activitId's to highlight. You can always pass in completed activityIds as well. Example extract from org.activiti.rest.api.process.ProcessInstanceDiagramResource


ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl)
        ActivitiUtil.getRepositoryService()).getDeployedProcessDefinition(pi.getProcessDefinitionId());

    if (pde != null && pde.isGraphicalNotationDefined()) {
      BpmnModel bpmnModel = ActivitiUtil.getRepositoryService().getBpmnModel(pde.getId());
      InputStream resource = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", ActivitiUtil.getRuntimeService().getActiveActivityIds(processInstanceId));

      InputRepresentation output = new InputRepresentation(resource, MediaType.IMAGE_PNG);
      return output;
     
    } else {
      throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
    }
[code]

chandraprabha
Champ in-the-making
Champ in-the-making
Can you please let me know how i can mark a task as "InProcess" using activiti Rest API.