Search in sources :

Example 1 with ActiveScope

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);
}
Also used : ActiveScope(io.zeebe.monitor.rest.dto.ActiveScope) PROCESS_INSTANCE_COMPLETED_INTENTS(io.zeebe.monitor.rest.ProcessesViewController.PROCESS_INSTANCE_COMPLETED_INTENTS) NOT_FOUND(org.springframework.http.HttpStatus.NOT_FOUND) ProcessInstanceEntity(io.zeebe.monitor.entity.ProcessInstanceEntity) PROCESS_INSTANCE_ENTERED_INTENTS(io.zeebe.monitor.rest.ProcessesViewController.PROCESS_INSTANCE_ENTERED_INTENTS) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ProcessInstanceRepository(io.zeebe.monitor.repository.ProcessInstanceRepository) ArrayList(java.util.ArrayList) ElementInstanceState(io.zeebe.monitor.rest.dto.ElementInstanceState) Map(java.util.Map) ActiveScope(io.zeebe.monitor.rest.dto.ActiveScope) StreamSupport(java.util.stream.StreamSupport) Pageable(org.springframework.data.domain.Pageable) IncidentEntity(io.zeebe.monitor.entity.IncidentEntity) ResponseStatusException(org.springframework.web.server.ResponseStatusException) ProcessRepository(io.zeebe.monitor.repository.ProcessRepository) EXCLUDE_ELEMENT_TYPES(io.zeebe.monitor.rest.ProcessesViewController.EXCLUDE_ELEMENT_TYPES) ElementInstanceEntity(io.zeebe.monitor.entity.ElementInstanceEntity) IOException(java.io.IOException) IncidentRepository(io.zeebe.monitor.repository.IncidentRepository) Instant(java.time.Instant) Mustache(com.samskivert.mustache.Mustache) ElementInstanceRepository(io.zeebe.monitor.repository.ElementInstanceRepository) Collectors(java.util.stream.Collectors) List(java.util.List) Template(com.samskivert.mustache.Template) ProcessInstanceDto(io.zeebe.monitor.rest.dto.ProcessInstanceDto) BpmnElementType(io.camunda.zeebe.protocol.record.value.BpmnElementType) Writer(java.io.Writer) ArrayList(java.util.ArrayList)

Aggregations

Mustache (com.samskivert.mustache.Mustache)1 Template (com.samskivert.mustache.Template)1 BpmnElementType (io.camunda.zeebe.protocol.record.value.BpmnElementType)1 ElementInstanceEntity (io.zeebe.monitor.entity.ElementInstanceEntity)1 IncidentEntity (io.zeebe.monitor.entity.IncidentEntity)1 ProcessInstanceEntity (io.zeebe.monitor.entity.ProcessInstanceEntity)1 ElementInstanceRepository (io.zeebe.monitor.repository.ElementInstanceRepository)1 IncidentRepository (io.zeebe.monitor.repository.IncidentRepository)1 ProcessInstanceRepository (io.zeebe.monitor.repository.ProcessInstanceRepository)1 ProcessRepository (io.zeebe.monitor.repository.ProcessRepository)1 EXCLUDE_ELEMENT_TYPES (io.zeebe.monitor.rest.ProcessesViewController.EXCLUDE_ELEMENT_TYPES)1 PROCESS_INSTANCE_COMPLETED_INTENTS (io.zeebe.monitor.rest.ProcessesViewController.PROCESS_INSTANCE_COMPLETED_INTENTS)1 PROCESS_INSTANCE_ENTERED_INTENTS (io.zeebe.monitor.rest.ProcessesViewController.PROCESS_INSTANCE_ENTERED_INTENTS)1 ActiveScope (io.zeebe.monitor.rest.dto.ActiveScope)1 ElementInstanceState (io.zeebe.monitor.rest.dto.ElementInstanceState)1 ProcessInstanceDto (io.zeebe.monitor.rest.dto.ProcessInstanceDto)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1