Search in sources :

Example 26 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class ProcessInstanceAdminServiceImplTest method cleanup.

@After
public void cleanup() {
    cleanupSingletonSessionId();
    if (processInstanceId != null) {
        try {
            // let's abort process instance to leave the system in clear state
            processService.abortProcessInstance(processInstanceId);
            ProcessInstance pi = processService.getProcessInstance(processInstanceId);
            assertNull(pi);
        } catch (ProcessInstanceNotFoundException e) {
        // ignore it as it might already be completed/aborted
        }
    }
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            try {
                deploymentService.undeploy(unit);
            } catch (Exception e) {
            // do nothing in case of some failed tests to avoid next test to fail as well
            }
        }
        units.clear();
    }
    close();
    CountDownListenerFactory.clear();
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) After(org.junit.After)

Example 27 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class CaseServiceImpl method addDynamicSubprocessToStage.

@Override
public Long addDynamicSubprocessToStage(Long processInstanceId, String stageId, String processId, Map<String, Object> parameters) throws CaseNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
        throw new ProcessInstanceNotFoundException("No process instance found with id " + processInstanceId + " or it's not active anymore");
    }
    String caseId = pi.getCorrelationKey();
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_PROCESS_TO_CASE);
    return processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new AddDynamicProcessToStageCommand(identityProvider, caseId, pi.getId(), stageId, processId, parameters));
}
Also used : AddDynamicProcessToStageCommand(org.jbpm.casemgmt.impl.command.AddDynamicProcessToStageCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 28 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class CaseServiceImpl method addDynamicTaskToStage.

@Override
public void addDynamicTaskToStage(String caseId, String stageId, TaskSpecification taskSpecification) throws CaseNotFoundException, StageNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_TASK_TO_CASE);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
        throw new ProcessInstanceNotFoundException("No process instance found with id " + pi.getId() + " or it's not active anymore");
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new AddDynamicTaskToStageCommand(identityProvider, caseId, taskSpecification.getNodeType(), pi.getId(), stageId, taskSpecification.getParameters()));
}
Also used : AddDynamicTaskToStageCommand(org.jbpm.casemgmt.impl.command.AddDynamicTaskToStageCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 29 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class CaseServiceImpl method addDynamicTaskToStage.

@Override
public void addDynamicTaskToStage(Long processInstanceId, String stageId, TaskSpecification taskSpecification) throws CaseNotFoundException, StageNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
        throw new ProcessInstanceNotFoundException("No process instance found with id " + processInstanceId + " or it's not active anymore");
    }
    String caseId = pi.getCorrelationKey();
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_TASK_TO_CASE);
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new AddDynamicTaskToStageCommand(identityProvider, caseId, taskSpecification.getNodeType(), pi.getId(), stageId, taskSpecification.getParameters()));
}
Also used : AddDynamicTaskToStageCommand(org.jbpm.casemgmt.impl.command.AddDynamicTaskToStageCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 30 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class AddDynamicTaskCommand method execute.

@Override
public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
    if (processInstance == null) {
        throw new ProcessInstanceNotFoundException("No process instance found with id " + processInstanceId);
    }
    CaseFileInstance caseFile = getCaseFile(ksession, caseId);
    CaseEventSupport caseEventSupport = getCaseEventSupport(context);
    caseEventSupport.fireBeforeDynamicTaskAdded(caseId, caseFile, processInstanceId, nodeType, parameters);
    DynamicUtils.addDynamicWorkItem(processInstance, ksession, nodeType, parameters);
    caseEventSupport.fireAfterDynamicTaskAdded(caseId, caseFile, processInstanceId, nodeType, parameters);
    return null;
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseEventSupport(org.jbpm.casemgmt.impl.event.CaseEventSupport) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Aggregations

ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)56 KieSession (org.kie.api.runtime.KieSession)21 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)21 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)16 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)16 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)13 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)13 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)13 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)13 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)13 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)13 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)10 After (org.junit.After)10 RegistryContext (org.drools.core.command.impl.RegistryContext)8 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)7 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)4 WorkItem (org.kie.api.runtime.process.WorkItem)4 ArrayList (java.util.ArrayList)3