aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerwin Gsenger <g.gsenger@datentechnik-innovation.at>2015-01-16 15:14:34 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 11:07:53 +0200
commitc393a871d38abe1638addd106258d8211eaa6a92 (patch)
treeefe4a614c5c2dca06be5bcd280218e65e74f5fd8
parent1c8dc14de27abd95b79f4d515e80639ccb1cc366 (diff)
downloadmoa-id-spss-c393a871d38abe1638addd106258d8211eaa6a92.tar.gz
moa-id-spss-c393a871d38abe1638addd106258d8211eaa6a92.tar.bz2
moa-id-spss-c393a871d38abe1638addd106258d8211eaa6a92.zip
add ability to extract all database data needed to build a 'MOAIDConfiguration' object
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
new file mode 100644
index 000000000..63c3b5bfb
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
@@ -0,0 +1,82 @@
+package at.gv.egovernment.moa.id.commons.db;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+
+import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral;
+import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes;
+import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs;
+import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration;
+import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
+import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates;
+
+public class ConfigurationFromDBExtractor {
+
+ private ConfigurationFromDBExtractor() {
+ }
+
+ private static <T> T getSingleValue(String queryString, Class<T> clazz) {
+ T result = null;
+ EntityManager session = ConfigurationDBUtils.getCurrentSession();
+ TypedQuery<T> query = session.createQuery(queryString, clazz);
+ try {
+ result = clazz.cast(query.getSingleResult());
+ } catch (Exception e) {
+ return null;
+ }
+ return result;
+ }
+
+ private static <T> List<T> getListOfValues(String queryString, Class<T> clazz) {
+ List<T> result = new ArrayList<T>();
+ EntityManager session = ConfigurationDBUtils.getCurrentSession();
+ TypedQuery<T> query = session.createQuery(queryString, clazz);
+ try {
+ result = query.getResultList();
+ } catch (Exception e) {
+ return new ArrayList<T>();
+ }
+ return result;
+ }
+
+ public static AuthComponentGeneral getAuthComponentGeneral() {
+ return getSingleValue("from AuthComponentGeneral", AuthComponentGeneral.class);
+ }
+
+ public static ChainingModes getChainingModes() {
+ return (ChainingModes) getSingleValue("from ChainingModes", ChainingModes.class);
+ }
+
+ public static List<OnlineApplication> getOnlineApplications() {
+ return getListOfValues("from OnlineApplication", OnlineApplication.class);
+ }
+
+ public static List<GenericConfiguration> getGenericConfigurations() {
+ return getListOfValues("from GenericConfiguration", GenericConfiguration.class);
+ }
+
+ public static String getTrustedCACertificates() {
+ return getSingleValue("select trustedCACertificates from MOAIDConfiguration", String.class);
+ }
+
+ public static DefaultBKUs getDefaultBKUs() {
+ return getSingleValue("select defaultBKUs from MOAIDConfiguration", DefaultBKUs.class);
+ }
+
+ public static SLRequestTemplates getSLRequestTemplates() {
+ return getSingleValue("select SLRequestTemplates from MOAIDConfiguration", SLRequestTemplates.class);
+ }
+
+ public static Date getTimeStampItem() {
+ return getSingleValue("select timestampItem from MOAIDConfiguration", Date.class);
+ }
+
+ public static Date getPvp2RefreshItem() {
+ return getSingleValue("select pvp2RefreshItem from MOAIDConfiguration", Date.class);
+ }
+
+}