Can `flowable` change the person in charge or add a task without changing xml of BPMN?

88 Views Asked by At

i have tree questions about the open-source flowable. it is important about What all cases have in common is that there should be no server restart due to xml changes.

is it possible?

  1. Can flowable change the person in charge to someone else? here is my process. i want to it Ken to Roy in my process. enter image description here

  2. Can flowable add a task without changing the xml of BPMN? I want to add service task in process without server restart. enter image description here

  3. If rejected during the process, will all of the history be accumulated? If Ben reject and then process is reset, but The history records is accumulated. Tom approved, Ken approved, Ben Reject then this process start first tom. enter image description here

I really appreciate your help. Thank you!!!

I ran the demo and checked the task logic, and I saw the table structure.

But it's still not enough to understand the above.

enter image description here

here is my source code WorkflowService in spring boot application

demo

site

controller

@Slf4j
@RestController
public class ArticleWorkflowController {
  @Autowired
  private ArticleWorkflowService service;

  @PostMapping("/submit")
  public void submit(@RequestBody Article article) {
    service.startProcess(article);
  }

  @PostMapping("/restart")
  public void restart(@RequestBody Article article) {
    service.restartProcess(article);
  }

  @GetMapping("/tasks")
  public List<Article> getTasks(@RequestParam String assignee) {
    return service.getTasks(assignee);
  }

  @PostMapping("/review")
  public void review(@RequestBody Approval approval) {
    service.submitReview(approval);
  }

  @GetMapping("/history")
  public List<HistoricActivityInstance> getHistoryList() {
    return service.getHistory();
  }
}

Service


@Slf4j
@RequiredArgsConstructor
@Service
public class ArticleWorkflowService {
  private final RuntimeService runtimeService;

  private final ProcessEngine processEngine;

  private final TaskService taskService;

  @Transactional
  public void startProcess(Article article) {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("author", article.getAuthor());
    variables.put("url", article.getUrl());
    runtimeService.startProcessInstanceByKey("articleReview", variables);


    log.info("task size is {}", taskService.createTaskQuery().list().size());
  }

  @Transactional
  public void restartProcess(Article article) {
    Map<String, Object> variables = new HashMap<>();
    variables.put("author", article.getAuthor());
    variables.put("url", article.getUrl());
//        
//               
//        
//        runtimeService.startProcessInstanceByKey("articleReview", variables);
  }

  @Transactional
  public List<Article> getTasks(String assignee) {
    List<Task> tasks = taskService.createTaskQuery()
        .taskCandidateGroup(assignee)
        .list();


    return tasks.stream()
        .map(task -> {
          Map<String, Object> variables = taskService.getVariables(task.getId());
          return new Article(
              task.getId(), (String) variables.get("author"), (String) variables.get("url"));
        })
        .collect(Collectors.toList());
  }

  @Transactional
  public void submitReview(Approval approval) {
    Map<String, Object> variables = new HashMap<>();
    variables.put("approved", approval.isStatus());
    taskService.complete(approval.getId(), variables);
  }

  @Transactional(readOnly = true)
  public List<HistoricActivityInstance> getHistory() {
    HistoryService historyService = processEngine.getHistoryService();

    return historyService.createHistoricActivityInstanceQuery()
        .list();

  }
}
1

There are 1 best solutions below

0
Valentin Zickner On
  1. You can change the assignee of the specific task with the TaskService#setAssignee method. However, it won't change the label in your diagram.
  2. You can't easily introduce a new step into the process without changing the XML. In theory, the functionality could be done with adding a task listener automatically. However, you would need to re-publish your BPMN diagram in that case as well. I would propose rather than restarting the server to use either the RepositoryService or the respective REST API to create a new deployment and publish your updated BPMN file without a server restart.
  3. The history will contain all the activities which have been executed and persisted to the database. Since you have user tasks in your process, this probably will result in multiple occurrences of the user task. Note: The usage of exclusive gateways would be nice in the diagram. This highlights that there is a decision which is happening after the task.