All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudfoundry.multiapps.controller.process.flowable.RetryProcessAdditionalAction Maven / Gradle / Ivy

There is a newer version: 1.183.0
Show newest version
package org.cloudfoundry.multiapps.controller.process.flowable;

import java.util.List;
import java.util.stream.Collectors;

import jakarta.inject.Inject;
import jakarta.inject.Named;

import org.cloudfoundry.multiapps.controller.persistence.model.ProgressMessage.ProgressMessageType;
import org.cloudfoundry.multiapps.controller.persistence.services.ProgressMessageService;
import org.flowable.engine.runtime.Execution;

@Named
public class RetryProcessAdditionalAction implements AdditionalProcessAction {

    private final FlowableFacade flowableFacade;
    private final ProgressMessageService progressMessageService;

    @Inject
    public RetryProcessAdditionalAction(FlowableFacade flowableFacade, ProgressMessageService progressMessageService) {
        this.progressMessageService = progressMessageService;
        this.flowableFacade = flowableFacade;
    }

    @Override
    public void executeAdditionalProcessAction(String processInstanceId) {
        List failedActivityIds = findFailedActivityIds(processInstanceId);
        for (String failedActivityId : failedActivityIds) {
            progressMessageService.createQuery()
                                  .processId(processInstanceId)
                                  .taskId(failedActivityId)
                                  .type(ProgressMessageType.ERROR)
                                  .delete();
        }
    }

    private List findFailedActivityIds(String superProcessInstanceId) {
        List executionsForProcess = flowableFacade.getActiveProcessExecutions(superProcessInstanceId);
        return executionsForProcess.stream()
                                   .map(Execution::getActivityId)
                                   .collect(Collectors.toList());
    }

    @Override
    public Action getApplicableAction() {
        return Action.RETRY;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy