Search in sources :

Example 31 with TaskFluent

use of org.jbpm.services.task.utils.TaskFluent in project jbpm by kiegroup.

the class AdHocUserTaskServiceImpl method addTask.

@Override
public long addTask(final String taskName, int priority, Date dueDate, final List<String> users, List<String> groups, String identity, String taskformName, String deploymentId, Long processInstanceId, Map<String, Object> params, boolean autoStart, boolean autoClaim) {
    TaskFluent taskFluent = new TaskFluent().setName(taskName).setPriority(priority).setDueDate(dueDate).setFormName(taskformName);
    if (deploymentId != null && !deploymentId.equals("")) {
        taskFluent.setDeploymentID(deploymentId);
    } else {
        taskFluent.setDeploymentID(null);
    }
    if (processInstanceId > 0) {
        taskFluent.setProcessInstanceId(processInstanceId);
    }
    for (String user : users) {
        taskFluent.addPotentialUser(user);
    }
    for (String group : groups) {
        taskFluent.addPotentialGroup(group);
    }
    taskFluent.setAdminUser("Administrator");
    taskFluent.setAdminGroup("Administrators");
    Task task = taskFluent.getTask();
    if (params == null) {
        params = new HashMap<String, Object>();
    }
    long taskId = nonProcessScopedTaskService.addTask(taskFluent.getTask(), params);
    if (autoStart) {
        nonProcessScopedTaskService.start(taskId, identity);
    }
    if (autoClaim) {
        nonProcessScopedTaskService.claim(taskId, identity);
    }
    return taskId;
}
Also used : Task(org.kie.api.task.model.Task) TaskFluent(org.jbpm.services.task.utils.TaskFluent)

Aggregations

TaskFluent (org.jbpm.services.task.utils.TaskFluent)31 Task (org.kie.api.task.model.Task)26 AuditTask (org.kie.internal.task.api.AuditTask)25 Test (org.junit.Test)24 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)20 QueryFilter (org.kie.internal.query.QueryFilter)17 TaskSummary (org.kie.api.task.model.TaskSummary)14 HashMap (java.util.HashMap)9 TaskEvent (org.kie.internal.task.api.model.TaskEvent)8 TaskVariable (org.kie.internal.task.api.TaskVariable)7 ArrayList (java.util.ArrayList)4 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)2 I18NText (org.kie.api.task.model.I18NText)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 EntityManager (javax.persistence.EntityManager)1 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)1 StandaloneJtaStrategy (org.jbpm.process.audit.strategy.StandaloneJtaStrategy)1 JPATaskLifeCycleEventListener (org.jbpm.services.task.audit.JPATaskLifeCycleEventListener)1