changeset 756:d4d765729a04

Simply delete a messung object (the db uses on delete cascade)
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 03 Nov 2015 09:15:59 +0100
parents 6b4764c19ced
children bc789d180439
files src/main/java/de/intevation/lada/rest/MessungService.java
diffstat 1 files changed, 2 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/MessungService.java	Mon Nov 02 10:01:01 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/MessungService.java	Tue Nov 03 09:15:59 2015 +0100
@@ -362,45 +362,7 @@
             return new Response(false, 697, null);
         }
 
-        QueryBuilder<LMesswert> mwBuilder =
-            new QueryBuilder<LMesswert>(
-                defaultRepo.entityManager("land"), LMesswert.class);
-        mwBuilder.and("messungsId", messungObj.getId());
-        QueryBuilder<LKommentarM> mkBuilder =
-            new QueryBuilder<LKommentarM>(
-                defaultRepo.entityManager("land"), LKommentarM.class);
-        mkBuilder.and("messungsId", messungObj.getId());
-        QueryBuilder<LStatusProtokoll> msBuilder =
-            new QueryBuilder<LStatusProtokoll>(
-                defaultRepo.entityManager("land"), LStatusProtokoll.class);
-        msBuilder.and("messungsId", messungObj.getId());
-
-        List<LMesswert> messwerte =
-            (List<LMesswert>)defaultRepo.filter(mwBuilder.getQuery(), "land").getData();
-        List<LKommentarM> kommentare =
-            (List<LKommentarM>)defaultRepo.filter(mkBuilder.getQuery(), "land").getData();
-        List<LStatusProtokoll> status =
-            (List<LStatusProtokoll>)defaultRepo.filter(msBuilder.getQuery(), "land").getData();
-
-        if (!messwerte.isEmpty() ||
-            !kommentare.isEmpty() ||
-            !status.isEmpty()
-        ) {
-            return new Response(false, 696, messung);
-        }
-
-        /* Create a query and request the messungTranslation object for the
-         * messung*/
-        QueryBuilder<MessungTranslation> builder =
-            new QueryBuilder<MessungTranslation>(
-                defaultRepo.entityManager("land"), MessungTranslation.class);
-        builder.and("messungs", messungObj.getId());
-        Response messungTrans = defaultRepo.filter(builder.getQuery(), "land");
-        MessungTranslation messungTransObj = ((List<MessungTranslation>)messungTrans.getData()).get(0);
-        /* Delete the messung translation object*/
-        defaultRepo.delete(messungTransObj, "land");
-        /* Delete the probe object*/
-        Response response = defaultRepo.delete(messungObj, "land");
-        return response;
+        /* Delete the messung object*/
+        return defaultRepo.delete(messungObj, "land");
     }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)