Search in sources :

Example 6 with ProcessInstanceDesc

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

the class CaseRuntimeDataServiceImpl method getAdHocFragmentsForCase.

@Override
public Collection<AdHocFragment> getAdHocFragmentsForCase(String caseId) {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceByCorrelationKey(correlationKeyFactory.newCorrelationKey(caseId));
    if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
        throw new CaseNotFoundException("No case instance found with id " + caseId + " or it's not active anymore");
    }
    CaseDefinition caseDef = getCase(pi.getDeploymentId(), pi.getProcessId());
    List<AdHocFragment> adHocFragments = new ArrayList<>();
    adHocFragments.addAll(caseDef.getAdHocFragments());
    Collection<CaseStageInstance> activeStages = internalGetCaseStages(caseDef, caseId, true, new QueryContext(0, 100));
    activeStages.forEach(stage -> adHocFragments.addAll(stage.getAdHocFragments()));
    return adHocFragments;
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ArrayList(java.util.ArrayList) CaseStageInstance(org.jbpm.casemgmt.api.model.instance.CaseStageInstance) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) CaseNotFoundException(org.jbpm.casemgmt.api.CaseNotFoundException) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment)

Example 7 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, List<String> variableNames) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.REMOVE_DATA);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new RemoveDataCaseFileInstanceCommand(identityProvider, variableNames, authorizationManager));
}
Also used : RemoveDataCaseFileInstanceCommand(org.jbpm.casemgmt.impl.command.RemoveDataCaseFileInstanceCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 8 with ProcessInstanceDesc

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

the class CaseServiceImpl method addDynamicSubprocess.

@Override
public Long addDynamicSubprocess(Long processInstanceId, 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 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 9 with ProcessInstanceDesc

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

the class CaseServiceImpl method addDynamicTask.

/*
     * Dynamic operations on a case
     */
@Override
public void addDynamicTask(String caseId, TaskSpecification taskSpecification) throws CaseNotFoundException {
    authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_TASK_TO_CASE);
    ProcessInstanceDesc pi = verifyCaseIdExists(caseId);
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new AddDynamicTaskCommand(identityProvider, caseId, taskSpecification.getNodeType(), pi.getId(), taskSpecification.getParameters()));
}
Also used : AddDynamicTaskCommand(org.jbpm.casemgmt.impl.command.AddDynamicTaskCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc)

Example 10 with ProcessInstanceDesc

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

the class CaseServiceImpl method addDataToCaseFile.

/*
     * Case file data methods
     */
@Override
public void addDataToCaseFile(String caseId, String name, Object value, 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);
    }
    Map<String, Object> parameters = new HashMap<>();
    parameters.put(name, value);
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(pi.getId()), new AddDataCaseFileInstanceCommand(identityProvider, parameters, accessRestriction, authorizationManager));
}
Also used : HashMap(java.util.HashMap) 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