Search in sources :

Example 1 with VariableUpdateEntry

use of io.zeebe.monitor.rest.dto.VariableUpdateEntry in project zeebe-simple-monitor by camunda-community-hub.

the class InstancesVariableListController 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 Map<VariableTuple, List<VariableEntity>> variablesByScopeAndName = variableRepository.findByProcessInstanceKey(instance.getKey(), pageable).stream().collect(Collectors.groupingBy(v -> new VariableTuple(v.getScopeKey(), v.getName())));
    variablesByScopeAndName.forEach((scopeKeyName, variables) -> {
        final VariableEntry variableDto = new VariableEntry();
        final long scopeKey = scopeKeyName.scopeKey;
        variableDto.setScopeKey(scopeKey);
        variableDto.setElementId(elementIdsForKeys.get(scopeKey));
        variableDto.setName(scopeKeyName.name);
        final VariableEntity lastUpdate = variables.get(variables.size() - 1);
        variableDto.setValue(lastUpdate.getValue());
        variableDto.setTimestamp(Instant.ofEpochMilli(lastUpdate.getTimestamp()).toString());
        final List<VariableUpdateEntry> varUpdates = variables.stream().map(v -> {
            final VariableUpdateEntry varUpdate = new VariableUpdateEntry();
            varUpdate.setValue(v.getValue());
            varUpdate.setTimestamp(Instant.ofEpochMilli(v.getTimestamp()).toString());
            return varUpdate;
        }).collect(Collectors.toList());
        variableDto.setUpdates(varUpdates);
        dto.getVariables().add(variableDto);
    });
    final long count = variableRepository.countByProcessInstanceKey(instance.getKey());
    addPaginationToModel(model, pageable, count);
}
Also used : VariableEntry(io.zeebe.monitor.rest.dto.VariableEntry) PathVariable(org.springframework.web.bind.annotation.PathVariable) ProcessInstanceEntity(io.zeebe.monitor.entity.ProcessInstanceEntity) Transactional(javax.transaction.Transactional) Autowired(org.springframework.beans.factory.annotation.Autowired) ElementInstanceEntity(io.zeebe.monitor.entity.ElementInstanceEntity) Controller(org.springframework.stereotype.Controller) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) ProcessInstanceDto(io.zeebe.monitor.rest.dto.ProcessInstanceDto) VariableEntity(io.zeebe.monitor.entity.VariableEntity) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping) VariableRepository(io.zeebe.monitor.repository.VariableRepository) VariableUpdateEntry(io.zeebe.monitor.rest.dto.VariableUpdateEntry) Pageable(org.springframework.data.domain.Pageable) PageableDefault(org.springframework.data.web.PageableDefault) IncidentEntity(io.zeebe.monitor.entity.IncidentEntity) VariableEntry(io.zeebe.monitor.rest.dto.VariableEntry) VariableEntity(io.zeebe.monitor.entity.VariableEntity) VariableUpdateEntry(io.zeebe.monitor.rest.dto.VariableUpdateEntry) List(java.util.List)

Aggregations

ElementInstanceEntity (io.zeebe.monitor.entity.ElementInstanceEntity)1 IncidentEntity (io.zeebe.monitor.entity.IncidentEntity)1 ProcessInstanceEntity (io.zeebe.monitor.entity.ProcessInstanceEntity)1 VariableEntity (io.zeebe.monitor.entity.VariableEntity)1 VariableRepository (io.zeebe.monitor.repository.VariableRepository)1 ProcessInstanceDto (io.zeebe.monitor.rest.dto.ProcessInstanceDto)1 VariableEntry (io.zeebe.monitor.rest.dto.VariableEntry)1 VariableUpdateEntry (io.zeebe.monitor.rest.dto.VariableUpdateEntry)1 Instant (java.time.Instant)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Transactional (javax.transaction.Transactional)1 Autowired (org.springframework.beans.factory.annotation.Autowired)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 PathVariable (org.springframework.web.bind.annotation.PathVariable)1