Search in sources :

Example 1 with AuditLogEntry

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());
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) ProcessInstanceEntity(io.zeebe.monitor.entity.ProcessInstanceEntity) Transactional(javax.transaction.Transactional) FlowElement(io.camunda.zeebe.model.bpmn.instance.FlowElement) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) ElementInstanceEntity(io.zeebe.monitor.entity.ElementInstanceEntity) HashMap(java.util.HashMap) Controller(org.springframework.stereotype.Controller) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) List(java.util.List) ProcessInstanceDto(io.zeebe.monitor.rest.dto.ProcessInstanceDto) ByteArrayInputStream(java.io.ByteArrayInputStream) ProcessesViewController.getBpmnElementInfos(io.zeebe.monitor.rest.ProcessesViewController.getBpmnElementInfos) Map(java.util.Map) Optional(java.util.Optional) GetMapping(org.springframework.web.bind.annotation.GetMapping) Pageable(org.springframework.data.domain.Pageable) PageableDefault(org.springframework.data.web.PageableDefault) AuditLogEntry(io.zeebe.monitor.rest.dto.AuditLogEntry) IncidentEntity(io.zeebe.monitor.entity.IncidentEntity) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) AuditLogEntry(io.zeebe.monitor.rest.dto.AuditLogEntry) ByteArrayInputStream(java.io.ByteArrayInputStream) HashMap(java.util.HashMap) FlowElement(io.camunda.zeebe.model.bpmn.instance.FlowElement)

Aggregations

Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)1 FlowElement (io.camunda.zeebe.model.bpmn.instance.FlowElement)1 ElementInstanceEntity (io.zeebe.monitor.entity.ElementInstanceEntity)1 IncidentEntity (io.zeebe.monitor.entity.IncidentEntity)1 ProcessInstanceEntity (io.zeebe.monitor.entity.ProcessInstanceEntity)1 ProcessesViewController.getBpmnElementInfos (io.zeebe.monitor.rest.ProcessesViewController.getBpmnElementInfos)1 AuditLogEntry (io.zeebe.monitor.rest.dto.AuditLogEntry)1 ProcessInstanceDto (io.zeebe.monitor.rest.dto.ProcessInstanceDto)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Transactional (javax.transaction.Transactional)1 Pageable (org.springframework.data.domain.Pageable)1 PageableDefault (org.springframework.data.web.PageableDefault)1 Controller (org.springframework.stereotype.Controller)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1