Expand my Community achievements bar.

OSGI: Help creating an Adaptive Form Task using Java

Avatar

Level 7

 

I am trying to create a task using an Adaptive form, input data, etc. - Just like the Assign Task but, I want to accomplish this via Java API.  The reason is because I need to create a bunch of parallel tasks and the workflow needs to block until they are all completed (don't worry about resolving data conflicts).

 

I am successfully creating a task using the code below. 

I'm noticing in the CRX that an Assign Task is really a "WorkItem" and not necessarily a Task - let me clarify

I have a custom component that creates a Task.  Immediately, when I check the instance in CRX, the task is in the History node although it's in my Inbox.

If I use the ootb Assign Task, it is uner the WorkItems node.  

I can't find methods to create a workitem or assign information to the task.

I don't know if I need it but, I assume it has something to do with the Task.DEFAULT_TASK_TYPE.

From the jcr, the Assign Task creates a subtype of forms:assigntask.

 

Anyway, I need some help to mimic the Assign Task feature in Java code.  Is there an API to that service?

 

Any direction would be helpful.  Thanks.

 

TaskManagerFactory taskManagerFactory = taskManager.getTaskManagerFactory();

Task task = taskManagerFactory.newTask(Task.DEFAULT_TASK_TYPE);
task.setName("This is the title of the task");
task.setDescription("This is the description of the task");
task.setInstructions("These are the instructions!");
task.setPriority(InboxItem.Priority.HIGH);
task.setProperty("taskStartDate", new Date());
task.setProperty("taskDueDate", new Date());
task.setProperty("superCustomProperty", "superCustomValue");
task.setCurrentAssignee("admin");
List<TaskAction> taskActions = new ArrayList<TaskAction>();
taskActions.add(taskManagerFactory.newTaskAction("Done1"));
taskActions.add(taskManagerFactory.newTaskAction("Done2"));
task.setActions(taskActions);
taskManager.createTask(task);

 

 

UPDATE: just had an idea - create a component that spawns a bunch of subworkflows that contains the Assign Task. Then, watch them for completion.  Gonna try that for now.

0 Replies