changeset 344:976f4e4df363

Validate haputprobennummer on probe update and create.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 30 Aug 2013 10:31:30 +0200
parents aee36709a8e8
children eef763835ef5 977582f7c0ae
files src/main/java/de/intevation/lada/validation/LProbeValidator.java
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/validation/LProbeValidator.java	Fri Aug 30 10:30:28 2013 +0200
+++ b/src/main/java/de/intevation/lada/validation/LProbeValidator.java	Fri Aug 30 10:31:30 2013 +0200
@@ -9,11 +9,14 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 
+import com.sun.istack.Builder;
+
 import de.intevation.lada.data.LOrtRepository;
 import de.intevation.lada.data.LProbeRepository;
 import de.intevation.lada.data.QueryBuilder;
 import de.intevation.lada.model.LOrt;
 import de.intevation.lada.model.LProbe;
+import de.intevation.lada.model.LProbeInfo;
 import de.intevation.lada.rest.Response;
 
 /**
@@ -57,9 +60,7 @@
         validateEntnahmeOrt(p, warnings);
         validateProbenahmeBegin(p, warnings);
         validateUWB(p, warnings);
-        if (!update) {
-            validateHauptProbenNummer(p, warnings);
-        }
+        validateHauptProbenNummer(p, warnings);
         return warnings;
     }
 
@@ -72,6 +73,15 @@
      */
     private void validateHauptProbenNummer(LProbe p, Map<String, Integer> warnings)
     throws ValidationException {
+        Response pInfo =
+            probeRepository.findById(LProbeInfo.class, p.getProbeId());
+        List<LProbeInfo> pList = (List<LProbeInfo>)pInfo.getData();
+        if (!(pList == null) && !pList.isEmpty()) {
+            LProbeInfo probe = pList.get(0);
+            if (probe.getHauptprobenNr().equals(p.getHauptprobenNr())) {
+                return;
+            }
+        }
         String hpn = p.getHauptprobenNr();
         QueryBuilder<LProbe> builder =
             new QueryBuilder<LProbe>(
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)