use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class LocalWithCustomCallbackTaskAuditTest method setup.
@Before
public void setup() {
pds = setupPoolingDataSource();
emf = Persistence.createEntityManagerFactory("org.jbpm.services.task");
callback = new NullGroupsUserGroupCallback();
this.taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).listener(new JPATaskLifeCycleEventListener(true)).listener(new BAMTaskEventListener(true)).userGroupCallback(callback).getTaskService();
this.taskAuditService = TaskAuditServiceFactory.newTaskAuditServiceConfigurator().setTaskService(taskService).getTaskAuditService();
}
use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class AuditTaskDeleteTest method produceTaskInstances.
private void produceTaskInstances() {
InternalTaskService taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).listener(new JPATaskLifeCycleEventListener(true)).listener(new BAMTaskEventListener(true)).getTaskService();
Calendar cal = randomCal();
String processId = "process";
taskTestData = new Task[10];
List<ProcessInstanceLog> pLogs = new ArrayList<>();
for (int i = 0; i < 10; i++) {
cal.add(Calendar.HOUR_OF_DAY, 1);
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").setProcessId(processId + i).setProcessInstanceId(i).setCreatedOn(cal.getTime()).getTask();
taskService.addTask(task, new HashMap<String, Object>());
taskTestData[i] = task;
ProcessInstanceLog plog = buildCompletedProcessInstance(i);
pLogs.add(plog);
}
StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
EntityManager em = jtaHelper.getEntityManager();
Object tx = jtaHelper.joinTransaction(em);
pLogs.forEach(pl -> {
em.persist(pl);
});
jtaHelper.leaveTransaction(em, tx);
}
use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class HumanTaskServiceProducer method configureHumanTaskConfigurator.
protected void configureHumanTaskConfigurator(HumanTaskConfigurator configurator) {
configurator.environment(getEnvironment(identityProvider)).entityManagerFactory(emf).userGroupCallback(safeGet(userGroupCallback)).userInfo(safeGet(userInfo));
DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
DeploymentDescriptor descriptor = manager.getDefaultDescriptor();
// in case there is descriptor with enabled audit register then by default
if (!descriptor.getAuditMode().equals(AuditMode.NONE)) {
JPATaskLifeCycleEventListener listener = new JPATaskLifeCycleEventListener(false);
BAMTaskEventListener bamListener = new BAMTaskEventListener(false);
// if the audit persistence unit is different than default for the engine perform proper init
if (!"org.jbpm.domain".equals(descriptor.getAuditPersistenceUnit())) {
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(descriptor.getAuditPersistenceUnit());
listener = new JPATaskLifeCycleEventListener(emf);
bamListener = new BAMTaskEventListener(emf);
}
configurator.listener(listener);
configurator.listener(bamListener);
}
// next proceed with registration of further listeners as cdi injections
try {
for (TaskLifeCycleEventListener listener : taskListeners) {
configurator.listener(listener);
logger.debug("Registering listener {}", listener);
}
} catch (Exception e) {
logger.debug("Cannot add listeners to task service due to {}", e.getMessage());
}
}
Aggregations