refactoring
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java b/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
deleted file mode 100644
index 4317bb5..0000000
--- a/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package de.ids_mannheim.korap.handlers;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
-import de.ids_mannheim.korap.resources.KustvaktResource;
-import de.ids_mannheim.korap.resources.VirtualCollection;
-import de.ids_mannheim.korap.user.User;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * @author hanl
- * @date 11/01/2014
- */
-
-@Deprecated
-//todo?! cache with ehcache and put token/sentence/paragraph numbers into cache
-public class CollectionDao
- implements ResourceOperationIface<VirtualCollection> {
-
- private static Logger log = LoggerFactory.getLogger(CollectionDao.class);
- private BatchBuilder batchBuilder;
- protected final NamedParameterJdbcTemplate jdbcTemplate;
-
- public CollectionDao(PersistenceClient client) {
- this.jdbcTemplate = (NamedParameterJdbcTemplate) client.getSource();
- this.batchBuilder = new BatchBuilder(
- this.jdbcTemplate.getJdbcOperations());
- }
-
- @Override
- public Class<VirtualCollection> getType() {
- return VirtualCollection.class;
- }
-
- // fixme: persistentid can be done, persistence is achieved by specifing a date until which documents
- // are to be included. this excludes documents that are part of the "sperreinträge"
- public <T extends KustvaktResource> T findbyId(String id, User user)
- throws KustvaktException {
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("id", id);
- source.addValue("user", user.getId());
- final String sql = "select * from coll_store where persistent_id=:id and user_id=:user;";
- try {
- return (T) this.jdbcTemplate.queryForObject(sql, source,
- new RowMapperFactory.CollectionMapper());
- }catch (DataAccessException e) {
- log.error("Exception during database get for id '" + id + "'", e);
- return null;
- }
- }
-
- public VirtualCollection findbyId(Integer id, User user)
- throws KustvaktException {
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("id", id);
- final String sql = "select * from coll_store where id=:id";
- try {
- return this.jdbcTemplate.queryForObject(sql, source,
- new RowMapperFactory.CollectionMapper());
- }catch (DataAccessException e) {
- log.error("Exception during database get for id '" + id + "'", e);
- return null;
- }
- }
-
- public int updateResource(VirtualCollection resource, User user)
- throws KustvaktException {
- MapSqlParameterSource np = new MapSqlParameterSource();
- np.addValue("id", resource.getPersistentID());
- np.addValue("qy", resource.getData());
- np.addValue("name", resource.getName());
- np.addValue("desc", resource.getDescription());
- final String sql = "UPDATE coll_store SET query=:qy, name=:name, description=:desc WHERE persistent_id=:id;";
- try {
- return this.jdbcTemplate.update(sql, np);
- }catch (DataAccessException e) {
- log.error("Exception during database update for id '" + resource
- .getPersistentID() + "'", e);
- throw new KustvaktException(e, StatusCodes.CONNECTION_ERROR);
- }
- }
-
- public int[] updateResources(List<VirtualCollection> resources, User user)
- throws KustvaktException {
- MapSqlParameterSource[] sources = new MapSqlParameterSource[resources
- .size()];
- final String sql = "UPDATE coll_store SET query=:qy, name=:name, description=:desc WHERE persistent_id=:id;";
- int i = 0;
- for (VirtualCollection c : resources) {
- MapSqlParameterSource np = new MapSqlParameterSource();
- np.addValue("id", c.getPersistentID());
- np.addValue("qy", c.getData());
- np.addValue("name", c.getName());
- np.addValue("desc", c.getDescription());
- sources[i++] = np;
- }
- try {
- return this.jdbcTemplate.batchUpdate(sql, sources);
- }catch (DataAccessException e) {
- log.error("Exception during database update", e);
- throw new KustvaktException(e, StatusCodes.CONNECTION_ERROR);
- }
- }
-
- @Override
- public int storeResource(VirtualCollection resource, User user)
- throws KustvaktException {
- if (resource.getData() != null) {
- MapSqlParameterSource np = new MapSqlParameterSource();
- np.addValue("query", resource.getData());
- np.addValue("pid", resource.getPersistentID());
- np.addValue("name", resource.getName());
- np.addValue("desc", resource.getDescription());
- np.addValue("us", user.getId());
- np.addValue("cr", System.currentTimeMillis());
-
- final String sql =
- "INSERT INTO coll_store (persistent_id, name, description, user_id, query, created) "
- + "VALUES (:pid, :name, :desc, :us, :query, :cr);";
- try {
- return this.jdbcTemplate.update(sql, np);
- }catch (DataAccessException e) {
- log.error("Exception during database store for id '" + resource
- .getPersistentID() + "'", e);
- throw new KustvaktException(e, StatusCodes.CONNECTION_ERROR);
- }
- }else
- throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT,
- "invalid query parameter", (String) resource.getData());
- }
-
- public int deleteResource(String id, User user) throws KustvaktException {
- //todo: foreign key and on delete cascade does not work properly!
- MapSqlParameterSource np = new MapSqlParameterSource();
- np.addValue("id", id);
- np.addValue("user", user.getId());
- // final String sql = "DELETE FROM coll_store cs inner join r_store rs on rs.id=cs.id WHERE rs.persistent_id=:id;";
- final String sql = "DELETE FROM coll_store where persistent_id=:id and user_id=:user;";
- try {
- return this.jdbcTemplate.update(sql, np);
- }catch (DataAccessException e) {
- log.error("Exception during database delete for id '" + id + "'",
- e);
- throw new KustvaktException(e, StatusCodes.CONNECTION_ERROR);
- }
- }
-
- @Override
- public int deleteAll() throws KustvaktException {
- final String sql = "DELETE FROM coll_store;";
- try {
- return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
- }catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
- @Override
- public int size() throws KustvaktException {
- final String sql = "select count(*) from coll_store;";
- try {
- return this.jdbcTemplate
- .queryForObject(sql, new HashMap<String, Object>(),
- Integer.class);
- }catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
- //todo: adjust to resource id input (batch operation!)
- // fixme: test
- public List<VirtualCollection> getResources(Collection<Object> resources,
- User user) throws KustvaktException {
- final String sql1 = "SELECT * from coll_store where id in";
- // final String sql =
- // "SELECT rs.*, rt.name_path, cs.query FROM r_store as rs inner join r_tree as rt on rs.id=rt.childID "
- // + "inner join coll_store as cs on cs.id=rs.id WHERE rs.id in";
- return batchBuilder.selectFromIDs(sql1, resources,
- new RowMapperFactory.CollectionMapper());
- }
-
-}
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserDetailsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
similarity index 95%
rename from src/main/java/de/ids_mannheim/korap/user/UserDetailsDao.java
rename to src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
index 4e16bed..071a74a 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserDetailsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
@@ -1,6 +1,9 @@
-package de.ids_mannheim.korap.user;
+package de.ids_mannheim.korap.handlers;
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
+import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.user.Userdetails2;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserSettingsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
similarity index 95%
rename from src/main/java/de/ids_mannheim/korap/user/UserSettingsDao.java
rename to src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
index c82ac64..dfc8830 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserSettingsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
@@ -1,6 +1,9 @@
-package de.ids_mannheim.korap.user;
+package de.ids_mannheim.korap.handlers;
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
+import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.user.UserSettings2;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserDataDbIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
similarity index 79%
rename from src/main/java/de/ids_mannheim/korap/user/UserDataDbIface.java
rename to src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
index 7ee663c..e1812ff 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserDataDbIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
@@ -1,6 +1,8 @@
-package de.ids_mannheim.korap.user;
+package de.ids_mannheim.korap.interfaces.db;
import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.user.Userdata;
/**
* @author hanl
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index 2eca9e0..e6393e9 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -9,6 +9,7 @@
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.interfaces.db.AuditingIface;
import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.user.*;
import de.ids_mannheim.korap.utils.StringUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserDetails.java b/src/main/java/de/ids_mannheim/korap/user/UserDetails.java
deleted file mode 100644
index 135fbd2..0000000
--- a/src/main/java/de/ids_mannheim/korap/user/UserDetails.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package de.ids_mannheim.korap.user;
-
-import lombok.Data;
-import org.apache.commons.collections.map.CaseInsensitiveMap;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * User: hanl
- * Date: 8/14/13
- * Time: 10:32 AM
- */
-
-// todo: set certain fields required!
-@Deprecated
-@Data
-public class UserDetails {
-
- private Integer Id;
- private Integer userID;
- private String firstName;
- private String lastName;
- // todo :should be boolean or integer?!
- private String gender;
- private String phone;
- private String institution;
- private String email;
- private String address;
- private String country;
- @Deprecated
- private boolean privateUsage;
-
- public UserDetails() {
- setFirstName("");
- setLastName("");
- setPhone("");
- setEmail("");
- setGender("");
- setAddress("");
- setCountry("");
- setInstitution("");
- setPrivateUsage(true);
- }
-
- public static UserDetails newDetailsIterator(Map<String, String> d) {
- UserDetails details = new UserDetails();
- Map<String, String> detailMap = new CaseInsensitiveMap(d);
-
- if (!detailMap.isEmpty()) {
- details.setFirstName(detailMap.get(Attributes.FIRSTNAME));
- details.setLastName(detailMap.get(Attributes.LASTNAME));
- details.setPhone(detailMap.get(Attributes.PHONE));
- details.setEmail(detailMap.get(Attributes.EMAIL));
- details.setGender(detailMap.get(Attributes.GENDER));
- details.setAddress(detailMap.get(Attributes.ADDRESS));
- details.setCountry(detailMap.get(Attributes.COUNTRY));
- details.setInstitution(detailMap.get(Attributes.INSTITUTION));
- details.setPrivateUsage(
- detailMap.get(Attributes.PRIVATE_USAGE) == null ?
- true :
- Boolean.valueOf(
- detailMap.get(Attributes.PRIVATE_USAGE)));
- }
- return details;
- }
-
- public void updateDetails(Map<String, String> d) {
- Map<String, Object> detailMap = new CaseInsensitiveMap(d);
-
- if (!detailMap.isEmpty()) {
- if (detailMap.containsKey(Attributes.FIRSTNAME))
- this.setFirstName(
- String.valueOf(detailMap.get(Attributes.FIRSTNAME)));
- if (detailMap.containsKey(Attributes.LASTNAME))
- this.setLastName(
- String.valueOf(detailMap.get(Attributes.LASTNAME)));
- if (detailMap.containsKey(Attributes.PHONE))
- this.setPhone(String.valueOf(detailMap.get(Attributes.PHONE)));
- if (detailMap.containsKey(Attributes.EMAIL))
- this.setEmail(String.valueOf(detailMap.get(Attributes.EMAIL)));
- if (detailMap.containsKey(Attributes.GENDER))
- this.setGender(
- String.valueOf(detailMap.get(Attributes.GENDER)));
- if (detailMap.containsKey(Attributes.ADDRESS))
- this.setAddress(
- String.valueOf(detailMap.get(Attributes.ADDRESS)));
- if (detailMap.containsKey(Attributes.COUNTRY))
- this.setCountry(
- String.valueOf(detailMap.get(Attributes.COUNTRY)));
- if (detailMap.containsKey(Attributes.INSTITUTION))
- this.setInstitution(
- String.valueOf(detailMap.get(Attributes.INSTITUTION)));
- this.setPrivateUsage(Boolean.valueOf(
- String.valueOf(detailMap.get(Attributes.PRIVATE_USAGE))));
- }
- }
-
- public Map<String, Object> toMap() {
- Map<String, Object> details = new HashMap<>();
- // shouldnt there be a mechanism that prevents the retrieval of all information if no scopes are given?
- // and if so, are the access_tokens specific to the scopes then?
- details.put(Attributes.EMAIL, this.email);
- details.put(Attributes.FIRSTNAME, this.firstName);
- details.put(Attributes.LASTNAME, this.lastName);
- details.put(Attributes.GENDER, this.gender);
- details.put(Attributes.PHONE, this.phone);
- details.put(Attributes.INSTITUTION, this.institution);
- details.put(Attributes.ADDRESS, this.address);
- details.put(Attributes.COUNTRY, this.country);
- details.put(Attributes.PRIVATE_USAGE, this.privateUsage);
-
- for (Map.Entry<String, Object> pair : details.entrySet()) {
- if (pair.getValue() == null || pair.getValue().equals("null"))
- pair.setValue("");
- }
- return details;
- }
-
-}
-
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserSettings.java b/src/main/java/de/ids_mannheim/korap/user/UserSettings.java
deleted file mode 100644
index 77351e9..0000000
--- a/src/main/java/de/ids_mannheim/korap/user/UserSettings.java
+++ /dev/null
@@ -1,525 +0,0 @@
-package de.ids_mannheim.korap.user;
-
-import de.ids_mannheim.korap.utils.BooleanUtils;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * User: hanl
- * Date: 8/14/13
- * Time: 10:26 AM
- */
-
-@Deprecated
-@Getter
-@Setter
-public class UserSettings {
-
- // todo: use simple map for settings, not all the parameter
- //todo: --> use sqlbuilder to update settings
-
-
- private Map<String, Object> values;
- // those are the only important parameters!!
-// private Integer id;
-// private Integer userID;
-
-
- private Integer id;
- private Integer userID;
- private String fileNameForExport;
- // @Deprecated
- // private Integer itemForSimpleAnnotation;
- private String leftContextItemForExport;
- private Integer leftContextSizeForExport;
- private String locale;
- private String leftContextItem;
- private Integer leftContextSize;
- private String rightContextItem;
- private String rightContextItemForExport;
- private Integer rightContextSize;
- private Integer rightContextSizeForExport;
- private String selectedCollection;
- private String queryLanguage;
- private Integer pageLength;
- private boolean metadataQueryExpertModus;
- // @Deprecated
- // private Integer searchSettingsTab;
- // @Deprecated
- // private Integer selectedGraphType;
- // @Deprecated
- // private String selectedSortType;
- // @Deprecated
- // private String selectedViewForSearchResults;
-
- /**
- * default values for foundry specification! of structure ff/lay
- */
- private String defaultPOSfoundry;
- private String defaultLemmafoundry;
- //default foundry for constituent information (syntax trees) --> there is no actual layer for this information
- private String defaultConstfoundry;
- private String defaultRelfoundry;
-
- //todo: refactor to anonymous -- since data is collected either way!
- private boolean collectData;
-
- /**
- * creates an instance of this object with default values, mapped from a database/configuration file
- */
- public UserSettings() {
- setupDefaultSettings();
- }
-
- @Deprecated
- public static UserSettings fromObjectMap(Map<String, Object> m) {
- UserSettings s = new UserSettings();
- s.setFileNameForExport((String) m.get(Attributes.FILENAME_FOR_EXPORT));
- // s.setItemForSimpleAnnotation(
- // (Integer) m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION));
- s.setLeftContextItemForExport(
- (String) m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
- s.setLeftContextSizeForExport(
- (Integer) m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT));
- s.setLocale((String) m.get(Attributes.LOCALE));
- s.setLeftContextItem((String) m.get(Attributes.LEFT_CONTEXT_ITEM));
- s.setLeftContextSize((Integer) m.get(Attributes.LEFT_CONTEXT_SIZE));
- s.setRightContextItem((String) m.get(Attributes.RIGHT_CONTEXT_ITEM));
- s.setRightContextItemForExport(
- (String) m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
- s.setRightContextSize((Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE));
- s.setRightContextSizeForExport(
- (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT));
- s.setSelectedCollection((String) m.get(Attributes.SELECTED_COLLECTION));
- s.setQueryLanguage((String) m.get(Attributes.QUERY_LANGUAGE));
- s.setPageLength((Integer) m.get(Attributes.PAGE_LENGTH));
- s.setMetadataQueryExpertModus((Boolean) BooleanUtils
- .getBoolean(m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
- // s.setSearchSettingsTab((Integer) m.get(Attributes.SEARCH_SETTINGS_TAB));
- // s.setSelectedGraphType((Integer) m.get(Attributes.SELECTED_GRAPH_TYPE));
- // s.setSelectedSortType((String) m.get(Attributes.SELECTED_SORT_TYPE));
- // s.setSelectedViewForSearchResults(
- // (String) m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
- s.setCollectData((Boolean) BooleanUtils
- .getBoolean(m.get(Attributes.COLLECT_AUDITING_DATA)));
-
- s.setDefaultConstfoundry(
- (String) m.get(Attributes.DEFAULT_CONST_FOUNDRY));
- s.setDefaultRelfoundry((String) m.get(Attributes.DEFAULT_REL_FOUNDRY));
- s.setDefaultPOSfoundry((String) m.get(Attributes.DEFAULT_POS_FOUNDRY));
- s.setDefaultLemmafoundry(
- (String) m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
-
- s.setId((Integer) m.get("Id"));
- s.setUserID((Integer) m.get("userID"));
- return s;
- }
-
- @Deprecated
- public static UserSettings fromMap(Map<String, String> m) {
- UserSettings s = new UserSettings();
- s.setFileNameForExport(m.get(Attributes.FILENAME_FOR_EXPORT));
- // s.setItemForSimpleAnnotation(
- // Integer.valueOf(m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION)));
- s.setLeftContextItemForExport(
- m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
- s.setLeftContextSizeForExport(Integer.valueOf(
- m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
- s.setLocale(m.get(Attributes.LOCALE));
- s.setLeftContextItem(m.get(Attributes.LEFT_CONTEXT_ITEM));
- s.setLeftContextSize(
- Integer.valueOf(m.get(Attributes.LEFT_CONTEXT_SIZE)));
- s.setRightContextItem(m.get(Attributes.RIGHT_CONTEXT_ITEM));
- s.setRightContextItemForExport(
- m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
- s.setRightContextSize(
- Integer.valueOf(m.get(Attributes.RIGHT_CONTEXT_SIZE)));
- s.setRightContextSizeForExport(Integer.valueOf(
- m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
- s.setSelectedCollection(m.get(Attributes.SELECTED_COLLECTION));
- s.setQueryLanguage(m.get(Attributes.QUERY_LANGUAGE));
- s.setPageLength(Integer.valueOf(m.get(Attributes.PAGE_LENGTH)));
- s.setMetadataQueryExpertModus(
- Boolean.valueOf(m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
- // s.setSearchSettingsTab(
- // Integer.valueOf(m.get(Attributes.SEARCH_SETTINGS_TAB)));
- // s.setSelectedGraphType(
- // Integer.valueOf(m.get(Attributes.SELECTED_GRAPH_TYPE)));
- // s.setSelectedSortType(m.get(Attributes.SELECTED_SORT_TYPE));
- // s.setSelectedViewForSearchResults(
- // m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
-
- s.setCollectData(
- Boolean.valueOf(m.get(Attributes.COLLECT_AUDITING_DATA)));
- s.setDefaultConstfoundry(m.get(Attributes.DEFAULT_CONST_FOUNDRY));
- s.setDefaultRelfoundry(m.get(Attributes.DEFAULT_REL_FOUNDRY));
- s.setDefaultPOSfoundry(m.get(Attributes.DEFAULT_POS_FOUNDRY));
- s.setDefaultLemmafoundry(m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
- return s;
- }
-
- public static UserSettings newSettingsIterator(Map<String, String> m) {
- UserSettings s = new UserSettings();
- if (m.isEmpty())
- return s;
-
- s.setFileNameForExport(m.get(Attributes.FILENAME_FOR_EXPORT));
- // s.setItemForSimpleAnnotation(
- // Integer.valueOf(m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION)));
- s.setLeftContextItemForExport(
- m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
- s.setLeftContextSizeForExport(Integer.valueOf(
- m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
- s.setLocale(m.get(Attributes.LOCALE));
- s.setLeftContextItem(m.get(Attributes.LEFT_CONTEXT_ITEM));
- s.setLeftContextSize(
- Integer.valueOf(m.get(Attributes.LEFT_CONTEXT_SIZE)));
- s.setRightContextItem(m.get(Attributes.RIGHT_CONTEXT_ITEM));
- s.setRightContextItemForExport(
- m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
- s.setRightContextSize(
- Integer.valueOf(m.get(Attributes.RIGHT_CONTEXT_SIZE)));
- s.setRightContextSizeForExport(Integer.valueOf(
- m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
- s.setSelectedCollection(m.get(Attributes.SELECTED_COLLECTION));
- s.setQueryLanguage(m.get(Attributes.QUERY_LANGUAGE));
- s.setPageLength(Integer.valueOf(m.get(Attributes.PAGE_LENGTH)));
- s.setMetadataQueryExpertModus(
- Boolean.valueOf(m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
- // s.setSearchSettingsTab(
- // Integer.valueOf(m.get(Attributes.SEARCH_SETTINGS_TAB)));
- // s.setSelectedGraphType(
- // Integer.valueOf(m.get(Attributes.SELECTED_GRAPH_TYPE)));
- // s.setSelectedSortType(m.get(Attributes.SELECTED_SORT_TYPE));
- // s.setSelectedViewForSearchResults(
- // m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
-
- s.setCollectData(
- Boolean.valueOf(m.get(Attributes.COLLECT_AUDITING_DATA)));
- s.setDefaultConstfoundry(m.get(Attributes.DEFAULT_CONST_FOUNDRY));
- s.setDefaultRelfoundry(m.get(Attributes.DEFAULT_REL_FOUNDRY));
- s.setDefaultPOSfoundry(m.get(Attributes.DEFAULT_POS_FOUNDRY));
- s.setDefaultLemmafoundry(m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
- return s;
- }
-
- @Deprecated
- public void updateStringSettings(Map<String, String> m) {
- if (m.get(Attributes.FILENAME_FOR_EXPORT) != null)
- this.setFileNameForExport(m.get(Attributes.FILENAME_FOR_EXPORT));
- // this.setItemForSimpleAnnotation(
- // Integer.valueOf(m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION)));
- if (m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT) != null)
- this.setLeftContextItemForExport(
- m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
- if (m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT) != null)
- this.setLeftContextSizeForExport(Integer.valueOf(
- m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
- if (m.get(Attributes.LOCALE) != null)
- this.setLocale(m.get(Attributes.LOCALE));
- if (m.get(Attributes.LEFT_CONTEXT_ITEM) != null)
- this.setLeftContextItem(m.get(Attributes.LEFT_CONTEXT_ITEM));
- if (m.get(Attributes.LEFT_CONTEXT_SIZE) != null)
- this.setLeftContextSize(
- Integer.valueOf(m.get(Attributes.LEFT_CONTEXT_SIZE)));
- if (m.get(Attributes.RIGHT_CONTEXT_ITEM) != null)
- this.setRightContextItem(m.get(Attributes.RIGHT_CONTEXT_ITEM));
- if (m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT) != null)
- this.setRightContextItemForExport(
- m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
- if (m.get(Attributes.RIGHT_CONTEXT_SIZE) != null)
- this.setRightContextSize(
- Integer.valueOf(m.get(Attributes.RIGHT_CONTEXT_SIZE)));
- if (m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT) != null)
- this.setRightContextSizeForExport(Integer.valueOf(
- m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
- if (m.get(Attributes.SELECTED_COLLECTION) != null)
- this.setSelectedCollection(m.get(Attributes.SELECTED_COLLECTION));
- if (m.get(Attributes.QUERY_LANGUAGE) != null)
- this.setQueryLanguage(m.get(Attributes.QUERY_LANGUAGE));
- if (m.get(Attributes.PAGE_LENGTH) != null)
- this.setPageLength(Integer.valueOf(m.get(Attributes.PAGE_LENGTH)));
- if (m.get(Attributes.METADATA_QUERY_EXPERT_MODUS) != null)
- this.setMetadataQueryExpertModus(Boolean.valueOf(
- m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
- // this.setSearchSettingsTab(
- // Integer.valueOf(m.get(Attributes.SEARCH_SETTINGS_TAB)));
- // this.setSelectedGraphType(
- // Integer.valueOf(m.get(Attributes.SELECTED_GRAPH_TYPE)));
- // this.setSelectedSortType(m.get(Attributes.SELECTED_SORT_TYPE));
- // this.setSelectedViewForSearchResults(
- // m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
- if (m.get(Attributes.COLLECT_AUDITING_DATA) != null)
- this.setCollectData(
- Boolean.valueOf(m.get(Attributes.COLLECT_AUDITING_DATA)));
- if (m.get(Attributes.DEFAULT_POS_FOUNDRY) != null)
- this.setDefaultPOSfoundry(m.get(Attributes.DEFAULT_POS_FOUNDRY));
- if (m.get(Attributes.DEFAULT_LEMMA_FOUNDRY) != null)
- this.setDefaultLemmafoundry(
- m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
- if (m.get(Attributes.DEFAULT_CONST_FOUNDRY) != null)
- this.setDefaultConstfoundry(
- m.get(Attributes.DEFAULT_CONST_FOUNDRY));
- if (m.get(Attributes.DEFAULT_REL_FOUNDRY) != null)
- this.setDefaultRelfoundry(m.get(Attributes.DEFAULT_REL_FOUNDRY));
- }
-
- @Deprecated
- public void updateObjectSettings(Map<String, Object> m) {
- if (m.get(Attributes.FILENAME_FOR_EXPORT) != null)
- this.setFileNameForExport(
- (String) m.get(Attributes.FILENAME_FOR_EXPORT));
- // this.setItemForSimpleAnnotation(
- // Integer.valueOf(m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION)));
- if (m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT) != null)
- this.setLeftContextItemForExport(
- (String) m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
- if (m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT) != null)
- this.setLeftContextSizeForExport(Integer.valueOf(
- (Integer) m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
- if (m.get(Attributes.LOCALE) != null)
- this.setLocale((String) m.get(Attributes.LOCALE));
- if (m.get(Attributes.LEFT_CONTEXT_ITEM) != null)
- this.setLeftContextItem(
- (String) m.get(Attributes.LEFT_CONTEXT_ITEM));
- if (m.get(Attributes.LEFT_CONTEXT_SIZE) != null)
- this.setLeftContextSize(Integer.valueOf(
- (Integer) m.get(Attributes.LEFT_CONTEXT_SIZE)));
- if (m.get(Attributes.RIGHT_CONTEXT_ITEM) != null)
- this.setRightContextItem(
- (String) m.get(Attributes.RIGHT_CONTEXT_ITEM));
- if (m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT) != null)
- this.setRightContextItemForExport(
- (String) m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
- if (m.get(Attributes.RIGHT_CONTEXT_SIZE) != null)
- this.setRightContextSize(Integer.valueOf(
- (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE)));
- if (m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT) != null)
- this.setRightContextSizeForExport(Integer.valueOf(
- (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
- if (m.get(Attributes.SELECTED_COLLECTION) != null)
- this.setSelectedCollection(
- (String) m.get(Attributes.SELECTED_COLLECTION));
- if (m.get(Attributes.QUERY_LANGUAGE) != null)
- this.setQueryLanguage((String) m.get(Attributes.QUERY_LANGUAGE));
- if (m.get(Attributes.PAGE_LENGTH) != null)
- this.setPageLength((Integer) m.get(Attributes.PAGE_LENGTH));
- if (m.get(Attributes.METADATA_QUERY_EXPERT_MODUS) != null)
- this.setMetadataQueryExpertModus(Boolean.valueOf(
- (Boolean) m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
- // this.setSearchSettingsTab(
- // Integer.valueOf(m.get(Attributes.SEARCH_SETTINGS_TAB)));
- // this.setSelectedGraphType(
- // Integer.valueOf(m.get(Attributes.SELECTED_GRAPH_TYPE)));
- // this.setSelectedSortType(m.get(Attributes.SELECTED_SORT_TYPE));
- // this.setSelectedViewForSearchResults(
- // m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
- if (m.get(Attributes.COLLECT_AUDITING_DATA) != null)
- this.setCollectData(
- (Boolean) m.get(Attributes.COLLECT_AUDITING_DATA));
- if (m.get(Attributes.DEFAULT_POS_FOUNDRY) != null)
- this.setDefaultPOSfoundry(
- (String) m.get(Attributes.DEFAULT_POS_FOUNDRY));
- if (m.get(Attributes.DEFAULT_LEMMA_FOUNDRY) != null)
- this.setDefaultLemmafoundry(
- (String) m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
- if (m.get(Attributes.DEFAULT_CONST_FOUNDRY) != null)
- this.setDefaultConstfoundry(
- (String) m.get(Attributes.DEFAULT_CONST_FOUNDRY));
- if (m.get(Attributes.DEFAULT_REL_FOUNDRY) != null)
- this.setDefaultRelfoundry(
- (String) m.get(Attributes.DEFAULT_REL_FOUNDRY));
- }
-
- //loadSubTypes from configuration?
- private void setupDefaultSettings() {
- this.setFileNameForExport("export");
- // this.setItemForSimpleAnnotation(0);
- this.setLocale("de");
- this.setLeftContextItemForExport("char");
- this.setLeftContextSizeForExport(100);
- this.setLeftContextItem("char");
- this.setLeftContextSize(200);
- this.setRightContextItem("char");
- this.setRightContextItemForExport("char");
- this.setRightContextSize(200);
- this.setRightContextSizeForExport(100);
- // persistent id for wikipedia!
- // fixme: deprecation warning!
- this.setSelectedCollection(
- "ZGU0ZTllNTFkYzc3M2VhZmViYzdkYWE2ODI5NDc3NTk4NGQ1YThhOTMwOTNhOWYxNWMwN2M3Y2YyZmE3N2RlNQ==");
- this.setQueryLanguage("COSMAS2");
- this.setPageLength(25);
- this.setMetadataQueryExpertModus(true);
- // this.setSearchSettingsTab(0);
- // this.setSelectedGraphType(1);
- // this.setSelectedSortType("FIFO");
- // this.setSelectedViewForSearchResults("KWIC");
-
- this.setCollectData(true);
- this.setDefaultConstfoundry("mate");
- this.setDefaultRelfoundry("mate");
- this.setDefaultPOSfoundry("tt");
- this.setDefaultLemmafoundry("tt");
- }
-
- public Map toStringMap() {
- Map<String, String> m = new HashMap<>();
- m.put(Attributes.FILENAME_FOR_EXPORT, this.getFileNameForExport());
- // m.put(Attributes.ITEM_FOR_SIMPLE_ANNOTATION,
- // String.valueOf(this.getItemForSimpleAnnotation()));
- m.put(Attributes.LEFT_CONTEXT_SIZE,
- String.valueOf(this.getLeftContextSize()));
- m.put(Attributes.LEFT_CONTEXT_ITEM,
- String.valueOf(this.getLeftContextItem()));
- m.put(Attributes.LOCALE, this.getLocale());
- m.put(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT,
- String.valueOf(this.getLeftContextSizeForExport()));
- m.put(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT,
- String.valueOf(this.getLeftContextItemForExport()));
- m.put(Attributes.RIGHT_CONTEXT_ITEM,
- String.valueOf(this.getRightContextItem()));
- m.put(Attributes.RIGHT_CONTEXT_SIZE,
- String.valueOf(this.getRightContextSize()));
- m.put(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT,
- String.valueOf(this.getRightContextItemForExport()));
- m.put(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT,
- String.valueOf(this.getRightContextSizeForExport()));
- m.put(Attributes.SELECTED_COLLECTION, this.getSelectedCollection());
- m.put(Attributes.QUERY_LANGUAGE, this.getQueryLanguage());
- m.put(Attributes.PAGE_LENGTH, String.valueOf(this.getPageLength()));
- m.put(Attributes.METADATA_QUERY_EXPERT_MODUS,
- String.valueOf(this.isMetadataQueryExpertModus()));
- // m.put(Attributes.SEARCH_SETTINGS_TAB,
- // String.valueOf(this.getSearchSettingsTab()));
- // m.put(Attributes.SELECTED_GRAPH_TYPE,
- // String.valueOf(this.getSelectedGraphType()));
- // m.put(Attributes.SELECTED_SORT_TYPE, this.getSelectedSortType());
- // m.put(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS,
- // this.getSelectedViewForSearchResults());
- m.put(Attributes.DEFAULT_POS_FOUNDRY, this.getDefaultPOSfoundry());
- m.put(Attributes.DEFAULT_LEMMA_FOUNDRY, this.getDefaultLemmafoundry());
- m.put(Attributes.DEFAULT_CONST_FOUNDRY, this.getDefaultConstfoundry());
- m.put(Attributes.DEFAULT_REL_FOUNDRY, this.getDefaultRelfoundry());
- m.put(Attributes.COLLECT_AUDITING_DATA,
- String.valueOf(this.isCollectData()));
-
- for (Map.Entry pair : m.entrySet()) {
- if (pair.getValue() == null)
- pair.setValue("");
- }
- return m;
- }
-
- public Map toObjectMap() {
- Map<String, Object> m = new HashMap<>();
- m.put(Attributes.FILENAME_FOR_EXPORT, this.getFileNameForExport());
- // m.put(Attributes.ITEM_FOR_SIMPLE_ANNOTATION,
- // this.getItemForSimpleAnnotation());
- m.put(Attributes.LEFT_CONTEXT_SIZE, this.getLeftContextSize());
- m.put(Attributes.LEFT_CONTEXT_ITEM, this.getLeftContextItem());
- m.put(Attributes.LOCALE, this.getLocale());
- m.put(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT,
- this.getLeftContextSizeForExport());
- m.put(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT,
- this.getLeftContextItemForExport());
- m.put(Attributes.RIGHT_CONTEXT_ITEM, this.getRightContextItem());
- m.put(Attributes.RIGHT_CONTEXT_SIZE, this.getRightContextSize());
- m.put(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT,
- this.getRightContextItemForExport());
- m.put(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT,
- this.getRightContextSizeForExport());
- m.put(Attributes.SELECTED_COLLECTION, this.getSelectedCollection());
- m.put(Attributes.QUERY_LANGUAGE, this.getQueryLanguage());
- m.put(Attributes.PAGE_LENGTH, this.getPageLength());
- m.put(Attributes.METADATA_QUERY_EXPERT_MODUS,
- this.isMetadataQueryExpertModus());
- // m.put(Attributes.SEARCH_SETTINGS_TAB, this.getSearchSettingsTab());
- // m.put(Attributes.SELECTED_GRAPH_TYPE, this.getSelectedGraphType());
- // m.put(Attributes.SELECTED_SORT_TYPE, this.getSelectedSortType());
- // m.put(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS,
- // this.getSelectedViewForSearchResults());
- m.put(Attributes.DEFAULT_POS_FOUNDRY, this.getDefaultPOSfoundry());
- m.put(Attributes.DEFAULT_LEMMA_FOUNDRY, this.getDefaultLemmafoundry());
- m.put(Attributes.DEFAULT_CONST_FOUNDRY, this.getDefaultConstfoundry());
- m.put(Attributes.DEFAULT_REL_FOUNDRY, this.getDefaultRelfoundry());
- m.put(Attributes.COLLECT_AUDITING_DATA, this.isCollectData());
- for (Map.Entry pair : m.entrySet()) {
- if (pair.getValue() == null)
- pair.setValue("");
- }
- return m;
- }
-
- @Override
- public String toString() {
- return "UserSettings{" +
- "id=" + id +
- ", userid=" + userID +
- ", fileNameForExport='" + fileNameForExport + '\'' +
- ", leftContextItemForExport='" + leftContextItemForExport + '\''
- +
- ", leftContextSizeForExport=" + leftContextSizeForExport +
- ", locale='" + locale + '\'' +
- ", leftContextItem='" + leftContextItem + '\'' +
- ", leftContextSize=" + leftContextSize +
- ", rightContextItem='" + rightContextItem + '\'' +
- ", rightContextItemForExport='" + rightContextItemForExport
- + '\'' +
- ", rightContextSize=" + rightContextSize +
- ", rightContextSizeForExport=" + rightContextSizeForExport +
- ", selectedCollection='" + selectedCollection + '\'' +
- ", queryLanguage='" + queryLanguage + '\'' +
- ", pageLength=" + pageLength +
- ", metadataQueryExpertModus=" + metadataQueryExpertModus +
- ", defaultPOSfoundry='" + defaultPOSfoundry + '\'' +
- ", defaultLemmafoundry='" + defaultLemmafoundry + '\'' +
- ", defaultConstfoundry='" + defaultConstfoundry + '\'' +
- ", defaultRelfoundry='" + defaultRelfoundry + '\'' +
- ", collectData='" + collectData + "\'" +
- '}';
- }
-
- public static UserSettings fromString(String value) {
- Map<String, Object> map;
- try {
- map = JsonUtils.read(value, Map.class);
- }catch (IOException e) {
- return new UserSettings();
- }
- return UserSettings.fromObjectMap(map);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- UserSettings that = (UserSettings) o;
-
- if (userID != null ? userID != that.userID : that.userID != null)
- return false;
- if (id != null ? !id.equals(that.id) : that.id != null)
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (userID != null ? userID.hashCode() : 0);
- return result;
- }
-
- public String toJSON() {
- return JsonUtils.toJSON(this);
- }
-}
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java b/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java
index 35cc02b..353915f 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/user/UserdataFactory.java
@@ -5,6 +5,7 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
diff --git a/src/test/java/UserdataTest.java b/src/test/java/UserdataTest.java
index b635ddc..1acd921 100644
--- a/src/test/java/UserdataTest.java
+++ b/src/test/java/UserdataTest.java
@@ -1,5 +1,7 @@
import de.ids_mannheim.korap.config.BeanConfiguration;
import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.handlers.UserDetailsDao;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.user.*;
import org.junit.AfterClass;
import org.junit.Before;