Search in sources :

Example 16 with ProcessInstanceDesc

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

the class CaseServiceImpl method getCaseComments.

/*
     * Case comments methods
     */
@Override
public Collection<CommentInstance> getCaseComments(String caseId, QueryContext queryContext) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.MODIFY_COMMENT);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    CaseFileInstance caseFile = internalGetCaseFileInstance(caseId, pi.getDeploymentId());
    List<CommentInstance> caseComments = new ArrayList<>(((CaseFileInstanceImpl) caseFile).getComments());
    // apply authorization
    caseComments = authorizationManager.filterByCommentAuthorization(caseId, caseFile, caseComments);
    int caseCommentsSize = caseComments.size();
    int offset = queryContext.getOffset();
    int pageSize = queryContext.getCount();
    int pageIndex = (caseCommentsSize + pageSize - 1) / pageSize;
    if (caseCommentsSize < pageSize) {
        return caseComments;
    } else if (pageIndex == (offset / pageSize) + 1) {
        return caseComments.subList(offset, caseCommentsSize);
    } else {
        return caseComments.subList(offset, offset + pageSize);
    }
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CommentInstance(org.jbpm.casemgmt.api.model.instance.CommentInstance) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 17 with ProcessInstanceDesc

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

the class CaseServiceImpl method removeFromCaseRole.

@Override
public void removeFromCaseRole(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, false));
}
Also used : ModifyRoleAssignmentCommand(org.jbpm.casemgmt.impl.command.ModifyRoleAssignmentCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 18 with ProcessInstanceDesc

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

the class CaseServiceImpl method addDynamicSubprocessToStage.

@Override
public Long addDynamicSubprocessToStage(String caseId, String stageId, String processId, Map<String, Object> parameters) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_PROCESS_TO_CASE);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    return processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), 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)

Example 19 with ProcessInstanceDesc

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

the class CaseServiceImpl method addDynamicSubprocess.

@Override
public Long addDynamicSubprocess(String caseId, String processId, Map<String, Object> parameters) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_PROCESS_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");
    }
    return processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new AddDynamicProcessCommand(identityProvider, caseId, pi.getId(), processId, parameters));
}
Also used : AddDynamicProcessCommand(org.jbpm.casemgmt.impl.command.AddDynamicProcessCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 20 with ProcessInstanceDesc

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

the class CaseServiceImpl method removeCaseComment.

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

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