changeset 562:fffee95c4cb6

Allow parameter 'ortId' to filter locations.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 13 Mar 2015 16:47:52 +0100
parents 20016be6c072
children 4a78dad2c31f
files src/main/java/de/intevation/lada/rest/stamm/LocationService.java
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/stamm/LocationService.java	Fri Mar 13 16:47:21 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/LocationService.java	Fri Mar 13 16:47:52 2015 +0100
@@ -19,6 +19,7 @@
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.log4j.Logger;
@@ -31,6 +32,7 @@
 import de.intevation.lada.util.auth.AuthenticationType;
 import de.intevation.lada.util.auth.Authorization;
 import de.intevation.lada.util.auth.AuthorizationType;
+import de.intevation.lada.util.data.QueryBuilder;
 import de.intevation.lada.util.data.Repository;
 import de.intevation.lada.util.data.RepositoryType;
 import de.intevation.lada.util.rest.Response;
@@ -74,7 +76,17 @@
             logger.debug("User is not authenticated!");
             return new Response(false, 699, null);
         }
-        return defaultRepo.getAll(SOrt.class, "stamm");
+        MultivaluedMap<String, String> params = info.getQueryParameters();
+        if (params.isEmpty() || !params.containsKey("ortId")) {
+            return defaultRepo.getAll(SOrt.class, "stamm");
+        }
+        String probeId = params.getFirst("ortId");
+        QueryBuilder<SOrt> builder =
+            new QueryBuilder<SOrt>(
+                defaultRepo.entityManager("land"),
+                SOrt.class);
+        builder.and("probeId", probeId);
+        return defaultRepo.filter(builder.getQuery(), "stamm");
     }
 
     /**
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)