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);
}
Aggregations