[Lada-commits] [PATCH 2 of 5] Replaced native query by criteria query
Wald Commits
scm-commit at wald.intevation.org
Wed Apr 22 09:17:35 CEST 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1429542391 -7200
# Node ID 5de1a5d7f3773b26eebcf8d701be4da9dbcf3adb
# Parent da56b05604aec3bc85d3f08c3d072bc9e964194b
Replaced native query by criteria query.
diff -r da56b05604ae -r 5de1a5d7f377 src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java
--- 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();
More information about the Lada-commits
mailing list