Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/validation/LMessungValidator.java @ 263:2098db2e8fbd M1
Code documentation.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 17 Jul 2013 09:40:53 +0200 |
parents | 0de24f5e7c01 |
children | 53417b61391c |
comparison
equal
deleted
inserted
replaced
262:f4b359aa9127 | 263:2098db2e8fbd |
---|---|
31 | 31 |
32 @Inject | 32 @Inject |
33 @Named("lmessungrepository") | 33 @Named("lmessungrepository") |
34 private Repository messungRepository; | 34 private Repository messungRepository; |
35 | 35 |
36 /** | |
37 * Validate a LMessung object. | |
38 * | |
39 * @param object The object to validate. | |
40 * @param update The database operation. | |
41 * TRUE indicates that the object should be updated, FALSE | |
42 * if the object is a new Object. | |
43 * @return Map containing warnings. | |
44 * @throws ValidationException | |
45 */ | |
36 @Override | 46 @Override |
37 public Map<String, Integer> validate(Object object, boolean update) | 47 public Map<String, Integer> validate(Object object, boolean update) |
38 throws ValidationException { | 48 throws ValidationException { |
39 Map<String, Integer> warnings = new HashMap<String, Integer>(); | 49 Map<String, Integer> warnings = new HashMap<String, Integer>(); |
40 if (!(object instanceof LMessung)) { | 50 if (!(object instanceof LMessung)) { |
50 validateUniqueNebenprobenNr(messung, warnings); | 60 validateUniqueNebenprobenNr(messung, warnings); |
51 } | 61 } |
52 return warnings; | 62 return warnings; |
53 } | 63 } |
54 | 64 |
65 /** | |
66 * Check if the object has a 'Nebenproben Nr.'. | |
67 * | |
68 * @param messung The LMessung object. | |
69 * @param warnings The map containing warnings. | |
70 * @throws ValidationException | |
71 */ | |
55 private void validateHasNebenprobenNr( | 72 private void validateHasNebenprobenNr( |
56 LMessung messung, | 73 LMessung messung, |
57 Map<String, Integer> warnings) | 74 Map<String, Integer> warnings) |
58 throws ValidationException { | 75 throws ValidationException { |
59 if (messung.getNebenprobenNr() == null || | 76 if (messung.getNebenprobenNr() == null || |
60 messung.getNebenprobenNr().equals("")) { | 77 messung.getNebenprobenNr().equals("")) { |
61 warnings.put("nebenprobenNr", 631); | 78 warnings.put("nebenprobenNr", 631); |
62 } | 79 } |
63 } | 80 } |
64 | 81 |
82 /** | |
83 * Check if the 'Nebenproben Nr' is unique. | |
84 * | |
85 * @param messung The LMessung object. | |
86 * @param warnings The map containing warnings. | |
87 * @throws ValidationException | |
88 */ | |
65 private void validateUniqueNebenprobenNr( | 89 private void validateUniqueNebenprobenNr( |
66 LMessung messung, | 90 LMessung messung, |
67 Map<String, Integer> warnings) | 91 Map<String, Integer> warnings) |
68 throws ValidationException { | 92 throws ValidationException { |
69 QueryBuilder<LMessung> builder = | 93 QueryBuilder<LMessung> builder = |
83 throw new ValidationException(errors); | 107 throw new ValidationException(errors); |
84 } | 108 } |
85 } | 109 } |
86 } | 110 } |
87 | 111 |
112 /** | |
113 * Check if the 'Messdatum' is after the 'Probennahmedatum'. | |
114 * | |
115 * @param messung The LMessung object. | |
116 * @param warnings The map containing warinings. | |
117 * @throws ValidationException | |
118 */ | |
88 private void validateDatum( | 119 private void validateDatum( |
89 LMessung messung, | 120 LMessung messung, |
90 Map<String, Integer> warnings) | 121 Map<String, Integer> warnings) |
91 throws ValidationException{ | 122 throws ValidationException{ |
92 String probeId = messung.getProbeId(); | 123 String probeId = messung.getProbeId(); |