use of io.zeebe.monitor.rest.dto.ActiveScope in project zeebe-simple-monitor by camunda-community-hub.
the class AbstractInstanceViewController method fillActiveScopesIntoDto.
protected void fillActiveScopesIntoDto(ProcessInstanceEntity instance, List<ElementInstanceEntity> events, Map<Long, String> elementIdsForKeys, ProcessInstanceDto dto) {
final List<ActiveScope> activeScopes = new ArrayList<>();
if (dto.isRunning()) {
activeScopes.add(new ActiveScope(instance.getKey(), instance.getBpmnProcessId()));
final List<Long> completedElementInstances = events.stream().filter(e -> PROCESS_INSTANCE_COMPLETED_INTENTS.contains(e.getIntent())).map(ElementInstanceEntity::getKey).collect(Collectors.toList());
final List<ActiveScope> activeElementInstances = events.stream().filter(e -> PROCESS_INSTANCE_ENTERED_INTENTS.contains(e.getIntent())).map(ElementInstanceEntity::getKey).filter(id -> !completedElementInstances.contains(id)).map(scopeKey -> new ActiveScope(scopeKey, elementIdsForKeys.get(scopeKey))).collect(Collectors.toList());
activeScopes.addAll(activeElementInstances);
}
dto.setActiveScopes(activeScopes);
}
Aggregations