diff --git a/pom.xml b/pom.xml index 17795080..0b4f4d25 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,8 @@ 5.5.0 + 8.0.1.Final + 17 ${version.java} @@ -198,6 +200,12 @@ mysql-connector-j + + org.hibernate.validator + hibernate-validator + ${version.hibernate.validator} + + diff --git a/src/main/java/io/zeebe/monitor/entity/ProcessEntity.java b/src/main/java/io/zeebe/monitor/entity/ProcessEntity.java index a23fb8bd..937d4c2a 100644 --- a/src/main/java/io/zeebe/monitor/entity/ProcessEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/ProcessEntity.java @@ -19,6 +19,9 @@ import org.hibernate.Length; @Entity(name = "PROCESS") +@Table(indexes = { + @Index(name = "process_bpmnProcessId", columnList = "BPMN_PROCESS_ID_"), +}) public class ProcessEntity { @Id @Column(name = "KEY_") diff --git a/src/main/java/io/zeebe/monitor/repository/ProcessRepository.java b/src/main/java/io/zeebe/monitor/repository/ProcessRepository.java index d4844831..ffaed601 100644 --- a/src/main/java/io/zeebe/monitor/repository/ProcessRepository.java +++ b/src/main/java/io/zeebe/monitor/repository/ProcessRepository.java @@ -20,10 +20,12 @@ import java.util.Collection; import java.util.List; import java.util.Optional; + import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; +import org.springframework.transaction.annotation.Transactional; public interface ProcessRepository extends PagingAndSortingRepository, CrudRepository { @@ -40,4 +42,7 @@ List getElementInstanceStatisticsByKeyAndIntentIn( @Param("key") long key, @Param("intents") Collection intents, @Param("excludeElementTypes") Collection excludeElementTypes); + + @Transactional(readOnly = true) + List findByBpmnProcessIdStartsWith(String bpmnProcessId); } diff --git a/src/main/java/io/zeebe/monitor/rest/ProcessesViewController.java b/src/main/java/io/zeebe/monitor/rest/ProcessesViewController.java index fef1d8e9..799bf21f 100644 --- a/src/main/java/io/zeebe/monitor/rest/ProcessesViewController.java +++ b/src/main/java/io/zeebe/monitor/rest/ProcessesViewController.java @@ -35,12 +35,12 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import jakarta.validation.constraints.Size; import org.camunda.bpm.model.xml.instance.ModelElementInstance; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @Controller @@ -59,26 +59,42 @@ public class ProcessesViewController extends AbstractViewController { @GetMapping("/") public String index(final Map model, final Pageable pageable) { - return processList(model, pageable); + return processList(model, pageable, Optional.empty()); } @GetMapping("/views/processes") - public String processList(final Map model, final Pageable pageable) { - - final long count = processRepository.count(); - - final List processes = new ArrayList<>(); - for (final ProcessEntity processEntity : processRepository.findAll(pageable)) { - final ProcessDto dto = toDto(processEntity); - processes.add(dto); + public String processList(final Map model, final Pageable pageable, @RequestParam("bpmnProcessId") Optional<@Size(min = 3) String> bpmnProcessId) { + + if (bpmnProcessId.isPresent()) { + final List processes = new ArrayList<>(); + for (final ProcessEntity processEntity : processRepository.findByBpmnProcessIdStartsWith(bpmnProcessId.get())) { + final ProcessDto dto = toDto(processEntity); + processes.add(dto); + } + + model.put("processes", processes); + model.put("bpmnProcessId", bpmnProcessId.get()); + model.put("count", processes.size()); + + addPaginationToModel(model, Pageable.ofSize(Integer.MAX_VALUE), processes.size()); + addDefaultAttributesToModel(model); + } else { + final long count = processRepository.count(); + + final List processes = new ArrayList<>(); + for (final ProcessEntity processEntity : processRepository.findAll(pageable)) { + final ProcessDto dto = toDto(processEntity); + processes.add(dto); + } + + model.put("processes", processes); + model.remove("bpmnProcessId"); + model.put("count", count); + + addPaginationToModel(model, pageable, count); + addDefaultAttributesToModel(model); } - model.put("processes", processes); - model.put("count", count); - - addPaginationToModel(model, pageable, count); - addDefaultAttributesToModel(model); - return "process-list-view"; } diff --git a/src/main/resources/templates/process-list-view.html b/src/main/resources/templates/process-list-view.html index 40d705ab..01011c95 100644 --- a/src/main/resources/templates/process-list-view.html +++ b/src/main/resources/templates/process-list-view.html @@ -9,6 +9,14 @@ New Deployment +
+ + + +
+
@@ -17,6 +25,7 @@ + @@ -28,6 +37,7 @@ + {{#processes}} @@ -54,4 +64,4 @@ document.addEventListener('DOMContentLoaded', function(){ listSort('timestamp','process-deployment-time') }, false); - \ No newline at end of file +
Process Definition Key BPMN process id Version