Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/validation/rules/status/StatusKombination.java @ 780:ec231b0c343d
Added validator and first rule for status.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 13 Nov 2015 13:42:25 +0100 |
parents | |
children | 9a2dcb355d89 |
comparison
equal
deleted
inserted
replaced
779:64adf06df02f | 780:ec231b0c343d |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 package de.intevation.lada.validation.rules.status; | |
9 | |
10 import java.util.List; | |
11 | |
12 import javax.inject.Inject; | |
13 | |
14 import de.intevation.lada.model.land.LStatusProtokoll; | |
15 import de.intevation.lada.model.stamm.StatusKombi; | |
16 import de.intevation.lada.util.annotation.RepositoryConfig; | |
17 import de.intevation.lada.util.data.QueryBuilder; | |
18 import de.intevation.lada.util.data.Repository; | |
19 import de.intevation.lada.util.data.RepositoryType; | |
20 import de.intevation.lada.validation.Violation; | |
21 import de.intevation.lada.validation.annotation.ValidationRule; | |
22 import de.intevation.lada.validation.rules.Rule; | |
23 | |
24 /** | |
25 * Validation rule for status. | |
26 * | |
27 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> | |
28 */ | |
29 @ValidationRule("Status") | |
30 public class StatusKombination implements Rule { | |
31 | |
32 @Inject | |
33 @RepositoryConfig(type=RepositoryType.RO) | |
34 private Repository repository; | |
35 | |
36 @Override | |
37 public Violation execute(Object object) { | |
38 LStatusProtokoll status = (LStatusProtokoll)object; | |
39 QueryBuilder<StatusKombi> kombi = new QueryBuilder<StatusKombi>( | |
40 repository.entityManager("stamm"), | |
41 StatusKombi.class); | |
42 kombi.and("stufeId", status.getStatusStufe()); | |
43 kombi.and("wertId", status.getStatusWert()); | |
44 List<StatusKombi> result = | |
45 repository.filterPlain(kombi.getQuery(), "stamm"); | |
46 if (result.isEmpty()) { | |
47 Violation violation = new Violation(); | |
48 violation.addError("status", 632); | |
49 } | |
50 return null; | |
51 } | |
52 } |