aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java
diff options
context:
space:
mode:
authorChristian Wagner <c.wagner@datentechnik-innovation.com>2015-01-13 13:02:26 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 11:06:49 +0200
commit4882a375585451be88bee367a82f9e18a57ebfdf (patch)
tree269b3c692bc5982de909e576eac3437a83e36c4b /id/server/moa-id-commons/src/main/java
parentcb6daf2e54d72a4a0bdca0252d96191440cd5f52 (diff)
downloadmoa-id-spss-4882a375585451be88bee367a82f9e18a57ebfdf.tar.gz
moa-id-spss-4882a375585451be88bee367a82f9e18a57ebfdf.tar.bz2
moa-id-spss-4882a375585451be88bee367a82f9e18a57ebfdf.zip
add configuration interface
little cleanup in 'ConfigPropertyDaoImpl'
Diffstat (limited to 'id/server/moa-id-commons/src/main/java')
-rw-r--r--id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/Configuration.java48
-rw-r--r--id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/dal/ConfigPropertyDaoImpl.java11
2 files changed, 56 insertions, 3 deletions
diff --git a/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/Configuration.java b/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/Configuration.java
new file mode 100644
index 000000000..6ec43c583
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/Configuration.java
@@ -0,0 +1,48 @@
+package com.datentechnik.moa.id.conf.persistence;
+
+import java.util.List;
+
+/**
+ *
+ */
+public interface Configuration {
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ Object get(String key);
+
+ /**
+ *
+ * @param key
+ * @param clazz
+ * @return
+ */
+ <T> T get(String key, Class<T> clazz);
+
+ /**
+ *
+ * @param key
+ * @param value
+ */
+ void set(String key, Object value);
+
+ /**
+ *
+ * @param key
+ * @param clazz
+ * @param defaultValue
+ * @return
+ */
+ <T> T get(String key, Class<T> clazz, Object defaultValue);
+
+ /**
+ *
+ * @param key
+ * @param clazz
+ * @return
+ */
+ <T> List<T> getList(String key, Class<T> clazz);
+} \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/dal/ConfigPropertyDaoImpl.java b/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/dal/ConfigPropertyDaoImpl.java
index e1e0a836c..2b28cb245 100644
--- a/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/dal/ConfigPropertyDaoImpl.java
+++ b/id/server/moa-id-commons/src/main/java/com/datentechnik/moa/id/conf/persistence/dal/ConfigPropertyDaoImpl.java
@@ -34,7 +34,6 @@ public class ConfigPropertyDaoImpl implements ConfigPropertyDao {
if (em.find(ConfigProperty.class, property.getKey()) != null) {
log.trace("Property '{}' already exists!", property.toString());
- // TODO: think about merging
// em.merge(property);
} else {
log.debug("Storing '{}'.", property.toString());
@@ -65,11 +64,17 @@ public class ConfigPropertyDaoImpl implements ConfigPropertyDao {
@Override
public List<ConfigProperty> getProperties() {
+
+ if (null == em) {
+ log.error("No EntityManager set!");
+ return null;
+ }
+
log.debug("Retrieving all properties from database.");
TypedQuery<ConfigProperty> query = em.createQuery("select mc from ConfigProperty mc", ConfigProperty.class);
try {
- List<ConfigProperty> questionerVoterList = query.getResultList();
- return questionerVoterList;
+ List<ConfigProperty> propertiesList = query.getResultList();
+ return propertiesList;
} catch (NoResultException e) {
log.debug("No property found in database.");
return null;