Mercurial > lada > lada-server
annotate src/main/java/de/intevation/lada/validation/rules/messprogramm/HasAllMandatory.java @ 1044:a796e68da1cf
A period with end before start is not meaningful.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 07 Sep 2016 18:17:48 +0200 |
parents | b943e956b767 |
children | 186d602e031a |
rev | line source |
---|---|
982
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
3 * |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
7 */ |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.lada.validation.rules.messprogramm; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.lada.model.land.Messprogramm; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.lada.validation.Violation; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.lada.validation.annotation.ValidationRule; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.lada.validation.rules.Rule; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
15 /** |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
16 * Validation rule for Messprogramm. |
1044
a796e68da1cf
A period with end before start is not meaningful.
Tom Gottfried <tom@intevation.de>
parents:
989
diff
changeset
|
17 * Validates if the Messprogramm has all mandatory fields set. |
982
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
18 */ |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
19 @ValidationRule("Messprogramm") |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
20 public class HasAllMandatory implements Rule { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
21 |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 @Override |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 public Violation execute(Object object) { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
24 Messprogramm messprogramm = (Messprogramm)object; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
25 Violation violation = new Violation(); |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
26 |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
27 if (messprogramm.getNetzbetreiberId() == null |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
28 | "".equals(messprogramm.getNetzbetreiberId())) { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
29 violation.addError("netzbetreiberId", 631); |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
30 } |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
31 if (messprogramm.getMstId() == null |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
32 | "".equals(messprogramm.getMstId())) { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
33 violation.addError("mstlabor", 631); |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
34 } |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
35 if (messprogramm.getLaborMstId() == null |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
36 | "".equals(messprogramm.getLaborMstId())) { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
37 violation.addError("mstlabor", 631); |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
38 } |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
39 if (messprogramm.getDatenbasisId() == null) { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
40 violation.addError("datenbasisId", 631); |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
41 } |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
42 if (messprogramm.getProbenartId() == null) { |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
43 violation.addError("probenartId", 631); |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
44 } |
989
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
45 if (messprogramm.getProbenintervall() == null |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
46 | "".equals(messprogramm.getProbenintervall())) { |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
47 violation.addError("probenintervall", 631); |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
48 } |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
49 if (messprogramm.getTeilintervallVon() == null) { |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
50 violation.addError("teilintervallVon", 631); |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
51 } |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
52 if (messprogramm.getTeilintervallBis() == null) { |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
53 violation.addError("teilintervallBis", 631); |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
54 } |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
55 if (messprogramm.getGueltigVon() == null) { |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
56 violation.addError("gueltigVon", 631); |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
57 } |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
58 if (messprogramm.getGueltigBis() == null) { |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
59 violation.addError("gueltigBis", 631); |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
60 } |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
61 if (messprogramm.getOrtId() == null) { |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
62 violation.addError("ortId", 631); |
b943e956b767
Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
982
diff
changeset
|
63 } |
982
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
64 |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
65 return violation.hasErrors() |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
66 ? violation |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
67 :null; |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
68 } |
962439442e48
Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
69 } |