Mercurial > lada > lada-server
changeset 346:977582f7c0ae
Return the netzbetreiber name instead of the id in the info service.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 30 Aug 2013 12:57:09 +0200 |
parents | 976f4e4df363 |
children | 6aecd10279b5 |
files | src/main/java/de/intevation/lada/rest/InfoService.java |
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 10:31:30 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/InfoService.java Fri Aug 30 12:57:09 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.