TaskQueryDataCommand cmd = taskQueryBuilder.createTaskQueryDataCommand();
List<TaskSummary> taskResult = taskService.execute(cmd);
assertNotNull( "Null taskResult!", taskResult );
assertFalse( "No task summaries found.", taskResult.isEmpty() );
TaskSummary taskSum = taskResult.get(0);
String deploymentId = taskSum.getDeploymentId();
long procInstId = taskSum.getProcessInstanceId();
Calendar cal = GregorianCalendar.getInstance();
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