changeset 347:6aecd10279b5

mered.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 30 Aug 2013 12:58:02 +0200
parents 977582f7c0ae (diff) eef763835ef5 (current diff)
children 4612c43127b6
files
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/InfoService.java	Fri Aug 30 11:18:26 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/InfoService.java	Fri Aug 30 12:58:02 2013 +0200
@@ -15,6 +15,9 @@
 import de.intevation.lada.auth.Authentication;
 import de.intevation.lada.auth.AuthenticationException;
 import de.intevation.lada.auth.AuthenticationResponse;
+import de.intevation.lada.data.QueryBuilder;
+import de.intevation.lada.data.Repository;
+import de.intevation.lada.model.SNetzBetreiber;
 
 class Info {
     String user;
@@ -62,6 +65,10 @@
     @Named("ldapauth")
     private Authentication authentication;
 
+    @Inject
+    @Named("readonlyrepository")
+    private Repository readonlyRepo;
+
     /**
      * Request SQL-Queries
      *
@@ -84,15 +91,23 @@
             String user = authentication.getUserName(headers);
             AuthenticationResponse ar = authentication.authorizedGroups(headers);
             List<String> groups = ar.getNetzbetreiber();
+            QueryBuilder<SNetzBetreiber> builder =
+                new QueryBuilder<SNetzBetreiber>(
+                    readonlyRepo.getEntityManager(), SNetzBetreiber.class);
+            for (String g : groups) {
+                builder.or("netzbetreiberId", g);
+            }
+            Response nResponse = readonlyRepo.filter(builder.getQuery());
+            List<SNetzBetreiber> netzbetr = (List<SNetzBetreiber>)nResponse.getData();
             String gString = "";
             boolean first = true;
-            for(String g : groups) {
+            for(SNetzBetreiber nb : netzbetr) {
                 if (first) {
-                    gString += g;
+                    gString += nb.getNetzbetreiber();
                     first = false;
                 }
                 else {
-                    gString += ", " + g;
+                    gString += ", " + nb.getNetzbetreiber();
                 }
             }
             //TODO: This is the best way to get the version.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)