19 package org.turro.warnings;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.stream.Stream;
25 import org.turro.annotation.ElephantWarning;
26 import org.turro.dossier.db.DossierPU;
27 import org.turro.dossier.entity.CategoryRequest;
28 import org.turro.dossier.entity.ParticipantRequest;
29 import org.turro.elephant.context.Application;
30 import org.turro.i18n.I_;
41 return I_.
get(
"Dossiers");
49 return Collections.EMPTY_LIST;
52 private List<IWarning> createModel() {
53 List<IWarning> warnings =
new ArrayList<>();
55 requests.forEach((request) -> {
56 checkParticipantRequest(warnings, request);
59 try(Stream<CategoryRequest> requests =
new DossierPU().stream(CategoryRequest.class,
"select c from CategoryRequest c")) {
60 requests.forEach((request) -> {
61 checkCategoryRequest(warnings, request);
67 private void checkParticipantRequest(List<IWarning> warnings, ParticipantRequest request) {
68 Warning warning =
new Warning();
69 warning.setEntity(request.getDossier());
70 warning.addMessage(I_.format(
"Pending request from %s", request.getIContact().getName()));
71 if(!warning.getMessages().isEmpty()) {
72 warnings.add(warning);
76 private void checkCategoryRequest(List<IWarning> warnings, CategoryRequest request) {
77 Warning warning =
new Warning();
78 warning.setEntity(request.getCategory());
79 warning.addMessage(I_.format(
"Pending request from %s", request.getIContact().getName()));
80 if(!warning.getMessages().isEmpty()) {
81 warnings.add(warning);
boolean isInRole(String role)
static Application getApplication()
static String get(String msg)
List< IWarning > getWarnings()