Search in sources :

Example 6 with BAMTaskEventListener

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();
}
Also used : JPATaskLifeCycleEventListener(org.jbpm.services.task.audit.JPATaskLifeCycleEventListener) BAMTaskEventListener(org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener) Before(org.junit.Before)

Example 7 with BAMTaskEventListener

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);
}
Also used : StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) BAMTaskEventListener(org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener) TaskFluent(org.jbpm.services.task.utils.TaskFluent) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService) JPATaskLifeCycleEventListener(org.jbpm.services.task.audit.JPATaskLifeCycleEventListener) EntityManager(javax.persistence.EntityManager) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 8 with BAMTaskEventListener

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());
    }
}
Also used : JPATaskLifeCycleEventListener(org.jbpm.services.task.audit.JPATaskLifeCycleEventListener) BAMTaskEventListener(org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) EntityManagerFactory(javax.persistence.EntityManagerFactory) DeploymentDescriptorManager(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager) AmbiguousResolutionException(javax.enterprise.inject.AmbiguousResolutionException) JPATaskLifeCycleEventListener(org.jbpm.services.task.audit.JPATaskLifeCycleEventListener) TaskLifeCycleEventListener(org.kie.api.task.TaskLifeCycleEventListener)

Aggregations

BAMTaskEventListener (org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener)8 JPATaskLifeCycleEventListener (org.jbpm.services.task.audit.JPATaskLifeCycleEventListener)7 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)2 EntityManager (javax.persistence.EntityManager)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 DeploymentDescriptorManager (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager)2 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 PostConstruct (javax.annotation.PostConstruct)1 AmbiguousResolutionException (javax.enterprise.inject.AmbiguousResolutionException)1 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)1 StandaloneJtaStrategy (org.jbpm.process.audit.strategy.StandaloneJtaStrategy)1 HumanTaskConfigurator (org.jbpm.services.task.HumanTaskConfigurator)1 LoadBalanceAssignmentStrategy (org.jbpm.services.task.assignment.impl.strategy.LoadBalanceAssignmentStrategy)1 BAMTaskSummaryImpl (org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl)1 TaskFluent (org.jbpm.services.task.utils.TaskFluent)1 Test (org.junit.Test)1 KieSession (org.kie.api.runtime.KieSession)1