Search in sources :

Example 6 with InternalTaskService

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);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 7 with InternalTaskService

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);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 8 with InternalTaskService

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;
}
Also used : RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) TaskCommand(org.jbpm.services.task.commands.TaskCommand) UpdateTaskCommand(org.jbpm.kie.services.impl.admin.commands.UpdateTaskCommand)

Example 9 with InternalTaskService

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);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 10 with InternalTaskService

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);
    }
}
Also used : TransactionManager(org.drools.persistence.api.TransactionManager) InternalTaskService(org.kie.internal.task.api.InternalTaskService) IOException(java.io.IOException) ContentMarshallerContext(org.kie.internal.task.api.ContentMarshallerContext)

Aggregations

InternalTaskService (org.kie.internal.task.api.InternalTaskService)44 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)35 TaskService (org.kie.api.task.TaskService)27 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)25 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)20 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)18 UserTaskService (org.jbpm.services.api.UserTaskService)17 TaskSummary (org.kie.api.task.model.TaskSummary)13 Test (org.junit.Test)12 KieSession (org.kie.api.runtime.KieSession)11 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)9 Task (org.kie.api.task.model.Task)5 TaskCleanUpProcessEventListener (org.jbpm.services.task.admin.listener.TaskCleanUpProcessEventListener)4 AuditService (org.kie.api.runtime.manager.audit.AuditService)4 I18NText (org.kie.api.task.model.I18NText)4 Date (java.util.Date)3 EntityManager (javax.persistence.EntityManager)3 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)3