use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class LocalTaskAuditWithDeadlineTest method setup.
@Before
public void setup() {
TaskDeadlinesServiceImpl.reset();
pds = setupPoolingDataSource();
emf = Persistence.createEntityManagerFactory("org.jbpm.services.task");
this.taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).listener(new JPATaskLifeCycleEventListener(true)).listener(new BAMTaskEventListener(true)).getTaskService();
this.taskAuditService = TaskAuditServiceFactory.newTaskAuditServiceConfigurator().setTaskService(taskService).getTaskAuditService();
}
use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class TotalCompletionTimeAssignmentStrategyTest method setUp.
@Before
public void setUp() throws Exception {
System.setProperty("org.jbpm.task.assignment.enabled", "true");
System.setProperty("org.jbpm.task.assignment.strategy", "LoadBalance");
System.setProperty("org.jbpm.task.assignment.loadbalance.calculator", "org.jbpm.services.task.assignment.impl.TotalCompletionTimeLoadCalculator");
System.setProperty("org.jbpm.services.task.assignment.taskduration.timetolive", "1000");
pds = setupPoolingDataSource();
emf = Persistence.createEntityManagerFactory("org.jbpm.services.task");
AssignmentServiceProvider.override(new LoadBalanceAssignmentStrategy());
this.taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).listener(new JPATaskLifeCycleEventListener(true)).listener(new BAMTaskEventListener(true)).getTaskService();
// giving ourselves lots of room
taskIds = new Long[100];
forceBAMEntries();
}
use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class LocalTaskAuditTest method setup.
@Before
public void setup() {
pds = setupPoolingDataSource();
emf = Persistence.createEntityManagerFactory("org.jbpm.services.task");
this.taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).listener(new JPATaskLifeCycleEventListener(true)).listener(new BAMTaskEventListener(true)).getTaskService();
this.taskAuditService = TaskAuditServiceFactory.newTaskAuditServiceConfigurator().setTaskService(taskService).getTaskAuditService();
}
use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class ProcessPersistenceHumanTaskOnLaneTest method testProcessWithBAMListener.
@SuppressWarnings("unchecked")
@Test
public void testProcessWithBAMListener() throws Exception {
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLane.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
((EventService<TaskLifeCycleEventListener>) taskService).registerTaskEventListener(new BAMTaskEventListener(true));
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertProcessInstanceActive(processInstance.getId());
long task1 = -1;
long task2 = -1;
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart");
disposeRuntimeManager();
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLane.bpmn2");
runtimeEngine = getRuntimeEngine();
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
((EventService<TaskLifeCycleEventListener>) taskService).registerTaskEventListener(new BAMTaskEventListener(true));
// let john execute Task 1
String taskUser = "john";
String locale = "en-UK";
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner(taskUser, locale);
assertEquals(1, list.size());
TaskSummary task = list.get(0);
task1 = task.getId();
taskService.claim(task.getId(), taskUser);
taskService.start(task.getId(), taskUser);
taskService.complete(task.getId(), taskUser, null);
List<Status> reservedOnly = new ArrayList<Status>();
reservedOnly.add(Status.Reserved);
list = taskService.getTasksAssignedAsPotentialOwnerByStatus(taskUser, reservedOnly, locale);
assertEquals(1, list.size());
task = list.get(0);
task2 = task.getId();
taskService.start(task.getId(), taskUser);
taskService.complete(task.getId(), taskUser, null);
assertProcessInstanceCompleted(processInstance.getId());
EntityManager em = getEmf().createEntityManager();
List<BAMTaskSummaryImpl> bamLogs = em.createQuery("from BAMTaskSummaryImpl").getResultList();
em.close();
assertNotNull(bamLogs);
assertEquals(2, bamLogs.size());
List<Long> taskIdsFromBAM = new ArrayList<Long>();
for (BAMTaskSummaryImpl bamEntry : bamLogs) {
taskIdsFromBAM.add(bamEntry.getTaskId());
}
assertTrue(taskIdsFromBAM.contains(task1));
assertTrue(taskIdsFromBAM.contains(task2));
}
use of org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener in project jbpm by kiegroup.
the class TaskServiceEJBImpl method configureDelegate.
@PostConstruct
public void configureDelegate() {
UserGroupCallback callback = UserDataServiceProvider.getUserGroupCallback();
HumanTaskConfigurator configurator = HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).userGroupCallback(callback);
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);
}
delegate = (InternalTaskService) configurator.getTaskService();
}
Aggregations