Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/validation/rules/status/StatusFolge.java @ 1035:4d95cc7f0a43 schema-update
Updated status workflow.
* Using status_kombi instead of status_wert and status_stufe
* new service for status_kombi
* updated validators
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 31 Aug 2016 15:52:15 +0200 |
parents | 1c41c7b8f7c2 |
children | f92c96efa976 |
comparison
equal
deleted
inserted
replaced
1034:61354a9fa58d | 1035:4d95cc7f0a43 |
---|---|
8 package de.intevation.lada.validation.rules.status; | 8 package de.intevation.lada.validation.rules.status; |
9 | 9 |
10 import java.util.List; | 10 import java.util.List; |
11 | 11 |
12 import javax.inject.Inject; | 12 import javax.inject.Inject; |
13 | |
14 import org.apache.log4j.Logger; | |
13 | 15 |
14 import de.intevation.lada.model.land.StatusProtokoll; | 16 import de.intevation.lada.model.land.StatusProtokoll; |
15 import de.intevation.lada.model.stammdaten.StatusKombi; | 17 import de.intevation.lada.model.stammdaten.StatusKombi; |
16 import de.intevation.lada.model.stammdaten.StatusReihenfolge; | 18 import de.intevation.lada.model.stammdaten.StatusReihenfolge; |
17 import de.intevation.lada.util.annotation.RepositoryConfig; | 19 import de.intevation.lada.util.annotation.RepositoryConfig; |
28 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> | 30 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> |
29 */ | 31 */ |
30 @ValidationRule("Status") | 32 @ValidationRule("Status") |
31 public class StatusFolge implements Rule { | 33 public class StatusFolge implements Rule { |
32 | 34 |
35 @Inject Logger logger; | |
36 | |
33 @Inject | 37 @Inject |
34 @RepositoryConfig(type=RepositoryType.RO) | 38 @RepositoryConfig(type=RepositoryType.RO) |
35 private Repository repository; | 39 private Repository repository; |
36 | 40 |
37 @Override | 41 @Override |
38 public Violation execute(Object object) { | 42 public Violation execute(Object object) { |
39 /* | |
40 StatusProtokoll status = (StatusProtokoll)object; | 43 StatusProtokoll status = (StatusProtokoll)object; |
41 QueryBuilder<StatusKombi> kombi = new QueryBuilder<StatusKombi>( | |
42 repository.entityManager("stamm"), | |
43 StatusKombi.class); | |
44 kombi.and("stufeId", status.getStatusStufe()); | |
45 kombi.and("wertId", status.getStatusWert()); | |
46 List<StatusKombi> result = | |
47 repository.filterPlain(kombi.getQuery(), "stamm"); | |
48 if (result.isEmpty()) { | |
49 Violation violation = new Violation(); | |
50 violation.addError("status", 632); | |
51 return violation; | |
52 } | |
53 | 44 |
54 // Get the previous status | 45 // Get the previous status |
55 QueryBuilder<LStatusProtokoll> lastFilter = | 46 QueryBuilder<StatusProtokoll> lastFilter = |
56 new QueryBuilder<LStatusProtokoll>( | 47 new QueryBuilder<StatusProtokoll>( |
57 repository.entityManager("land"), | 48 repository.entityManager("land"), |
58 LStatusProtokoll.class); | 49 StatusProtokoll.class); |
59 | 50 |
60 lastFilter.and("messungsId", status.getMessungsId()); | 51 lastFilter.and("messungsId", status.getMessungsId()); |
61 lastFilter.orderBy("datum", true); | 52 lastFilter.orderBy("datum", true); |
62 List<LStatusProtokoll> protos = | 53 List<StatusProtokoll> protos = |
63 repository.filterPlain(lastFilter.getQuery(), "land"); | 54 repository.filterPlain(lastFilter.getQuery(), "land"); |
64 if (protos.isEmpty()) { | 55 if (protos.isEmpty()) { |
65 return null; | 56 return null; |
66 } | 57 } |
67 LStatusProtokoll last = protos.get(protos.size() - 1); | 58 StatusProtokoll last = protos.get(protos.size() - 1); |
68 QueryBuilder<StatusKombi> kombi2 = kombi.getEmptyBuilder(); | |
69 kombi2.and("stufeId", last.getStatusStufe()); | |
70 kombi2.and("wertId", last.getStatusWert()); | |
71 List<StatusKombi> result2 = | |
72 repository.filterPlain(kombi2.getQuery(), "stamm"); | |
73 if (result2.isEmpty()) { | |
74 Violation violation = new Violation(); | |
75 violation.addError("status", 632); | |
76 return violation; | |
77 } | |
78 QueryBuilder<StatusReihenfolge> folgeFilter = | 59 QueryBuilder<StatusReihenfolge> folgeFilter = |
79 new QueryBuilder<StatusReihenfolge>( | 60 new QueryBuilder<StatusReihenfolge>( |
80 repository.entityManager("stamm"), | 61 repository.entityManager("stamm"), |
81 StatusReihenfolge.class); | 62 StatusReihenfolge.class); |
82 folgeFilter.and("von", result2.get(0).getId()); | 63 folgeFilter.and("vonId", last.getStatusKombi()); |
83 folgeFilter.and("zu", result.get(0).getId()); | 64 folgeFilter.and("zuId", status.getStatusKombi()); |
84 List<StatusReihenfolge> reihenfolge = | 65 List<StatusReihenfolge> reihenfolge = |
85 repository.filterPlain(folgeFilter.getQuery(), "stamm"); | 66 repository.filterPlain(folgeFilter.getQuery(), "stamm"); |
86 if (reihenfolge.isEmpty()) { | 67 if (reihenfolge.isEmpty()) { |
87 Violation violation = new Violation(); | 68 Violation violation = new Violation(); |
88 violation.addError("status", 632); | 69 violation.addError("status", 632); |
89 return violation; | 70 return violation; |
90 } | 71 } |
91 | 72 |
92 return null;*/ | 73 return null; |
93 | |
94 Violation violation = new Violation(); | |
95 violation.addError("status", 000); | |
96 return violation; | |
97 } | 74 } |
98 } | 75 } |