annotate src/main/java/de/intevation/lada/validation/rules/messprogramm/HasAllMandatory.java @ 1028:1c41c7b8f7c2 schema-update

Updated server application to new database model. THIS IS STILL WIP!!!
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 08 Jul 2016 15:32:36 +0200
parents b943e956b767
children
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.
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 * Validates if the Messprogramm has Datenbasis.
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.getMstId() == null
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 | "".equals(messprogramm.getMstId())) {
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 violation.addError("mstlabor", 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.getLaborMstId() == null
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 | "".equals(messprogramm.getLaborMstId())) {
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.getDatenbasisId() == null) {
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 violation.addError("datenbasisId", 631);
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 }
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 if (messprogramm.getProbenartId() == null) {
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39 violation.addError("probenartId", 631);
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40 }
989
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
41 if (messprogramm.getProbenintervall() == null
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
42 | "".equals(messprogramm.getProbenintervall())) {
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
43 violation.addError("probenintervall", 631);
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
44 }
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
45 if (messprogramm.getTeilintervallVon() == null) {
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
46 violation.addError("teilintervallVon", 631);
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
47 }
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
48 if (messprogramm.getTeilintervallBis() == null) {
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
49 violation.addError("teilintervallBis", 631);
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
50 }
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
51 if (messprogramm.getGueltigVon() == null) {
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
52 violation.addError("gueltigVon", 631);
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
53 }
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
54 if (messprogramm.getGueltigBis() == null) {
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
55 violation.addError("gueltigBis", 631);
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
56 }
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
57 if (messprogramm.getOrtId() == null) {
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
58 violation.addError("ortId", 631);
b943e956b767 Complement mandatory fields for messprogramm.
Tom Gottfried <tom@intevation.de>
parents: 982
diff changeset
59 }
982
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
60
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
61 return violation.hasErrors()
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
62 ? violation
962439442e48 Check mandatory fields before saving a Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
63 :null;
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 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)