Package org.jbpm.process.audit

Examples of org.jbpm.process.audit.JPAAuditLogService


    // Audit Log Service logic
   
    @PostConstruct
    public void initAuditLogService() {
        auditLogService = new JPAAuditLogService(emf);
        if( emf == null ) {
            ((JPAAuditLogService) auditLogService).setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
        }
    }
View Full Code Here


        taskResults.put("taskOutputStr", "task-" + procInstId);
        taskService.complete(taskId, USER_ID, taskResults);
   
        assertNull("Process instance has not been finished.", ksession.getProcessInstance(procInstId) );
       
        AuditLogService logService = new JPAAuditLogService(getEmf());
        List<VariableInstanceLog> vils = logService.findVariableInstances(procInstId);
        assertTrue( "No variable instance logs found", vils != null && ! vils.isEmpty() );
        assertTrue( "Too few variable instance logs found", vils.size() > 3 );
    }
View Full Code Here

        cal.roll(Calendar.DAY_OF_YEAR, 1);
        Date tomorrow = cal.getTime();
        cal.roll(Calendar.DAY_OF_YEAR, -2);
        Date yesterday = cal.getTime();
        AuditLogService auditLogService = new JPAAuditLogService(getEmf());
       
        logger.debug( "tomorrow: " + QUERY_PARAM_DATE_FORMAT.format(tomorrow) );
        logger.debug( "yesterday: " + QUERY_PARAM_DATE_FORMAT.format(yesterday) );
        taskQueryBuilder.clear();
        taskQueryBuilder
        .deploymentId(deploymentId)
        .startDateMin(yesterday)
        .endDateMax(tomorrow)
        .processInstanceId(procInstId)
        .processInstanceStatus(ProcessInstance.STATE_COMPLETED)
        .processId(PROCESS_ID)
        .taskId(taskSum.getId())
        .taskStatus(Status.Completed)
        .value("check-" + procInstId)
        .variableId("inputStr");
       
        taskResult = taskService.execute(taskQueryBuilder.createTaskQueryDataCommand());
        assertNotNull( "Null taskResult!", taskResult );
        assertFalse( "No task summaries found.", taskResult.isEmpty() );
        assertEquals( "Num task summaries found.", 1, taskResult.size() );
        assertEquals( taskSum.getId(), taskResult.get(0).getId() );
       
        RemoteServicesQueryCommandBuilder varLogQueryBuilder = new RemoteServicesQueryCommandBuilder();
       
        varLogQueryBuilder
        .deploymentId(deploymentId)
        .startDateMin(yesterday)
        .endDateMax(tomorrow)
        .processInstanceId(procInstId)
        .processInstanceStatus(ProcessInstance.STATE_COMPLETED)
        .processId(PROCESS_ID)
        .taskId(taskSum.getId())
        .taskStatus(Status.Completed)
        .like().value("*-" + procInstId)
        .variableId("input*");

        List<org.kie.api.runtime.manager.audit.VariableInstanceLog> varResult
            = ((AuditLogService) engine.getAuditLogService()).queryVariableInstanceLogs(varLogQueryBuilder.getQueryData());

        assertNotNull( "Null var Result!", varResult );
        assertFalse( "No var logs found.", varResult.isEmpty() );
        assertEquals( "Num var logs found.", 1, varResult.size() );
        for( org.kie.api.runtime.manager.audit.VariableInstanceLog log : varResult ) {
            assertTrue( "Incorrect var value: " + log.getValue(), log.getValue().endsWith("-" + procInstId) );
            assertTrue( "Incorrect var name: " + log.getVariableId(), log.getVariableId().startsWith("input") );
        }
       
        RemoteServicesQueryCommandBuilder procLogQueryBuilder = new RemoteServicesQueryCommandBuilder();
      
        ParametrizedQuery<ProcessInstanceLog> procQuery = auditLogService.processInstanceLogQuery().processInstanceId(procInstId).buildQuery();
        List<ProcessInstanceLog> procLogs = procQuery.getResultList();
        assertFalse( "No proc logs?!?", procLogs.isEmpty() );
      
        ParametrizedQuery<org.kie.api.runtime.manager.audit.VariableInstanceLog> varQuery
        = auditLogService.variableInstanceLogQuery()
        .intersect()
        .processInstanceId(procInstId)
        .last()
        .like().value("*-" + procInstId)
        .variableId("input*")
        .buildQuery();
       
        List<org.kie.api.runtime.manager.audit.VariableInstanceLog> varLogs = varQuery.getResultList();
        assertFalse( "No last var logs?!?", varLogs.isEmpty() );
   
        procLogQueryBuilder
        .taskId(taskSum.getId())
        .taskStatus(Status.Completed)
        .like().value("*-" + procInstId)
        .variableId("input*");
       
        List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> procResult
            = ((AuditLogService) engine.getAuditLogService()).queryProcessInstanceLogs(procLogQueryBuilder.getQueryData());
       
        assertNotNull( "Null proc Result!", procResult );
        assertFalse( "No proc logs found.", procResult.isEmpty() );
        assertEquals( "Num proc logs found.", 1, procResult.size() );
        org.kie.api.runtime.manager.audit.ProcessInstanceLog procLog = procResult.get(0);
        assertEquals( "Incorrect proc inst id: " + procLog.getProcessInstanceId(), procInstId, procLog.getProcessInstanceId().longValue() );
        assertEquals( "Incorrect external id: " + procLog.getExternalId(), deploymentId, procLog.getExternalId() );
     
        // variable value
        org.kie.api.runtime.manager.audit.VariableInstanceLog varLog = varLogs.get(0);
        varQuery = auditLogService.variableInstanceLogQuery()
        .intersect()
        .processInstanceId(procInstId)
        .last()
        .variableValue(varLog.getVariableId(), varLog.getValue())
        .buildQuery();
       
        varLogs = varQuery.getResultList();
        assertFalse( "No last var logs?!?", varLogs.isEmpty() );
        assertEquals( "Num varlogs", 1, varLogs.size());
        assertEquals( "Num varlogs", varLog, varLogs.get(0) );
  
        // variable value regex
        varQuery = auditLogService.variableInstanceLogQuery()
        .intersect()
        .processInstanceId(procInstId)
        .like()
        .variableValue(varLog.getVariableId(), "*" + varLog.getValue().substring(3))
        .buildQuery();
View Full Code Here

    //@PersistenceUnit(unitName = "org.jbpm.domain")
  private EntityManagerFactory emf;

  public List<ActiveNodeInfo> getActiveNodeInfo(String instanceId) {
      AuditLogService auditLogService = new JPAAuditLogService(emf);
    ProcessInstanceLog processInstance = auditLogService.findProcessInstance(new Long(instanceId));
    if (processInstance == null) {
      throw new IllegalArgumentException("Could not find process instance " + instanceId);
    }
    Map<String, NodeInstanceLog> nodeInstances = new HashMap<String, NodeInstanceLog>();
    for (NodeInstanceLog nodeInstance: auditLogService.findNodeInstances(new Long(instanceId))) {
      if (nodeInstance.getType() == NodeInstanceLog.TYPE_ENTER) {
        nodeInstances.put(nodeInstance.getNodeInstanceId(), nodeInstance);
      } else {
        nodeInstances.remove(nodeInstance.getNodeInstanceId());
      }
View Full Code Here

        DeploymentService mockDepService = mock(DeploymentService.class);
        when(mockDepService.getRuntimeManager(anyString())).thenReturn(runtimeManager);
        userTaskService.setDeploymentService(mockDepService);
        queryResource.setProcessRequestBean(processRequestBean);
       
        processRequestBean.setAuditLogService(new JPAAuditLogService(getEmf()));
       
        queryTaskHelper = new InternalTaskQueryHelper(queryResource);
        queryProcInstHelper = new InternalProcInstQueryHelper(queryResource);
    }
View Full Code Here

        taskResults.put("taskOutputStr", "task-" + procInstId);
        taskService.complete(taskId, USER_ID, taskResults);
   
        assertNull("Process instance has not been finished.", ksession.getProcessInstance(procInstId) );
       
        AuditLogService logService = new JPAAuditLogService(getEmf());
        List<VariableInstanceLog> vils = logService.findVariableInstances(procInstId);
        assertTrue( "No variable instance logs found", vils != null && ! vils.isEmpty() );
        assertTrue( "Too few variable instance logs found", vils.size() > 3 );
    }
View Full Code Here

        taskResults.put("taskOutputStr", new MyType("task-" + procInstId, random.nextInt()));
        taskService.complete(taskId, USER_ID, taskResults);
   
        assertNull("Process instance has not been finished.", ksession.getProcessInstance(procInstId) );
       
        AuditLogService logService = new JPAAuditLogService(getEmf());
        List<VariableInstanceLog> vils = logService.findVariableInstances(procInstId);
        assertTrue( "No variable instance logs found", vils != null && ! vils.isEmpty() );
        assertTrue( "Too few variable instance logs found: " + vils.size(), vils.size() >= 3 );
       
        VariableInstanceLog lastVil = null;
        for( VariableInstanceLog vil : vils ) {
View Full Code Here

TOP

Related Classes of org.jbpm.process.audit.JPAAuditLogService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.