[Lada-commits] [PATCH 3 of 6] Simply delete a messung object (the db uses on delete cascade)

Wald Commits scm-commit at wald.intevation.org
Tue Nov 3 09:24:39 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1446538559 -3600
# Node ID d4d765729a048d4aad7f9c2bdd9d49d8d991dabe
# Parent  6b4764c19cedeadfb478d14891daa779bdf70644
Simply delete a messung object (the db uses on delete cascade)

diff -r 6b4764c19ced -r d4d765729a04 src/main/java/de/intevation/lada/rest/MessungService.java
--- 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");
     }
 }


More information about the Lada-commits mailing list