Search in sources :

Example 96 with UserTaskInstanceDesc

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

the class UserTaskServiceImpl method setDescription.

@Override
public void setDescription(String deploymentId, Long taskId, String description) {
    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 {
        InternalI18NText text = (InternalI18NText) TaskModelProvider.getFactory().newI18NText();
        text.setLanguage("en-UK");
        text.setText(description);
        List<I18NText> names = new ArrayList<I18NText>();
        names.add(text);
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        ((InternalTaskService) taskService).setDescriptions(taskId, names);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) 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) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 97 with UserTaskInstanceDesc

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

the class UserTaskServiceImpl method setExpirationDate.

@Override
public void setExpirationDate(String deploymentId, Long taskId, Date date) {
    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).setExpirationDate(taskId, date);
    } 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 98 with UserTaskInstanceDesc

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

the class UserTaskServiceImpl method saveContent.

@Override
public Long saveContent(String deploymentId, Long taskId, Map<String, Object> values) {
    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;
    }
    if (manager instanceof InternalRuntimeManager) {
        values = process(values, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        return ((InternalTaskService) taskService).addContent(taskId, (Map<String, Object>) values);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) 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 99 with UserTaskInstanceDesc

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

the class UserTaskServiceImpl method getTaskInputContentByTaskId.

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> getTaskInputContentByTaskId(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 null;
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        Task taskInstanceById = taskService.getTaskById(taskId);
        long documentContentId = taskInstanceById.getTaskData().getDocumentContentId();
        if (documentContentId > 0) {
            Content contentById = taskService.getContentById(documentContentId);
            if (contentById == null) {
                return new HashMap<String, Object>();
            }
            ContentMarshallerContext ctx = TaskContentRegistry.get().getMarshallerContext(task.getDeploymentId());
            Object unmarshall = ContentMarshallerHelper.unmarshall(contentById.getContent(), ctx.getEnvironment(), ctx.getClassloader());
            Map<String, Object> data = (Map<String, Object>) unmarshall;
            for (Object variable : data.values()) {
                if (variable instanceof LazyLoaded<?>) {
                    ((LazyLoaded<?>) variable).load();
                }
            }
            return data;
        }
        return new HashMap<String, Object>();
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) Task(org.kie.api.task.model.Task) HashMap(java.util.HashMap) 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) LazyLoaded(org.kie.internal.utils.LazyLoaded) Content(org.kie.api.task.model.Content) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) HashMap(java.util.HashMap) Map(java.util.Map) ContentMarshallerContext(org.kie.internal.task.api.ContentMarshallerContext)

Example 100 with UserTaskInstanceDesc

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

the class UserTaskServiceImpl method deleteContent.

@Override
public void deleteContent(String deploymentId, Long taskId, Long contentId) {
    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).deleteContent(taskId, contentId);
    } 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)

Aggregations

UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)118 Test (org.junit.Test)67 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)36 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)35 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)35 InternalTaskService (org.kie.internal.task.api.InternalTaskService)35 UserTaskService (org.jbpm.services.api.UserTaskService)34 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)34 TaskService (org.kie.api.task.TaskService)34 HashMap (java.util.HashMap)23 QueryContext (org.kie.api.runtime.query.QueryContext)22 ArrayList (java.util.ArrayList)18 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)16 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)16 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)15 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)11 QueryDefinition (org.jbpm.services.api.query.model.QueryDefinition)9 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)7 CorrelationKey (org.kie.internal.process.CorrelationKey)7 AdvancedQueryContext (org.kie.api.runtime.query.AdvancedQueryContext)6