use of org.jbpm.services.api.model.UserTaskInstanceDesc 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;
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImpl method addComment.
@Override
public Long addComment(String deploymentId, Long taskId, String text, String addedBy, Date addedOn) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return null;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
InternalComment comment = (InternalComment) TaskModelProvider.getFactory().newComment();
comment.setText(text);
comment.setAddedAt(addedOn);
comment.setAddedBy(TaskModelProvider.getFactory().newUser(addedBy));
return ((InternalTaskService) taskService).addComment(taskId, comment);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImpl method claim.
@Override
public void claim(String deploymentId, Long taskId, String userId) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
taskService.claim(taskId, userId);
} catch (PermissionDeniedException e) {
throw new TaskNotFoundException(e.getMessage());
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImpl method setSkipable.
@Override
public void setSkipable(String deploymentId, Long taskId, boolean skipable) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
((InternalTaskService) taskService).setSkipable(taskId, skipable);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceImpl method stop.
@Override
public void stop(String deploymentId, Long taskId, String userId) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
taskService.stop(taskId, userId);
} catch (PermissionDeniedException e) {
throw new TaskNotFoundException(e.getMessage());
} finally {
disposeRuntimeEngine(manager, engine);
}
}
Aggregations