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;
}
Aggregations