Mercurial > lada > lada-server
changeset 624:5de1a5d7f377
Replaced native query by criteria query.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 20 Apr 2015 17:06:31 +0200 |
parents | da56b05604ae |
children | e4b4d66589a4 |
files | src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java |
diffstat | 1 files changed, 11 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java Mon Apr 20 17:04:50 2015 +0200 +++ b/src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java Mon Apr 20 17:06:31 2015 +0200 @@ -167,20 +167,21 @@ } private UserInfo getGroupsFromDB(String roles) { - String nativeQuery = "select * from stammdaten.auth where ldap_group in "; - roles = roles.replaceAll(",", "', '"); - nativeQuery += "('" + roles + "')"; - Query query = repository.entityManager("land").createNativeQuery(nativeQuery); + QueryBuilder<Auth> builder = new QueryBuilder<Auth>( + repository.entityManager("stamm"), + Auth.class); + builder.andIn("ldapGroup", Arrays.asList(roles.split(","))); + Response response = repository.filter(builder.getQuery(), "stamm"); @SuppressWarnings("unchecked") - List<Object[]> result = query.getResultList(); + List<Auth> auth = (List<Auth>)response.getData(); List<String> netzbetreiber = new ArrayList<String>(); List<String> messstellen = new ArrayList<String>(); - for (Object[] row: result) { - if (row[2] != null) { - netzbetreiber.add(row[2].toString()); + for (Auth a : auth) { + if (a.getNetzBetreiber() != null) { + netzbetreiber.add(a.getNetzBetreiber()); } - if (row[3] != null) { - messstellen.add(row[3].toString()); + if (a.getMessStelle() != null) { + messstellen.add(a.getMessStelle()); } } UserInfo userInfo = new UserInfo();