Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-2756

Processes: Hide implementation details of workItem handling

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major Major
    • 0.14.0
    • None
    • Core Engine
    • None

      see also KOGITO-2754

      1) improve transitionWorkItem

          @POST()
          @Path("/{id}/firstLineApproval/{workItemId}")
          @Consumes(MediaType.APPLICATION_JSON)
          @Produces(MediaType.APPLICATION_JSON)
          public ApprovalsModelOutput completeTask_firstLineApproval_0(@PathParam("id") final String id, @PathParam("workItemId") final String workItemId, @QueryParam("phase") @DefaultValue("complete") final String phase, @QueryParam("user") final String user, @QueryParam("group") final List<String> groups, final Approvals_1_TaskOutput model) {
              try {
                  return org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> {
                      ProcessInstance<ApprovalsModel> pi = process.instances().findById(id).orElse(null);
                     ....
                      org.kie.kogito.auth.IdentityProvider identity = ...
                      org.jbpm.process.instance.impl.humantask.HumanTaskTransition transition = 
                                new org.jbpm.process.instance.impl.humantask.HumanTaskTransition(phase, model.toMap(), identity);
                      pi.transitionWorkItem(workItemId, transition);
                      ....
                  });
              } catch (WorkItemNotFoundException e) {
                  return null;
              }
          }
      

      e.g. implement a subclass or a factory for HumanTaskTransition that takes a phase a Model subclass (no explicit toMap())
      or update the transitionWorkItem API

          pi.transitionWorkItem(workItemId, model, policies(user, groups))
      

      2) Improve workItem GET

          @GET()
          @Path("/{id}/VisaApplication/{workItemId}")
          @Produces(MediaType.APPLICATION_JSON)
          public Travels_6_TaskInput getTask_VisaApplication_0(@PathParam("id") String id, @PathParam("workItemId") String workItemId, @QueryParam("user") final String user, @QueryParam("group") final List<String> groups) {
      ....
                  WorkItem workItem = pi.workItem(workItemId, policies(user, groups));
                  if (workItem == null) {
                      return null;
                  }
                  return Travels_6_TaskInput.fromMap(workItem.getId(), workItem.getName(), workItem.getParameters());
      ....
          }
      
      

      realize:

                  return pi.workItem(Travels_6_TaskInput.class, policies(user, groups));
      

              ftirados Francisco Javier Tirado Sarti
              evacchi Edoardo Vacchi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: