use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class UserTaskServiceImpl method setPriority.
@Override
public void setPriority(String deploymentId, Long taskId, int priority) {
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).setPriority(taskId, priority);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class UserTaskServiceImpl method getCommentsByTaskId.
@Override
public List<Comment> getCommentsByTaskId(String deploymentId, Long taskId) {
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 Collections.emptyList();
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
return ((InternalTaskService) taskService).getAllCommentsByTaskId(taskId);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.internal.task.api.InternalTaskService 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.internal.task.api.InternalTaskService 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.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class SingletonRuntimeManager method init.
public void init() {
// TODO should we proxy/wrap the ksession so we capture dispose.destroy method calls?
String location = getLocation();
Long knownSessionId = getPersistedSessionId(location, identifier);
InternalTaskService internalTaskService = newTaskService(taskServiceFactory);
boolean owner = false;
TransactionManager tm = null;
if (environment.usePersistence()) {
tm = getTransactionManagerInternal(environment.getEnvironment());
owner = tm.begin();
}
try {
if (knownSessionId > 0) {
try {
this.singleton = new SynchronizedRuntimeImpl(factory.findKieSessionById(knownSessionId), internalTaskService);
} catch (RuntimeException e) {
// in case session with known id was found
}
}
if (this.singleton == null) {
this.singleton = new SynchronizedRuntimeImpl(factory.newKieSession(), internalTaskService);
persistSessionId(location, identifier, singleton.getKieSession().getIdentifier());
}
((RuntimeEngineImpl) singleton).setManager(this);
TaskContentRegistry.get().addMarshallerContext(getIdentifier(), new ContentMarshallerContext(environment.getEnvironment(), environment.getClassLoader()));
configureRuntimeOnTaskService(internalTaskService, singleton);
registerItems(this.singleton);
attachManager(this.singleton);
this.registry.register(this);
if (tm != null) {
tm.commit(owner);
}
} catch (Exception e) {
if (tm != null) {
tm.rollback(owner);
}
throw new RuntimeException("Exception while initializing runtime manager " + this.identifier, e);
}
}
Aggregations