Search in sources :

Example 11 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class CaseServiceImpl method getCaseRoleAssignments.

@Override
public Collection<CaseRoleInstance> getCaseRoleAssignments(String caseId) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.MODIFY_ROLE_ASSIGNMENT);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    CaseFileInstance caseFile = internalGetCaseFileInstance(caseId, pi.getDeploymentId());
    return ((CaseFileInstanceImpl) caseFile).getAssignments();
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseFileInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseFileInstanceImpl) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 12 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class CaseServiceImpl method removeDataFromCaseFile.

@Override
public void removeDataFromCaseFile(String caseId, String name) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.REMOVE_DATA);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new RemoveDataCaseFileInstanceCommand(identityProvider, Arrays.asList(name), authorizationManager));
}
Also used : RemoveDataCaseFileInstanceCommand(org.jbpm.casemgmt.impl.command.RemoveDataCaseFileInstanceCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 13 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class CaseServiceImpl method assignToCaseRole.

/*
     * Case role assignment methods
     */
@Override
public void assignToCaseRole(String caseId, String role, OrganizationalEntity entity) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.MODIFY_ROLE_ASSIGNMENT);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new ModifyRoleAssignmentCommand(identityProvider, role, entity, true));
}
Also used : ModifyRoleAssignmentCommand(org.jbpm.casemgmt.impl.command.ModifyRoleAssignmentCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 14 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc 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)

Example 15 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class CaseServiceImpl method addDataToCaseFile.

@Override
public void addDataToCaseFile(String caseId, Map<String, Object> data, String... restrictedTo) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_DATA);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    List<String> accessRestriction = null;
    if (restrictedTo != null) {
        accessRestriction = Arrays.asList(restrictedTo);
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new AddDataCaseFileInstanceCommand(identityProvider, data, accessRestriction, authorizationManager));
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) AddDataCaseFileInstanceCommand(org.jbpm.casemgmt.impl.command.AddDataCaseFileInstanceCommand)

Aggregations

ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)198 Test (org.junit.Test)147 QueryContext (org.kie.api.runtime.query.QueryContext)123 ArrayList (java.util.ArrayList)75 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)57 HashMap (java.util.HashMap)32 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)25 TaskSummary (org.kie.api.task.model.TaskSummary)25 QueryFilter (org.kie.internal.query.QueryFilter)23 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)17 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)16 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)15 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)12 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)12 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)11 CorrelationKey (org.kie.internal.process.CorrelationKey)11 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)9 List (java.util.List)7