Java Code Examples for org.camunda.bpm.engine.impl.task.TaskDefinition#addTaskListener()

The following examples show how to use org.camunda.bpm.engine.impl.task.TaskDefinition#addTaskListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeTaskListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, TaskDefinition taskDefinition) {
  HumanTask humanTask = getDefinition(element);

  List<CamundaTaskListener> listeners = queryExtensionElementsByClass(humanTask, CamundaTaskListener.class);

  for (CamundaTaskListener listener : listeners) {
    TaskListener taskListener = initializeTaskListener(element, activity, context, listener);

    String eventName = listener.getCamundaEvent();
    if (eventName != null) {
      taskDefinition.addTaskListener(eventName, taskListener);

    } else {
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_UPDATE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener);
    }
  }
}
 
Example 2
Source File: RegisterAllBpmnParseListenerTest.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
@Test
public void add_taskListeners_to_already_existin_listeners() {
  final TaskDefinition taskDefinition = new TaskDefinition(mock(TaskFormHandler.class));
  final TaskListener taskListenerFromBpmn = mock(TaskListener.class);
  taskDefinition.addTaskListener(EVENTNAME_ASSIGNMENT, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_COMPLETE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_CREATE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_DELETE, taskListenerFromBpmn);

  parseListener.addTaskListener(taskDefinition);

  assertThat(taskDefinition.getTaskListeners()).hasSize(4);

  assertThat(taskDefinition.getTaskListeners(EVENTNAME_ASSIGNMENT)).containsExactly(taskListenerFromBpmn, taskListener);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_COMPLETE)).containsExactly(taskListenerFromBpmn, taskListener);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_CREATE)).containsExactly(taskListenerFromBpmn, taskListener);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_DELETE)).containsExactly(taskListenerFromBpmn, taskListener);
}
 
Example 3
Source File: RegisterAllBpmnParseListenerTest.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
@Test
public void add_taskListeners_to_already_existin_listeners_with_reactor_listener_first() {
  final TaskDefinition taskDefinition = new TaskDefinition(mock(TaskFormHandler.class));
  final TaskListener taskListenerFromBpmn = mock(TaskListener.class);
  taskDefinition.addTaskListener(EVENTNAME_ASSIGNMENT, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_COMPLETE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_CREATE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_DELETE, taskListenerFromBpmn);

  final RegisterAllBpmnParseListener parseListener = new RegisterAllBpmnParseListener(taskListener, executionListener, true);
  parseListener.addTaskListener(taskDefinition);

  assertThat(taskDefinition.getTaskListeners()).hasSize(4);

  assertThat(taskDefinition.getTaskListeners(EVENTNAME_ASSIGNMENT)).containsExactly(taskListener, taskListenerFromBpmn);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_COMPLETE)).containsExactly(taskListener, taskListenerFromBpmn);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_CREATE)).containsExactly(taskListener, taskListenerFromBpmn);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_DELETE)).containsExactly(taskListener, taskListenerFromBpmn);
}
 
Example 4
Source File: PublishDelegateParseListener.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
private void addTaskListener(TaskDefinition taskDefinition) {
  if (taskListener != null) {
    for (String event : TASK_EVENTS) {
      taskDefinition.addTaskListener(event, taskListener);
    }
  }
}
 
Example 5
Source File: PublishDelegateParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void addTaskListener(TaskDefinition taskDefinition) {
  if (taskListener != null) {
    for (String event : TASK_EVENTS) {
      taskDefinition.addTaskListener(event, taskListener);
    }
  }
}
 
Example 6
Source File: RegisterAllBpmnParseListener.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
void addTaskListener(final TaskDefinition taskDefinition) {
  if(reactorListenerFirstOnUserTask) {
    taskDefinition.setTaskListeners(reactorListenerFirstMap(taskDefinition.getTaskListeners(), TASK_EVENTS, taskListener));
  } else {
    for (final String event : TASK_EVENTS) {
      taskDefinition.addTaskListener(event, taskListener);
    }
  }
}
 
Example 7
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskCreateListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, new CdiEventListener());
}
 
Example 8
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskUpdateListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_UPDATE, TASK_LISTENER);
}
 
Example 9
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskCompleteListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, TASK_LISTENER);
}
 
Example 10
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskCreateListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, TASK_LISTENER);
}
 
Example 11
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskAssignmentListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, TASK_LISTENER);
}
 
Example 12
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskDeleteListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, new CdiEventListener());
}
 
Example 13
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskUpdateListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_UPDATE, new CdiEventListener());
}
 
Example 14
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskCompleteListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, new CdiEventListener());
}
 
Example 15
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTaskAssignmentListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, new CdiEventListener());
}
 
Example 16
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
protected void addTaskDeleteListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, createTaskListener(taskDefinition));
}
 
Example 17
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
protected void addTaskCompleteListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, createTaskListener(taskDefinition));
}
 
Example 18
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
protected void addTaskCreateListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, createTaskListener(taskDefinition));
}
 
Example 19
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
protected void addTaskAssignmentListeners(TaskDefinition taskDefinition) {
  taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, createTaskListener(taskDefinition));
}
 
Example 20
Source File: RegisterAllCmmnTransformListener.java    From camunda-bpm-reactor with Apache License 2.0 4 votes vote down vote up
void addTaskListener(TaskDefinition taskDefinition) {
  for (String event : TASK_EVENTS) {
    taskDefinition.addTaskListener(event, taskListener);
  }
}