Skip to content

Commit

Permalink
Merge pull request #14 from latera/HBW-253
Browse files Browse the repository at this point in the history
HBW-253 Send webhook on task event when task has been persisted
  • Loading branch information
GideonEXE authored Jan 24, 2020
2 parents 280a535 + bb7039e commit 794684e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/org/camunda/latera/bss/taskListeners/TaskNotifier.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@ package org.camunda.latera.bss.taskListeners
import org.camunda.bpm.engine.identity.UserQuery
import org.camunda.bpm.engine.delegate.TaskListener
import org.camunda.bpm.engine.delegate.DelegateTask
import org.camunda.bpm.engine.impl.context.Context;
import org.camunda.bpm.engine.impl.cfg.TransactionListener
import org.camunda.bpm.engine.impl.cfg.TransactionState
import org.camunda.bpm.engine.impl.interceptor.CommandContext
import org.camunda.latera.bss.connectors.HOMS

class TaskNotifier implements TaskListener {
void notify(DelegateTask task) {
String assignee = getAssignee(task)
List<String> candidates = getCandidates(task)

new HOMS(task.getExecution()).sendTaskEvent(
task.getId(),
task.getEventName(),
[*candidates, assignee].unique(false) - null
)
TransactionListener listener = new TransactionListener() {
void execute(CommandContext commandContext) {
String assignee = getAssignee(task)
List<String> candidates = getCandidates(task)

new HOMS(task.getExecution()).sendTaskEvent(
task.getId(),
task.getEventName(),
[*candidates, assignee].unique(false) - null
)
}
}

Context.getCommandContext()
.getTransactionContext()
.addTransactionListener(TransactionState.COMMITTED, listener)
}

private static String getAssignee(DelegateTask task) {
Expand Down

0 comments on commit 794684e

Please sign in to comment.