aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2013-07-29 16:18:47 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2013-08-06 10:24:36 +0200
commite281b81475cc8a94a59f6ce7767d4b0996ea7180 (patch)
tree51b7a5e0e0a1abacc6157a0509377cdc5fb03fed /id/server/moa-id-commons/src/main/java
parent99694b29f82f858f5b6163e6a3d6c11caaeb487e (diff)
downloadmoa-id-spss-e281b81475cc8a94a59f6ce7767d4b0996ea7180.tar.gz
moa-id-spss-e281b81475cc8a94a59f6ce7767d4b0996ea7180.tar.bz2
moa-id-spss-e281b81475cc8a94a59f6ce7767d4b0996ea7180.zip
Configuration Tool:
- OA Configuration TODO: - General Configuration - Import - User Management
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.java108
1 files changed, 104 insertions, 4 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 80d95628e..e815f2a69 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
@@ -17,14 +17,41 @@ public class ConfigurationDBRead {
private static Map<String, String> QUERIES = new HashMap<String, String>();
static {
- QUERIES.put("getOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix like SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'");
- QUERIES.put("getMOAIDConfiguration", "select moaidconfiguration from MOAIDConfiguration moaidconfiguration");
+ QUERIES.put("getActiveOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix like SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'");
+ QUERIES.put("getOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix like SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix))");
+ QUERIES.put("getOnlineApplicationWithDBID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id");
QUERIES.put("getAllOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication");
+ QUERIES.put("getMOAIDConfiguration", "select moaidconfiguration from MOAIDConfiguration moaidconfiguration");
QUERIES.put("getUserWithUserID", "select userdatabase from UserDatabase userdatabase where userdatabase.id = :id");
-
+ QUERIES.put("searchOnlineApplicationsWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.friendlyName like :id");
+ QUERIES.put("searchOnlineApplicationsFormUserWithID", "select onlineapplication from UserDatabase userdatabase, OnlineApplication onlineapplication where userdatabase.id = :userid and userdatabase.registratedOAs.friendlyName like :oaid");
}
@SuppressWarnings("rawtypes")
+ public static OnlineApplication getActiveOnlineApplication(String id) {
+ MiscUtil.assertNotNull(id, "OnlineApplictionID");
+ Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+
+ List result;
+ EntityManager session = ConfigurationDBUtils.getCurrentSession();
+
+ javax.persistence.Query query = session.createQuery(QUERIES.get("getActiveOnlineApplicationWithID"));
+ //query.setParameter("id", id+"%");
+ query.setParameter("id", id);
+ result = query.getResultList();
+
+ Logger.trace("Found entries: " + result.size());
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return (OnlineApplication) result.get(0);
+ }
+
+
+ @SuppressWarnings("rawtypes")
public static OnlineApplication getOnlineApplication(String id) {
MiscUtil.assertNotNull(id, "OnlineApplictionID");
Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
@@ -46,7 +73,30 @@ public class ConfigurationDBRead {
return (OnlineApplication) result.get(0);
}
-
+
+ @SuppressWarnings("rawtypes")
+ public static OnlineApplication getOnlineApplication(long dbid) {
+ MiscUtil.assertNotNull(dbid, "OnlineApplictionID");
+ Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database.");
+
+ List result;
+ EntityManager session = ConfigurationDBUtils.getCurrentSession();
+
+ javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithDBID"));
+ //query.setParameter("id", id+"%");
+ query.setParameter("id", dbid);
+ result = query.getResultList();
+
+ Logger.trace("Found entries: " + result.size());
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return (OnlineApplication) result.get(0);
+ }
+
public static MOAIDConfiguration getMOAIDConfiguration() {
Logger.trace("Load MOAID Configuration from database.");
@@ -84,6 +134,56 @@ public class ConfigurationDBRead {
return result;
}
+ @SuppressWarnings("rawtypes")
+ public static List<OnlineApplication> searchOnlineApplications(String id) {
+ MiscUtil.assertNotNull(id, "OnlineApplictionID");
+ Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+
+ List<OnlineApplication> result;
+ EntityManager session = ConfigurationDBUtils.getCurrentSession();
+
+ javax.persistence.Query query = session.createQuery(QUERIES.get("searchOnlineApplicationsWithID"));
+ query.setParameter("id", "%"+id+"%");
+
+ result = query.getResultList();
+
+ Logger.trace("Found entries: " + result.size());
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return result;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static List<OnlineApplication> searchOnlineApplicationsFromUser(long userid, String oaid) {
+ MiscUtil.assertNotNull(oaid, "OnlineApplictionID");
+ MiscUtil.assertNotNull(userid, "UserID");
+
+ Logger.trace("Getting OnlineApplication with ID " + oaid
+ + " from user with UserID " + userid + " database.");
+
+ List<OnlineApplication> result;
+ EntityManager session = ConfigurationDBUtils.getCurrentSession();
+
+ javax.persistence.Query query = session.createQuery(QUERIES.get("searchOnlineApplicationsFormUserWithID"));
+ query.setParameter("userid", userid);
+ query.setParameter("oaid", "%"+oaid+"%");
+
+ result = query.getResultList();
+
+ Logger.trace("Found entries: " + result.size());
+
+ if (result.size() == 0) {
+ Logger.trace("No entries found.");
+ return null;
+ }
+
+ return result;
+ }
+
public static UserDatabase getUserWithID(long id) {
MiscUtil.assertNotNull(id, "UserID");
Logger.trace("Getting Userinformation with ID " + id + " from database.");