aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons')
-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;