use of io.zeebe.monitor.rest.dto.AuditLogEntry in project zeebe-simple-monitor by camunda-community-hub.
the class InstancesAuditLogViewController method fillViewDetailsIntoDto.
@Override
protected void fillViewDetailsIntoDto(ProcessInstanceEntity instance, List<ElementInstanceEntity> events, List<IncidentEntity> incidents, Map<Long, String> elementIdsForKeys, Map<String, Object> model, Pageable pageable, ProcessInstanceDto dto) {
final var bpmnModelInstance = processRepository.findByKey(instance.getProcessDefinitionKey()).map(w -> new ByteArrayInputStream(w.getResource().getBytes())).map(Bpmn::readModelFromStream);
final Map<String, String> flowElements = new HashMap<>();
bpmnModelInstance.ifPresent(bpmn -> {
bpmn.getModelElementsByType(FlowElement.class).forEach(e -> flowElements.put(e.getId(), Optional.ofNullable(e.getName()).orElse("")));
dto.setBpmnElementInfos(getBpmnElementInfos(bpmn));
});
final List<AuditLogEntry> auditLogEntries = events.stream().skip((long) pageable.getPageSize() * pageable.getPageNumber()).map(e -> {
final AuditLogEntry entry = new AuditLogEntry();
entry.setKey(e.getKey());
entry.setFlowScopeKey(e.getFlowScopeKey());
entry.setElementId(e.getElementId());
entry.setElementName(flowElements.getOrDefault(e.getElementId(), ""));
entry.setBpmnElementType(e.getBpmnElementType());
entry.setState(e.getIntent());
entry.setTimestamp(Instant.ofEpochMilli(e.getTimestamp()).toString());
return entry;
}).limit(pageable.getPageSize()).collect(Collectors.toList());
dto.setAuditLogEntries(auditLogEntries);
addPaginationToModel(model, pageable, events.size());
}
Aggregations