Search in sources :

Example 1 with ProcessInstanceDesc

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

the class RuntimeDataServiceImpl method getProcessInstanceByCorrelationKey.

@Override
public ProcessInstanceDesc getProcessInstanceByCorrelationKey(CorrelationKey correlationKey) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("correlationKey", correlationKey.toExternalForm());
    params.put("maxResults", 1);
    List<ProcessInstanceDesc> processInstances = commandService.execute(new QueryNameCommand<List<ProcessInstanceDesc>>("getProcessInstanceByCorrelationKey", params));
    if (!processInstances.isEmpty()) {
        ProcessInstanceDesc desc = processInstances.iterator().next();
        List<String> statuses = new ArrayList<String>();
        statuses.add(Status.Ready.name());
        statuses.add(Status.Reserved.name());
        statuses.add(Status.InProgress.name());
        params = new HashMap<String, Object>();
        params.put("processInstanceId", desc.getId());
        params.put("statuses", statuses);
        List<UserTaskInstanceDesc> tasks = commandService.execute(new QueryNameCommand<List<UserTaskInstanceDesc>>("getTaskInstancesByProcessInstanceId", params));
        ((org.jbpm.kie.services.impl.model.ProcessInstanceDesc) desc).setActiveTasks(tasks);
        return desc;
    }
    return null;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) List(java.util.List) ArrayList(java.util.ArrayList) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 2 with ProcessInstanceDesc

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

the class ProcessInstanceAdminServiceImpl method updateTimerRelative.

@Override
public void updateTimerRelative(long processInstanceId, long timerId, long delay, long period, int repeatLimit) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new RelativeUpdateTimerCommand(processInstanceId, timerId, delay, period, repeatLimit));
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) RelativeUpdateTimerCommand(org.jbpm.process.instance.command.RelativeUpdateTimerCommand)

Example 3 with ProcessInstanceDesc

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

the class ProcessInstanceAdminServiceImpl method cancelNodeInstance.

@Override
public void cancelNodeInstance(long processInstanceId, long nodeInstanceId) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new CancelNodeInstanceCommand(processInstanceId, nodeInstanceId));
}
Also used : CancelNodeInstanceCommand(org.jbpm.kie.services.impl.admin.commands.CancelNodeInstanceCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 4 with ProcessInstanceDesc

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

the class ProcessInstanceAdminServiceImpl method getProcessNodes.

@Override
public Collection<ProcessNode> getProcessNodes(long processInstanceId) throws ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    Collection<ProcessNode> nodes = processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new ListNodesCommand(processInstanceId));
    return nodes;
}
Also used : ListNodesCommand(org.jbpm.kie.services.impl.admin.commands.ListNodesCommand) ProcessNode(org.jbpm.services.api.admin.ProcessNode) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 5 with ProcessInstanceDesc

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

the class ProcessInstanceAdminServiceImpl method updateTimer.

@Override
public void updateTimer(long processInstanceId, long timerId, long delay, long period, int repeatLimit) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new UpdateTimerCommand(processInstanceId, timerId, delay, period, repeatLimit));
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) RelativeUpdateTimerCommand(org.jbpm.process.instance.command.RelativeUpdateTimerCommand) UpdateTimerCommand(org.jbpm.process.instance.command.UpdateTimerCommand)

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