Search in sources :

Example 1 with ReopenCaseCommand

use of org.jbpm.casemgmt.impl.command.ReopenCaseCommand in project jbpm by kiegroup.

the class CaseServiceImpl method reopenCase.

@Override
public void reopenCase(String caseId, String deploymentId, String caseDefinitionId, Map<String, Object> data) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.REOPEN_CASE);
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceByCorrelationKey(correlationKeyFactory.newCorrelationKey(caseId));
    if (pi != null) {
        throw new CaseActiveException("Case with id " + caseId + " is still active and cannot be reopened");
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("caseId", caseId);
    params.put("maxResults", 1);
    List<Long> caseIdMapping = commandService.execute(new QueryNameCommand<List<Long>>("findCaseIdContextMapping", params));
    if (caseIdMapping.isEmpty()) {
        throw new CaseNotFoundException("Case with id " + caseId + " was not found");
    }
    logger.debug("About to reopen case {} by starting process instance {} from deployment {} with additional data {}", caseId, caseDefinitionId, deploymentId, data);
    processService.execute(deploymentId, CaseContext.get(caseId), new ReopenCaseCommand(identityProvider, caseId, deploymentId, caseDefinitionId, data, processService));
}
Also used : HashMap(java.util.HashMap) ReopenCaseCommand(org.jbpm.casemgmt.impl.command.ReopenCaseCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) List(java.util.List) ArrayList(java.util.ArrayList) CaseNotFoundException(org.jbpm.casemgmt.api.CaseNotFoundException) CaseActiveException(org.jbpm.casemgmt.api.CaseActiveException)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)1 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)1 ReopenCaseCommand (org.jbpm.casemgmt.impl.command.ReopenCaseCommand)1 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)1