Integrated lite and full services and controllers in core.
Change-Id: I34914c89c2266fa02bee1a5b0522c46139b13966
diff --git a/lite/src/main/resources/db/V1__annotation_tables.sql b/lite/src/main/resources/db/V1__annotation_tables.sql
new file mode 100644
index 0000000..b0299d1
--- /dev/null
+++ b/lite/src/main/resources/db/V1__annotation_tables.sql
@@ -0,0 +1,53 @@
+CREATE TABLE IF NOT EXISTS annotation(
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ code VARCHAR(20) NOT NULL,
+ type VARCHAR(20) NOT NULL,
+ text VARCHAR(20) NULL,
+ description VARCHAR(100) NOT NULL,
+ de_description VARCHAR(100)
+);
+
+CREATE UNIQUE INDEX annotation_index ON annotation (code, type);
+
+CREATE TABLE IF NOT EXISTS annotation_layer(
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ foundry_id INTEGER NOT NULL,
+ layer_id INTEGER NOT NULL,
+ description VARCHAR(255) NOT NULL,
+ FOREIGN KEY (foundry_id)
+ REFERENCES annotation (id)
+ ON DELETE CASCADE,
+ FOREIGN KEY (layer_id)
+ REFERENCES annotation (id)
+ ON DELETE CASCADE
+);
+
+CREATE UNIQUE INDEX annotation_layer_index ON annotation_layer (foundry_id, layer_id);
+
+CREATE TABLE IF NOT EXISTS annotation_key(
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ layer_id INTEGER NOT NULL,
+ key_id INTEGER NOT NULL,
+ FOREIGN KEY (layer_id)
+ REFERENCES annotation_layer (id)
+ ON DELETE CASCADE,
+ FOREIGN KEY (key_id)
+ REFERENCES annotation (id)
+ ON DELETE CASCADE
+);
+
+CREATE UNIQUE INDEX annotation_key_index ON annotation_key (layer_id, key_id);
+
+CREATE TABLE IF NOT EXISTS annotation_value(
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ key_id INTEGER NOT NULL,
+ value_id INTEGER NOT NULL,
+ FOREIGN KEY (key_id)
+ REFERENCES annotation_key (id)
+ ON DELETE CASCADE,
+ FOREIGN KEY (key_id)
+ REFERENCES annotation (id)
+ ON DELETE CASCADE
+);
+
+CREATE UNIQUE INDEX annotation_value_index ON annotation_value (key_id, value_id);
diff --git a/lite/src/main/resources/hibernate.properties b/lite/src/main/resources/hibernate.properties
new file mode 100644
index 0000000..199dc73
--- /dev/null
+++ b/lite/src/main/resources/hibernate.properties
@@ -0,0 +1,8 @@
+hibernate.dialect=org.hibernate.dialect.MySQLDialect
+hibernate.hbm2ddl.auto=none
+hibernate.show_sql=false
+hibernate.cache.use_query_cache=false
+hibernate.cache.use_second_level_cache=false
+hibernate.cache.provider=org.hibernate.cache.EhCacheProvider
+hibernate.cache.region.factory=org.hibernate.cache.ehcache.EhCacheRegionFactory
+hibernate.jdbc.time_zone=UTC
\ No newline at end of file
diff --git a/lite/src/main/resources/kustvakt-lite.conf b/lite/src/main/resources/kustvakt-lite.conf
index f0dd6b3..db385f0 100644
--- a/lite/src/main/resources/kustvakt-lite.conf
+++ b/lite/src/main/resources/kustvakt-lite.conf
@@ -8,7 +8,6 @@
krill.namedVC=vc
-
# Kustvakt
current.api.version = v1.0
diff --git a/lite/src/main/resources/kustvakt.info b/lite/src/main/resources/kustvakt.info
new file mode 100644
index 0000000..ea847bb
--- /dev/null
+++ b/lite/src/main/resources/kustvakt.info
@@ -0,0 +1,8 @@
+kustvakt.version=${project.version}
+kustvakt.name=${project.name}
+
+# use this file to define the properties and logging file names
+kustvakt.properties=./kustvakt-lite.conf
+kustvakt.logging=./log4j.properties
+kustvakt.cache=true
+kustvakt.cache_store=./store
\ No newline at end of file
diff --git a/lite/src/main/resources/lite-config.xml b/lite/src/main/resources/lite-config.xml
index 671ca33..7c5991c 100644
--- a/lite/src/main/resources/lite-config.xml
+++ b/lite/src/main/resources/lite-config.xml
@@ -1,57 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
+<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" />
+ <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="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 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="properties">
- <ref bean="properties"/>
+ <bean id="placeholders"
+ class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
+ <property name="ignoreResourceNotFound" value="true" />
+ <property name="locations">
+ <array>
+ <value>classpath:lite-jdbc.properties</value>
+ <value>file:./lite-jdbc.properties</value>
+ <value>classpath:hibernate.properties</value>
+ <value>classpath:kustvakt-lite.conf</value>
+ <value>file:./kustvakt-lite.conf</value>
+ </array>
</property>
</bean>
- <bean id="kustvakt_auditing"
- class="de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing">
- </bean>
-
- <bean id="kustvakt_response"
- class="de.ids_mannheim.korap.web.CoreResponseHandler">
- <constructor-arg index="0" name="iface" ref="kustvakt_auditing"/>
- </bean>
-
- <bean id="kustvakt_config"
- class="de.ids_mannheim.korap.config.KustvaktConfiguration">
- <constructor-arg index="0" name="properties" ref="properties"/>
- </bean>
-
- <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.resource.rewrite.RewriteHandler">
- <constructor-arg ref="kustvakt_config" />
+ <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="search_krill"
- class="de.ids_mannheim.korap.web.SearchKrill">
- <constructor-arg value="${krill.indexDir}"/>
- </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>
+ </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/lite/src/main/resources/lite-jdbc.properties b/lite/src/main/resources/lite-jdbc.properties
new file mode 100644
index 0000000..99e2e54
--- /dev/null
+++ b/lite/src/main/resources/lite-jdbc.properties
@@ -0,0 +1,9 @@
+#-------------------------------------------------------------------------------
+# Sqlite Settings
+
+jdbc.database=sqlite
+jdbc.driverClassName=org.sqlite.JDBC
+jdbc.url=jdbc:sqlite:liteDB.sqlite
+jdbc.username=pc
+jdbc.password=pc
+jdbc.schemaPath=db
\ No newline at end of file
diff --git a/lite/src/main/resources/log4j2.properties b/lite/src/main/resources/log4j2.properties
index f5e5366..b0115e7 100644
--- a/lite/src/main/resources/log4j2.properties
+++ b/lite/src/main/resources/log4j2.properties
@@ -20,8 +20,8 @@
logger.console.appenderRefs = stdout
logger.console.appenderRef.file.ref = STDOUT
-#loggers=file
-#logger.file.name=de.ids_mannheim.korap
-#logger.file.level = error
-#logger.file.appenderRefs = file
-#logger.file.appenderRef.file.ref = ERRORLOG
\ No newline at end of file
+loggers=file
+logger.file.name=de.ids_mannheim.korap
+logger.file.level = error
+logger.file.appenderRefs = file
+logger.file.appenderRef.file.ref = ERRORLOG
\ No newline at end of file