diff options
Diffstat (limited to 'id/server/moa-id-commons/src/main/java')
-rw-r--r-- | id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java index 795981777..20fc4c845 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java @@ -6,6 +6,8 @@ import java.util.Map; import javax.persistence.EntityManager; +import org.apache.commons.lang.StringEscapeUtils; + import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; @@ -22,8 +24,12 @@ public class ConfigurationDBRead { QUERIES.put("getOnlineApplicationWithDBID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id"); QUERIES.put("getAllOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication"); QUERIES.put("getAllActiveOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '1'"); + QUERIES.put("getAllNewOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1'"); QUERIES.put("getMOAIDConfiguration", "select moaidconfiguration from MOAIDConfiguration moaidconfiguration"); QUERIES.put("getUserWithUserID", "select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id"); + QUERIES.put("getNewUserWithUserTokken", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken and userdatabase.isUserRequest = '1'"); + QUERIES.put("getAllNewUsers", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken is null and userdatabase.isUserRequest = '1'"); + QUERIES.put("getUserWithUserBPKWBPK", "select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk"); QUERIES.put("getUserWithUserUsername", "select userdatabase from UserDatabase userdatabase where userdatabase.username = :username"); QUERIES.put("getAllUsers", "select userdatabase from UserDatabase userdatabase"); QUERIES.put("searchOnlineApplicationsWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.friendlyName like :id"); } @@ -32,6 +38,9 @@ public class ConfigurationDBRead { public static OnlineApplication getActiveOnlineApplication(String id) { MiscUtil.assertNotNull(id, "OnlineApplictionID"); Logger.trace("Getting OnlineApplication with ID " + id + " from database."); + + //TODO: check!!! + id = StringEscapeUtils.escapeHtml(id); List result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); @@ -135,6 +144,24 @@ public class ConfigurationDBRead { return result; } + public static List<OnlineApplication> getAllNewOnlineApplications() { + Logger.trace("Get All OnlineApplications from database."); + + List<OnlineApplication> result; + EntityManager session = ConfigurationDBUtils.getCurrentSession(); + + javax.persistence.Query query = session.createQuery(QUERIES.get("getAllNewOnlineApplications")); + result = query.getResultList(); + + Logger.trace("Found entries: " + result.size()); + + if (result.size() == 0) { + Logger.trace("No entries found."); + return null; + } + return result; + } + public static List<UserDatabase> getAllUsers() { Logger.trace("Get All OnlineApplications from database."); @@ -235,4 +262,62 @@ public class ConfigurationDBRead { } return (UserDatabase) result.get(0); } + + public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) { + MiscUtil.assertNotNull(bpkwbpk, "bpk/wbpk"); + Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database."); + + List<UserDatabase> result; + EntityManager session = ConfigurationDBUtils.getCurrentSession(); + + javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserBPKWBPK")); + query.setParameter("bpk", bpkwbpk); + result = query.getResultList(); + + Logger.trace("Found entries: " + result.size()); + + if (result.size() == 0) { + Logger.trace("No entries found."); + return null; + } + return (UserDatabase) result.get(0); + } + + public static UserDatabase getNewUserWithTokken(String tokken) { + MiscUtil.assertNotNull(tokken, "bpk/wbpk"); + Logger.trace("Getting Userinformation with Tokken " + tokken + " from database."); + + List<UserDatabase> result; + EntityManager session = ConfigurationDBUtils.getCurrentSession(); + + javax.persistence.Query query = session.createQuery(QUERIES.get("getNewUserWithUserTokken")); + query.setParameter("tokken", tokken); + result = query.getResultList(); + + Logger.trace("Found entries: " + result.size()); + + if (result.size() == 0) { + Logger.trace("No entries found."); + return null; + } + return (UserDatabase) result.get(0); + } + + public static List<UserDatabase> getAllNewUsers() { + Logger.trace("Get all new Users from Database"); + + List<UserDatabase> result; + EntityManager session = ConfigurationDBUtils.getCurrentSession(); + + javax.persistence.Query query = session.createQuery(QUERIES.get("getAllNewUsers")); + result = query.getResultList(); + + Logger.trace("Found entries: " + result.size()); + + if (result.size() == 0) { + Logger.trace("No entries found."); + return null; + } + return result; + } } |