comparison src/main/java/de/intevation/lada/validation/LProbeValidator.java @ 263:2098db2e8fbd M1

Code documentation.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 17 Jul 2013 09:40:53 +0200
parents 0de24f5e7c01
children aadc0bb0dc1d
comparison
equal deleted inserted replaced
262:f4b359aa9127 263:2098db2e8fbd
35 private LOrtRepository ortRepository; 35 private LOrtRepository ortRepository;
36 36
37 /** 37 /**
38 * Validate a LProbe object. 38 * Validate a LProbe object.
39 * 39 *
40 * @param probe The LProbe object. 40 * @param probe The LProbe object.
41 * @param update The database operation.
42 * TRUE indicates that the object should be updated, FALSE
43 * if the object is a new Object.
44 * @return Map containing warnings.
41 */ 45 */
42 @Override 46 @Override
43 public Map<String, Integer> validate(Object probe, boolean update) 47 public Map<String, Integer> validate(Object probe, boolean update)
44 throws ValidationException { 48 throws ValidationException {
45 Map<String, Integer>warnings = new HashMap<String, Integer>(); 49 Map<String, Integer>warnings = new HashMap<String, Integer>();
55 validateUWB(p, warnings); 59 validateUWB(p, warnings);
56 validateHauptProbenNummer(p, warnings); 60 validateHauptProbenNummer(p, warnings);
57 return warnings; 61 return warnings;
58 } 62 }
59 63
64 /**
65 * Check if the 'Hauptproben Nr' is unique.
66 *
67 * @param p The LProbe object.
68 * @param warnings The map containing warnings.
69 * @throws ValidationException
70 */
60 private void validateHauptProbenNummer(LProbe p, Map<String, Integer> warnings) 71 private void validateHauptProbenNummer(LProbe p, Map<String, Integer> warnings)
61 throws ValidationException { 72 throws ValidationException {
62 String hpn = p.getHauptprobenNr(); 73 String hpn = p.getHauptprobenNr();
63 QueryBuilder<LProbe> builder = 74 QueryBuilder<LProbe> builder =
64 new QueryBuilder<LProbe>( 75 new QueryBuilder<LProbe>(
71 errors.put("hauptprobenNr", 611); 82 errors.put("hauptprobenNr", 611);
72 throw new ValidationException(errors, warnings); 83 throw new ValidationException(errors, warnings);
73 } 84 }
74 } 85 }
75 86
87 /**
88 * Check if the LProbe object has 'Entnahmeort'.
89 *
90 * @param probe
91 * @param warnings
92 */
76 private void validateEntnahmeOrt(LProbe probe, Map<String, Integer> warnings) { 93 private void validateEntnahmeOrt(LProbe probe, Map<String, Integer> warnings) {
77 String pid = probe.getProbeId(); 94 String pid = probe.getProbeId();
78 95
79 QueryBuilder<LOrt> builder = 96 QueryBuilder<LOrt> builder =
80 new QueryBuilder<LOrt>( 97 new QueryBuilder<LOrt>(
85 if (((List<LOrt>)response.getData()).isEmpty()) { 102 if (((List<LOrt>)response.getData()).isEmpty()) {
86 warnings.put("entnahmeOrt", 631); 103 warnings.put("entnahmeOrt", 631);
87 } 104 }
88 } 105 }
89 106
107 /**
108 * Check if 'Probenahmeende' is after 'Probenahmebeginn'.
109 *
110 * @param probe The LProbe object.
111 * @param warnings The map containing warnings.
112 */
90 private void validateProbenahmeBegin(LProbe probe, Map<String, Integer> warnings) { 113 private void validateProbenahmeBegin(LProbe probe, Map<String, Integer> warnings) {
91 Date begin = probe.getProbeentnahmeBeginn(); 114 Date begin = probe.getProbeentnahmeBeginn();
92 if (begin == null) { 115 if (begin == null) {
93 warnings.put("probeentnahmeBegin", 631); 116 warnings.put("probeentnahmeBegin", 631);
94 } 117 }
95 else if (begin.after(new Date())){ 118 else if (begin.after(new Date())){
96 warnings.put("probeentnahmeBegin", 661); 119 warnings.put("probeentnahmeBegin", 661);
97 } 120 }
98 } 121 }
99 122
123 /**
124 * Check if the LProbe object has a 'Umweltbereich'.
125 *
126 * @param probe The LProbe object.
127 * @param warnings The map containing warnings.
128 */
100 private void validateUWB(LProbe probe, Map<String, Integer> warnings) { 129 private void validateUWB(LProbe probe, Map<String, Integer> warnings) {
101 String uwb = probe.getUmwId(); 130 String uwb = probe.getUmwId();
102 if (uwb == null || uwb.equals("")) { 131 if (uwb == null || uwb.equals("")) {
103 warnings.put("uwb", 631); 132 warnings.put("uwb", 631);
104 } 133 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)