Removed document controllers and KustvaktResource.
Change-Id: I5347a3d68a3d4f09debe6bca850523c9f148062f
diff --git a/full/Changes b/full/Changes
index 65b5d4c..49d53bd 100644
--- a/full/Changes
+++ b/full/Changes
@@ -16,6 +16,8 @@
11/12/2018
- Implemented revoking all tokens of a user client via a super client
(margaretha)
+ - Removed document controllers and KustvaktResource (margaretha)
+
# version 0.61.3
17/10/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/cache/ResourceCache.java b/full/src/main/java/de/ids_mannheim/korap/cache/ResourceCache.java
deleted file mode 100644
index 45f0ce7..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/cache/ResourceCache.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package de.ids_mannheim.korap.cache;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import de.ids_mannheim.korap.config.KustvaktCacheable;
-import de.ids_mannheim.korap.resources.KustvaktResource;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-
-/**
- * @author hanl
- * @date 23/03/2014
- *
- * @author margaretha
- * @date 01/03/2018
- *
- * EM: removed resource related code, keep cache
- */
-
-//todo: use interface (maybe a cachable interface?) and bean instanceing
-// todo: if cachable, data integrity needs to be checked! either remove caching or check integrity!
-@SuppressWarnings("all")
-public class ResourceCache extends KustvaktCacheable {
-
- private static Logger jlog = LogManager.getLogger(ResourceCache.class);
-
- public ResourceCache () {
- super("resources", "key:resources");
- }
-
-
- @Deprecated
- public <T extends KustvaktResource> T getCache (Object id, Class<T> cz) {
- Element e = CacheManager.getInstance().getCache("resources").get(id);
- if (e != null)
- return (T) e.getObjectValue();
- else
- return null;
- }
-
-
- @Deprecated
- public <R extends KustvaktResource> void cache (R resource) {
- CacheManager.getInstance().getCache("resources")
- .put(new Element(resource.getPersistentID(), resource));
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java b/full/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
deleted file mode 100644
index 9cdc277..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
+++ /dev/null
@@ -1,296 +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.Document;
-import de.ids_mannheim.korap.resources.KustvaktResource;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.BooleanUtils;
-import de.ids_mannheim.korap.utils.StringUtils;
-import edu.emory.mathcs.backport.java.util.Collections;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-
-import javax.print.Doc;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author hanl
- * @date 05/11/2014
- */
-// todo: error handling
-@Deprecated
-public class DocumentDao implements ResourceOperationIface<Document> {
-
- private NamedParameterJdbcTemplate jdbcTemplate;
-
-
- public DocumentDao (PersistenceClient client) {
- this.jdbcTemplate = (NamedParameterJdbcTemplate) client.getSource();
- }
-
-
- @Override
- public Document findbyId (Integer id, User user) throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("id", id);
- String sql = "select id, persistent_id, disabled, strftime('%s', created) as created from doc_store where id=:id";
- try {
- return this.jdbcTemplate.queryForObject(sql, s,
- new RowMapper<Document>() {
- @Override
- public Document mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- Document doc = null;
- if (!rs.isClosed()) {
- String s = rs.getString("persistent_id");
- System.out.println("VALUE IS " + s);
- doc = new Document(rs
- .getString("persistent_id"));
- doc.setId(rs.getInt("id"));
- doc.setCreated(rs.getTimestamp("created")
- .getTime());
- doc.setDisabled(rs.getBoolean("disabled"));
- }
-
- return doc;
- }
- });
- }
- catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
-
- // todo: search for partial matches if entire document is disabled
- // document id, consisting of corpus sigle, substring key and text number
- @Override
- public Document findbyId (String id, User user) throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("id", id);
- s.addValue("docSigle", StringUtils.getDocSigle(id));
-
- String sql = "select id, persistent_id, disabled, created from doc_store where persistent_id=:id or persistent_id like :docSigle;";
- try {
- return this.jdbcTemplate.queryForObject(sql, s,
- new RowMapper<Document>() {
- @Override
- public Document mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- Document doc = null;
- if (!rs.isClosed()) {
- doc = new Document(rs
- .getString("persistent_id"));
- doc.setId(rs.getInt("id"));
- doc.setCreated(rs.getLong("created"));
- doc.setDisabled(rs.getBoolean("disabled"));
- }
-
- return doc;
- }
- });
- }
- catch (EmptyResultDataAccessException em) {
- return null;
- }
- catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
-
- @Override
- public List<Document> findbyPartialId (String id, User user)
- throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("id", id + "%");
-
- String sql = "select id, persistent_id, disabled, created from doc_store where persistent_id like :id;";
- try {
- return this.jdbcTemplate.query(sql, s, new RowMapper<Document>() {
- @Override
- public Document mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- Document doc = null;
- if (!rs.isClosed()) {
- doc = new Document(rs.getString("persistent_id"));
- doc.setId(rs.getInt("id"));
- doc.setCreated(rs.getLong("created"));
- doc.setDisabled(rs.getBoolean("disabled"));
- }
-
- return doc;
- }
- });
- }
- catch (EmptyResultDataAccessException em) {
- return null;
- }
- catch (DataAccessException e) {
- e.printStackTrace();
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
-
- //todo:
- @Override
- public List<Document> getResources (Collection<Object> ids, User user)
- throws KustvaktException {
- return null;
- }
-
-
- @Override
- public int updateResource (Document document, User user)
- throws KustvaktException {
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("pid", document.getPersistentID());
- source.addValue("dis", BooleanUtils.getBoolean(document.isDisabled()));
- final String sql = "UPDATE doc_store set disabled=:dis where persistent_id=:pid;";
- try {
- return this.jdbcTemplate.update(sql, source);
- }
- catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
-
- @Override
- public int[] updateResources (List<Document> resources, User user)
- throws KustvaktException {
- return new int[0];
- }
-
-
- //todo: remove and introduce partial match search of persistent id!
- @Deprecated
- public List<Document> findbyCorpus (String corpus, int offset, int index)
- throws KustvaktException {
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("corpus", corpus + "%");
- source.addValue("offset", (offset * index));
- source.addValue("limit", offset);
- final String sql = "select id, persistent_id, disabled, created from doc_store where (persistent_id like :corpus) limit :offset, :limit";
- try {
- return this.jdbcTemplate.query(sql, source,
- new RowMapper<Document>() {
- @Override
- public Document mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- // todo: test on empty/closed resultset!
- if (!rs.isClosed()) {
- Document doc = new Document(rs
- .getString("persistent_id"));
- doc.setId(rs.getInt("id"));
- doc.setCreated(rs.getTimestamp("created")
- .getTime());
- doc.setDisabled(rs.getBoolean("disabled"));
- return doc;
- }
- return null;
- }
- });
- }
- catch (EmptyResultDataAccessException em) {
- em.printStackTrace();
- return Collections.emptyList();
- }
- catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
-
- @Deprecated
- public List<String> findbyCorpus (String corpus, boolean disabled)
- throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("corpus", corpus + "%");
- s.addValue("dis", BooleanUtils.getBoolean(disabled));
- String sql = "SELECT persistent_id FROM doc_store WHERE (persistent_id like :corpus) AND disabled=:dis;";
- try {
- return this.jdbcTemplate.queryForList(sql, s, String.class);
- }
- catch (EmptyResultDataAccessException em) {
- em.printStackTrace();
- return Collections.emptyList();
- }
- catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
- }
-
-
- // parent is disabled here
- @Override
- public int storeResource (Document resource, User user)
- throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("id", resource.getPersistentID());
- s.addValue("corpus", resource.getCorpus());
- s.addValue("dis", BooleanUtils.getBoolean(resource.isDisabled()));
-
- String sql = "INSERT INTO doc_store (persistent_id, disabled) VALUES (:id, :dis)";
- try {
- return this.jdbcTemplate.update(sql, s);
- }
- catch (DataAccessException e) {
- e.printStackTrace();
- throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT,
- "illegal argument given", resource.getPersistentID());
- }
- }
-
-
- @Override
- public int deleteResource (String id, User user) throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("id", id);
- String sql = "delete from doc_store where persistent_id=:id;";
- try {
- return this.jdbcTemplate.update(sql, s);
- }
- catch (DataAccessException e) {
- throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
- }
-
- }
-
-
- @Override
- public int size () {
- return -1;
- }
-
-
- @Override
- public int truncate () {
- String sql = "delete from doc_store;";
- try {
- return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
- }
- catch (DataAccessException e) {
- return -1;
- }
- }
-
-
- @Override
- public Class<Document> type () {
- return Document.class;
- }
-
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java b/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java
index b18ce0c..f4c2f49 100644
--- a/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java
+++ b/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java
@@ -4,7 +4,6 @@
import de.ids_mannheim.korap.config.FullConfiguration;
import de.ids_mannheim.korap.resource.rewrite.CollectionCleanRewrite;
-import de.ids_mannheim.korap.resource.rewrite.DocMatchRewrite;
// import de.ids_mannheim.korap.resource.rewrite.IdWriter;
import de.ids_mannheim.korap.resource.rewrite.RewriteHandler;
@@ -28,7 +27,6 @@
this.addProcessor(vcRewrite);
this.add(CollectionRewrite.class);
// this.add(IdWriter.class);
- this.add(DocMatchRewrite.class);
this.add(CollectionCleanRewrite.class);
}
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/DocumentController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/DocumentController.java
deleted file mode 100644
index ccd2b6d..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/DocumentController.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package de.ids_mannheim.korap.web.controller;
-
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-
-import com.sun.jersey.spi.container.ResourceFilters;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.DocumentDao;
-import de.ids_mannheim.korap.resources.Document;
-import de.ids_mannheim.korap.server.KustvaktServer;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.KustvaktResponseHandler;
-import de.ids_mannheim.korap.web.APIVersionFilter;
-import de.ids_mannheim.korap.web.filter.AdminFilter;
-
-/**
- * EM: To Do: restructure codes regarding service and controller layers
- *
- * @author hanl
- * @date 19/11/2014
- */
-@Deprecated
-@Controller
-@Path("/v0.1/doc")
-@ResourceFilters({APIVersionFilter.class, AdminFilter.class })
-@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
-public class DocumentController {
-
- @Autowired
- private KustvaktResponseHandler kustvaktResponseHandler;
-
- private static Logger jlog =
- LogManager.getLogger(DocumentController.class);
- private DocumentDao documentDao;
-
-
- @POST
- @Path("{doc}")
- public Response store (@PathParam("doc") String docid,
- @QueryParam("disabled") Boolean disabled) {
- Document doc = new Document(docid);
- doc.setDisabled(disabled);
- try {
- this.documentDao.storeResource(doc, null);
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok().build();
- }
-
-
- //todo: pipe add document to index endpoint
-
- @GET
- @Path("{corpus}")
- public Response get (@PathParam("corpus") String corpus,
- @QueryParam("index") Integer index,
- @QueryParam("offset") Integer length) {
- if (index == null) index = 1;
- if (length == null) length = 25;
- try {
- List docs = this.documentDao.findbyCorpus(corpus, length, index);
- //todo: serialize to document json
- return Response.ok(JsonUtils.toJSON(docs)).build();
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- }
-
-}
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index d0c3576..948b2f7 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -241,10 +241,6 @@
<constructor-arg ref="kustvakt_db" />
</bean>
- <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
<bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
<constructor-arg ref="kustvakt_config" />
</bean>
@@ -305,7 +301,6 @@
<util:list id="kustvakt_resources"
value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
- <ref bean="document_provider" />
</util:list>
<!-- specify type for constructor argument -->
diff --git a/full/src/main/resources/lite-config.xml b/full/src/main/resources/lite-config.xml
deleted file mode 100644
index b342c59..0000000
--- a/full/src/main/resources/lite-config.xml
+++ /dev/null
@@ -1,182 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
- xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
-
-
- <context:component-scan
- base-package="de.ids_mannheim.korap.web.filter, de.ids_mannheim.korap.web.utils,
- de.ids_mannheim.korap.authentication.http" />
- <context:annotation-config />
-
- <bean id="placeholders"
- class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
- <property name="ignoreResourceNotFound" value="true" />
- <property name="locations">
- <array>
- <value>classpath:properties/lite-jdbc.properties</value>
- <value>file:./lite-jdbc.properties</value>
- <value>classpath:properties/hibernate.properties</value>
- <value>classpath:kustvakt-lite.conf</value>
- <value>file:./kustvakt-lite.conf</value>
- </array>
- </property>
- </bean>
-
- <bean id="properties"
- class="org.springframework.beans.factory.config.PropertiesFactoryBean">
- <property name="ignoreResourceNotFound" value="true" />
- <property name="locations">
- <array>
- <value>classpath:kustvakt-lite.conf</value>
- <value>file:./kustvakt-lite.conf</value>
- </array>
- </property>
- </bean>
-
- <bean id="config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
- <constructor-arg index="0" name="properties" ref="properties" />
- </bean>
-
- <!-- Database -->
-
- <bean id="sqliteDataSource"
- class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
- lazy-init="true">
- <property name="driverClassName" value="${jdbc.driverClassName}" />
- <property name="url" value="${jdbc.url}" />
- <property name="username" value="${jdbc.username}" />
- <property name="password" value="${jdbc.password}" />
- <property name="connectionProperties">
- <props>
- <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
- </props>
- </property>
-
- <!-- relevant for single connection datasource and sqlite -->
- <property name="suppressClose">
- <value>true</value>
- </property>
- <!--<property name="initialSize" value="2"/> -->
- <!--<property name="poolPreparedStatements" value="true"/> -->
- </bean>
-
- <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
- <property name="baselineOnMigrate" value="true" />
- <!-- <property name="validateOnMigrate" value="false" /> -->
- <!-- <property name="cleanOnValidationError" value="true" /> -->
- <property name="locations" value="${jdbc.schemaPath}" />
- <property name="dataSource" ref="sqliteDataSource" />
- </bean>
-
- <bean id="entityManagerFactory"
- class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="sqliteDataSource" />
-
- <property name="packagesToScan">
- <array>
- <value>de.ids_mannheim.korap.entity</value>
- <value>de.ids_mannheim.korap.oauth2.entity</value>
- </array>
- </property>
- <property name="jpaVendorAdapter">
- <bean id="jpaVendorAdapter"
- class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
- <property name="databasePlatform" value="${hibernate.dialect}" />
- </bean>
- </property>
- <property name="jpaProperties">
- <props>
- <prop key="hibernate.dialect">${hibernate.dialect}</prop>
- <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
- <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
- <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
- <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
- </prop>
- <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
- <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
- <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
- </props>
- </property>
- </bean>
- <tx:annotation-driven proxy-target-class="true"
- transaction-manager="transactionManager" />
-
- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactory" />
- </bean>
-
- <bean id="transactionTemplate"
- class="org.springframework.transaction.support.TransactionTemplate">
- <constructor-arg ref="transactionManager" />
- </bean>
- <bean id="txManager"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="sqliteDataSource" />
- </bean>
-
- <!-- Initialization -->
- <bean id="initializator" class="de.ids_mannheim.de.init.LiteInitializatorImpl"
- init-method="init">
- </bean>
- <bean id="annotationParser" class="de.ids_mannheim.korap.annotation.AnnotationParser"
- scope="singleton" />
-
- <!-- Krill -->
- <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
- <constructor-arg value="${krill.indexDir}" />
- </bean>
-
- <!-- Filters -->
- <bean id="APIVersionFilter" class="de.ids_mannheim.korap.web.APIVersionFilter"
- scope="singleton" />
-
- <!-- Authentication -->
- <bean id="authenticationManager"
- class="de.ids_mannheim.korap.authentication.DummyAuthenticationManager" />
-
- <!-- Response handler -->
- <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
- <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
- </bean>
-
- <!-- Controllers -->
- <bean id="annotationController"
- class="de.ids_mannheim.korap.web.controller.AnnotationController" />
- <bean id="searchController" class="de.ids_mannheim.korap.web.controller.SearchController" />
- <bean id="statisticController"
- class="de.ids_mannheim.korap.web.controller.StatisticController" />
-
- <!-- Services -->
- <bean id="annotationService" class="de.ids_mannheim.korap.service.AnnotationService"></bean>
- <bean id="scopeService"
- class="de.ids_mannheim.korap.oauth2.service.DummyOAuth2ScopeServiceImpl" />
- <bean id="searchService" class="de.ids_mannheim.korap.service.SearchService"></bean>
-
- <!-- DAO -->
- <bean id="adminDao" class="de.ids_mannheim.korap.dao.DummyAdminDaoImpl" />
- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao" />
-
- <!-- DTO Converter -->
- <bean id="annotationConverter" class="de.ids_mannheim.korap.dto.converter.AnnotationConverter" />
-
- <!-- Rewrite -->
- <bean id="rewriteHandler" class="de.ids_mannheim.korap.resource.rewrite.RewriteHandler">
- <constructor-arg ref="config" />
- </bean>
-
-
-
- <bean id="kustvakt_auditing"
- class="de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing">
- </bean>
-
-</beans>
\ No newline at end of file
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java b/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
index bb1923d..7994ef5 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
@@ -6,7 +6,6 @@
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
import de.ids_mannheim.korap.interfaces.db.AuditingIface;
-import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
/**
@@ -21,8 +20,6 @@
public AuditingIface getAuditingDao();
- public List<ResourceOperationIface> getResourceDaos();
-
public List<UserDataDbIface> getUserdataDaos();
public EncryptionIface getCrypto();
diff --git a/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java
deleted file mode 100644
index c19e0dc..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package de.ids_mannheim.korap.handlers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.resources.Document;
-
-/**
- * @author hanl
- * @date 12/11/2015
- */
-@Ignore
-@Deprecated
-public class DocumentDaoTest extends BeanConfigTest {
-
- @Autowired
- private DocumentDao dao;
-
-
- @After
- public void clear () {
- dao.truncate();
- }
-
-
- @Test
- public void testSet () throws KustvaktException {
- Document doc = new Document("BRZ13_APR.00001");
- doc.setDisabled(true);
- dao.storeResource(doc, null);
- }
-
-
- @Test
- public void testGet () throws KustvaktException {
- Document doc = new Document("BRZ13_APR.00002");
- doc.setDisabled(true);
- dao.storeResource(doc, null);
- Document doc1 = dao.findbyId(doc.getPersistentID(), null);
- assertNotNull(doc1);
- assertTrue(doc.isDisabled());
- }
-
-
- @Test
- public void testRemove () throws KustvaktException {
- Document doc = new Document("BRZ13_APR.00003");
- doc.setDisabled(true);
- dao.storeResource(doc, null);
- Document doc1 = dao.findbyId(doc.getPersistentID(), null);
- assertEquals(1, dao.deleteResource(doc.getPersistentID(), null));
- doc1 = dao.findbyId(doc.getPersistentID(), null);
- Assert.assertNull(doc1);
- }
-
-
- @Test
- public void testEmptyFind () throws KustvaktException {
- List<String> dc = dao.findbyCorpus("WPD", true);
- assertNotNull(dc);
- assertEquals("should be empty", 0, dc.size());
- }
-
-
- @Test
- public void testFindText () throws KustvaktException {
- int length = 10;
- for (int i = 0; i < length; i++) {
- Document doc = new Document("WPD_APR.0000" + i);
- doc.setDisabled(true);
- dao.storeResource(doc, null);
- }
- List<String> dc = dao.findbyCorpus("WPD", true);
-
- assertNotNull(dc);
- assertNotSame("should not be empty", 0, dc.size());
- assertEquals("not all found", length, dc.size());
- }
-
-
- @Test
- public void testFindDocByText () throws KustvaktException {
- Document doc = new Document("WPD_AAA", "WPD_AAA.02439");
- doc.setDisabled(true);
- dao.storeResource(doc, null);
-
- Document dfind = dao.findbyId(doc.getPersistentID(), null);
- assertNotNull(dfind);
- assertEquals(doc.getPersistentID(), dfind.getPersistentID());
- }
-
-
- @Test
- public void testFindDocByPartial () throws KustvaktException {
- Document doc = new Document("WPD_AAA.02439");
- doc.setDisabled(true);
- Document doc1 = new Document("WPD_AAA.02343");
- dao.storeResource(doc, null);
- dao.storeResource(doc1, null);
-
- List<Document> dfind = dao.findbyPartialId(doc.getDocSigle(), null);
- assertNotNull(dfind);
- assertNotEquals(0, dfind.size());
- assertEquals(2, dfind.size());
- assertEquals(doc.getDocSigle(), dfind.get(0).getDocSigle());
-
- dfind = dao.findbyPartialId(doc.getCorpus(), null);
- assertNotNull(dfind);
- assertNotEquals(0, dfind.size());
- assertEquals(2, dfind.size());
- assertEquals(doc.getDocSigle(), dfind.get(0).getDocSigle());
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {
- dao = new DocumentDao(helper().getContext().getPersistenceClient());
- }
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java
index 155e8be..c5814e4 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java
@@ -9,10 +9,8 @@
import org.springframework.aop.support.AopUtils;
import de.ids_mannheim.korap.config.BeansFactory;
-import de.ids_mannheim.korap.handlers.DocumentDao;
import de.ids_mannheim.korap.handlers.UserDetailsDao;
import de.ids_mannheim.korap.handlers.UserSettingsDao;
-import de.ids_mannheim.korap.resources.Document;
import de.ids_mannheim.korap.user.UserDetails;
import de.ids_mannheim.korap.user.UserSettings;
@@ -37,17 +35,4 @@
BeansFactory.closeApplication();
}
-
- @Test
- public void testResourceBeans () {
- BeansFactory.loadClasspathContext("test-config.xml");
- Collection coll = BeansFactory.getKustvaktContext()
- .getResourceProviders();
- assertFalse(coll.isEmpty());
- Object o = BeansFactory.getTypeFactory().getTypeInterfaceBean(coll,
- Document.class);
- assertEquals(DocumentDao.class, AopUtils.getTargetClass(o));
-
- BeansFactory.closeApplication();
- }
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java
index 53e28df..32deec8 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java
@@ -1,30 +1,19 @@
package de.ids_mannheim.korap.resource.rewrite;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
-import com.fasterxml.jackson.databind.JsonNode;
-
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.TestVariables;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.DocumentDao;
-import de.ids_mannheim.korap.resources.Document;
+import de.ids_mannheim.korap.rewrite.CollectionRewrite;
import de.ids_mannheim.korap.utils.JsonUtils;
-import net.sf.ehcache.CacheManager;
/**
- * EM: To do: not implemented in the new DB yet
* @author hanl
* @date 12/11/2015
*/
-@Ignore
public class ResultRewriteTest extends BeanConfigTest {
@Override
@@ -32,63 +21,16 @@
}
-
- // otherwise cache will maintain values not relevant for other tests
- @Before
- public void before () {
- CacheManager.getInstance().getCache("documents").removeAll();
- DocumentDao dao = new DocumentDao(helper().getContext()
- .getPersistenceClient());
- dao.truncate();
- }
-
-
@Test
public void testPostRewriteNothingToDo () throws KustvaktException {
RewriteHandler ha = new RewriteHandler();
ha.insertBeans(helper().getContext());
assertEquals("Handler could not be added to rewrite handler instance!",
- true, ha.add(DocMatchRewrite.class));
+ true, ha.add(CollectionRewrite.class));
- DocumentDao dao = new DocumentDao(helper().getContext()
- .getPersistenceClient());
- Document d = dao.findbyId("BRZ13_APR.00014", null);
- assertNull(d);
String v = ha.processResult(TestVariables.RESULT, null);
assertEquals("results do not match",
JsonUtils.readTree(TestVariables.RESULT), JsonUtils.readTree(v));
}
-
- @Test
- public void testResultRewriteRemoveDoc () throws KustvaktException {
- DocumentDao dao = new DocumentDao(helper().getContext()
- .getPersistenceClient());
-
- Document doc = new Document("WPD_AAA.02439");
- doc.setDisabled(true);
- dao.storeResource(doc, null);
-
- RewriteHandler ha = new RewriteHandler();
- ha.insertBeans(helper().getContext());
- assertEquals("Handler could not be added to rewrite handler instance!",
- true, ha.add(DocMatchRewrite.class));
-
- JsonNode check = JsonUtils.readTree(TestVariables.RESULT);
- assertNotNull(check);
- int check_size = check.at("/matches").size();
-
- String v = ha.processResult(TestVariables.RESULT, null);
- JsonNode node = JsonUtils.readTree(v);
-
- assertNotNull(node);
- int size = node.at("/matches").size();
- assertNotEquals("documents were not removed", check_size, size);
- assertEquals("result does not contain required matches", 22, size);
-
- dao.deleteResource(doc.getPersistentID(), null);
- Document d = dao.findbyId(doc.getPersistentID(), null);
- assertNull("document should not exist anymore!", d);
- }
-
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java
deleted file mode 100644
index 405bd6b..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package de.ids_mannheim.korap.resource.rewrite;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.joda.time.DateTime;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.test.annotation.DirtiesContext;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.config.TestVariables;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.DocumentDao;
-import de.ids_mannheim.korap.resources.Document;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.utils.TimeUtils;
-
-/** EM: DocumentDao is not available anymore.
- * Created by hanl on 30.05.16.
- */
-@Deprecated
-@Ignore
-public class RewriteBenchmarkTest extends BeanConfigTest {
-
-
- private static int THRESHOLD = 1000;
-
-
- @Test
- public void testDocMatchRewriteByTextSigle () throws KustvaktException {
- DocumentDao dao = new DocumentDao(helper().getContext()
- .getPersistenceClient());
-
- int i = 999;
- for (int j = 100; j < i; j++) {
- Document doc = new Document("WPD_AAA.02" + j);
- doc.setDisabled(true);
- dao.storeResource(doc, null);
- }
- RewriteHandler ha = new RewriteHandler();
- ha.insertBeans(helper().getContext());
- assertEquals("Handler could not be added to rewrite handler instance!",
- true, ha.add(DocMatchRewrite.class));
-
- DateTime now = TimeUtils.getNow();
- String v = ha.processResult(TestVariables.RESULT, null);
- long diff = TimeUtils.calcDiff(now, new DateTime());
- assertTrue(diff < THRESHOLD);
- JsonNode node = JsonUtils.readTree(v);
-
- JsonNode check = JsonUtils.readTree(TestVariables.RESULT);
- assertNotNull(check);
- int check_size = check.at("/matches").size();
-
- assertNotNull(node);
- int size = node.at("/matches").size();
- assertNotEquals("documents were not removed", check_size, size);
-
- dao.truncate();
- }
-
-
- @Test
- public void testDocMatchRewriteByDocSigle () throws KustvaktException {
- DocumentDao dao = new DocumentDao(helper().getContext()
- .getPersistenceClient());
-
- Document doc = new Document("WPD_AAA");
- doc.setDisabled(true);
- dao.storeResource(doc, null);
-
- RewriteHandler ha = new RewriteHandler();
- ha.insertBeans(helper().getContext());
- assertEquals("Handler could not be added to rewrite handler instance!",
- true, ha.add(DocMatchRewrite.class));
-
- DateTime now = TimeUtils.getNow();
- String v = ha.processResult(TestVariables.RESULT, null);
- long diff = TimeUtils.calcDiff(now, new DateTime());
- assertTrue(diff < THRESHOLD);
- JsonNode node = JsonUtils.readTree(v);
-
- JsonNode check = JsonUtils.readTree(TestVariables.RESULT);
- assertNotNull(check);
- int check_size = check.at("/matches").size();
-
- assertNotNull(node);
- int size = node.at("/matches").size();
- assertNotEquals("documents were not removed", check_size, size);
- assertEquals(0, size);
- dao.truncate();
- }
-
-
- @Test
- public void testCollectionRewriteInject () {
-
- }
-
-
- @Test
- public void testCollectionRewriteRemoval () {
-
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {}
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
index 81430c6..67f74bd 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
@@ -25,7 +25,6 @@
* @author hanl
* @date 21/10/2015
*/
-@Ignore
public class RewriteHandlerTest extends BeanConfigTest {
@Test
@@ -33,7 +32,6 @@
RewriteHandler handler = new RewriteHandler();
handler.insertBeans(helper().getContext());
assertTrue(handler.add(FoundryInject.class));
- assertTrue(handler.add(DocMatchRewrite.class));
assertTrue(handler.add(CollectionCleanRewrite.class));
assertTrue(handler.add(IdWriter.class));
}
@@ -95,18 +93,18 @@
node.at("/query/wrap/operands/1/foundry").asText());
}
-
+ // EM: Fix me usersetting
@Override
public void initMethod () throws KustvaktException {
- helper().setupAccount();
- UserDataDbIface settingsdao = BeansFactory.getTypeFactory()
- .getTypeInterfaceBean(
- helper().getContext().getUserDataProviders(),
- UserSettings.class);
- assertNotNull(settingsdao);
- UserSettings s = (UserSettings) settingsdao.get(helper().getUser());
- s.setField(Attributes.DEFAULT_LEMMA_FOUNDRY, "tt_test");
- settingsdao.update(s);
+// helper().setupAccount();
+// UserDataDbIface settingsdao = BeansFactory.getTypeFactory()
+// .getTypeInterfaceBean(
+// helper().getContext().getUserDataProviders(),
+// UserSettings.class);
+// assertNotNull(settingsdao);
+// UserSettings s = (UserSettings) settingsdao.get(helper().getUser());
+// s.setField(Attributes.DEFAULT_LEMMA_FOUNDRY, "tt_test");
+// settingsdao.update(s);
}
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index a0bc2ce..00361de 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -220,10 +220,6 @@
<constructor-arg ref="kustvakt_db" />
</bean>
- <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
<bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
<constructor-arg ref="kustvakt_config" />
</bean>
@@ -288,7 +284,6 @@
<util:list id="kustvakt_resources"
value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
- <ref bean="document_provider" />
</util:list>
<!-- specify type for constructor argument -->