[Lada-commits] [PATCH 6 of 6] Filter orte by netzbetreiber

Wald Commits scm-commit at wald.intevation.org
Fri Jan 27 15:19:41 CET 2017


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1485526493 -3600
# Node ID e4cb532fde82174667360e9ba4d46ab5af49af36
# Parent  a1323ef2c3309b2fa940b84f2b1d0128bbc53b66
Filter orte by netzbetreiber.

diff -r a1323ef2c330 -r e4cb532fde82 src/main/java/de/intevation/lada/rest/stamm/OrtService.java
--- a/src/main/java/de/intevation/lada/rest/stamm/OrtService.java	Fri Jan 27 15:14:12 2017 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/OrtService.java	Fri Jan 27 15:14:53 2017 +0100
@@ -34,6 +34,7 @@
 import de.intevation.lada.util.annotation.RepositoryConfig;
 import de.intevation.lada.util.auth.Authorization;
 import de.intevation.lada.util.auth.AuthorizationType;
+import de.intevation.lada.util.auth.UserInfo;
 import de.intevation.lada.util.data.QueryBuilder;
 import de.intevation.lada.util.data.Repository;
 import de.intevation.lada.util.data.RepositoryType;
@@ -180,7 +181,16 @@
             orte = repository.filterPlain(builder.getQuery(), "stamm");
         }
         else {
-            orte = repository.getAllPlain(Ort.class, "stamm");
+            UserInfo user = authorization.getInfo(request);
+            QueryBuilder<Ort> builder =
+                new QueryBuilder<Ort>(
+                    repository.entityManager("stamm"),
+                    Ort.class
+                );
+            for (String nb : user.getNetzbetreiber()) {
+               builder.or("netzbetreiberId", nb);
+            }
+            orte = repository.filterPlain(builder.getQuery(), "stamm");
         }
 
         int size = orte.size();


More information about the Lada-commits mailing list