use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.
the class UserTaskServiceImpl method execute.
@Override
public <T> T execute(String deploymentId, Command<T> command) {
Long processInstanceId = CommonUtils.getProcessInstanceId(command);
RuntimeManager manager = getRuntimeManager(deploymentId, command);
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
return taskService.execute(command);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.
the class UserTaskServiceImpl method getRuntimeManager.
protected RuntimeManager getRuntimeManager(String deploymentId, Command<?> command) {
if (deploymentId == null && command instanceof TaskCommand<?>) {
Long taskId = ((TaskCommand<?>) command).getTaskId();
if (taskId != null) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
deploymentId = task.getDeploymentId();
}
}
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentId);
if (manager == null) {
InternalTaskService internalTaskService = getInternalTaskService();
if (internalTaskService != null) {
manager = new FalbackRuntimeManager(internalTaskService);
} else {
logger.warn("Cannot find runtime manager for deployment {}", deploymentId);
throw new RuntimeException("No runtime manager found for deployment " + deploymentId);
}
}
return manager;
}
use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.
the class UserTaskServiceImpl method getCommentById.
@Override
public Comment getCommentById(String deploymentId, Long taskId, Long commentId) {
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
return ((InternalTaskService) taskService).getCommentById(commentId);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.
the class UserTaskAdminServiceImpl method acknowledgeError.
@Override
public void acknowledgeError(String... errorId) throws ExecutionErrorNotFoundException {
for (String error : errorId) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("errorId", error);
params.put("ack", new Short("0"));
List<ExecutionError> execErrors = commandService.execute(new QueryNameCommand<List<ExecutionError>>("getErrorById", params));
if (execErrors.isEmpty()) {
throw new ExecutionErrorNotFoundException("No execution error found for id " + errorId);
}
ExecutionError errorInstance = execErrors.get(0);
RuntimeManager runtimeManager = RuntimeManagerRegistry.get().getManager(errorInstance.getDeploymentId());
if (runtimeManager != null) {
((AbstractRuntimeManager) runtimeManager).getExecutionErrorManager().getStorage().acknowledge(identityProvider.getName(), errorInstance.getErrorId());
}
}
}
use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.
the class AsyncWorkItemHandlerCmdCallback method onCommandDone.
@Override
public void onCommandDone(CommandContext ctx, ExecutionResults results) {
WorkItem workItem = (WorkItem) ctx.getData("workItem");
logger.debug("About to complete work item {}", workItem);
// find the right runtime to do the complete
RuntimeManager manager = getRuntimeManager(ctx);
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get((Long) ctx.getData("processInstanceId")));
try {
engine.getKieSession().getWorkItemManager().completeWorkItem(workItem.getId(), results == null ? null : results.getData());
} finally {
manager.disposeRuntimeEngine(engine);
}
}
Aggregations