Commit 2ea26116 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'devel_11.1.x' into 'devel_11.0.x'

# Conflicts:
#   CHANGELOG
parents d5b04014 ef9d76d7
......@@ -60,6 +60,8 @@ import lcsb.mapviewer.persist.dao.cache.CacheTypeDao;
"/applicationContext-annotation.xml", //
"/applicationContext-persist.xml", //
"/test-applicationContext.xml", //
"/test-applicationContext.xml", //
"/dataSource.xml", //
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class AnnotationTestFunctions extends AbstractTransactionalJUnit4SpringContextTests {
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
This configuration file was written by the eclipse-cs plugin configuration editor
<!--
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
Checkstyle-Configuration: MapViewer checkstyle
Description: none
<!--
Checkstyle-Configuration: MapViewer checkstyle
Description: none
-->
<module name="Checker">
<property name="severity" value="warning"/>
......
......@@ -22,6 +22,8 @@ import lcsb.mapviewer.persist.dao.map.ModelDao;
@Transactional(value = "txManager")
@ContextConfiguration(locations = { "/applicationContext-persist.xml", //
"/test-applicationContext.xml",//
"/dataSource.xml", //
})
@RunWith(SpringJUnit4ClassRunner.class)
public class DbSerializationTest {
......
......@@ -9,6 +9,8 @@ versionCompLt() {
[ "$1" = "$2" ] && return 1 || versionCompLte $1 $2
}
# file with bash code generating DB schema diffs for different versions
dbschemadiff=management_scripts/db_schema_and_diff.sh
#Where source file of the debian package should be placed
SRC_DIR=debian/src
......@@ -54,22 +56,9 @@ cp debian/scripts/common.sh $SRC_DIR/
#copy changelog file
cp CHANGELOG $ROOT_DIR/debian/template/changelog
#this variable will contain all available versions of the package
versions=();
#this is current (latest) version of the package
current_version=-1;
#find all available versions
for version in `ls $DB_SCHEMA_DIR | sort -V`;
do
if [ -d "$DB_SCHEMA_DIR/$version" ]
then
versions+=($version);
current_version=$version;
fi
done
# set $versions and $current_version; generate upgrade scripts in SRC_DIR
DBSCRIPT_DEST_DIR=$SRC_DIR
source $dbschemadiff
echo "Current version: " $current_version
......@@ -81,47 +70,6 @@ then
exit 1;
fi
#--------------------------------------
# GENERATE DB schemas and diff files
#--------------------------------------
#last version (used for generating db diff files)
last_version=-1;
for version_A in ${versions[*]}
do
#main update file (used to create this version - it's a diff
#between base.sql and current version)
update_file=$SRC_DIR/db_0_to_$current_version".sql";
#now iterate through all versions
for file in `ls $DB_SCHEMA_DIR/$version_A | sort -V`;
do
if [ -f "$DB_SCHEMA_DIR/$version_A/$file" ]
then
#add differemce tp current db schema diff
printf "\n\n-- UPDATE $version_A/$file\n\n" >>$update_file;
cat $DB_SCHEMA_DIR/$version_A/$file >> $update_file;
#and now iterate again through all versions to add diffs
#between previous versions and current one
for version_B in ${versions[*]}
do
#update from version_B should contain all db changes that appeard
#after #version_B (so version_A must be later)
if versionCompLt $version_B $version_A
then
upd_file=$SRC_DIR/db_"$version_B"_to_$current_version".sql";
printf "\n\n-- UPDATE $version_A/$file\n\n" >>$upd_file;
cat $DB_SCHEMA_DIR/$version_A/$file >> $upd_file;
fi
done
fi
done
last_version=$version_A
done
#------------------------------------------
# Now we have all db schema diff files. Let's start preparing
# debian package
......
# shell snippet which extracts all available MINERVA versions from
# subdirectories available in DB_SCHEMA_DIR (typically
# `persist/src/db`) and generates database upgrade scripts (diff
# files)
# Precondition: the following variables have to be correctly initialised
# * DB_SCHEMA_DIR set to the directory containing database initialisation and upgrade sql commands
# * DBSCRIPT_DEST_DIR set to the directory that will be populated with database upgrade scripts
# Postcondition:
# * versions is set to the available MINERVA versions (bash array)
# * current_version is set to the latest available version
# * DBSCRIPT_DEST_DIR contains script to initialise the database from any version to the current version
#this variable will contain all available versions of the package
versions=();
#this is current (latest) version of the package
current_version=-1;
#find all available versions
for version in `ls "$DB_SCHEMA_DIR" | sort -V`;
do
if [ -d "$DB_SCHEMA_DIR/$version" ]
then
versions+=($version);
current_version=$version;
fi
done
#--------------------------------------
# GENERATE DB schemas and diff files
#--------------------------------------
versionCompLte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
versionCompLt() {
[ "$1" = "$2" ] && return 1 || versionCompLte $1 $2
}
#last version (used for generating db diff files)
for version_A in ${versions[*]}
do
#main update file (used to create this version - it's a diff
#between base.sql and current version)
update_file="$DBSCRIPT_DEST_DIR/db_0_to_${current_version}.sql";
#now iterate through all versions
for file in `ls "$DB_SCHEMA_DIR/$version_A" | sort -V`;
do
if [ -f "$DB_SCHEMA_DIR/$version_A/$file" ]
then
#add difference to current db schema diff
printf "\n\n-- UPDATE $version_A/$file\n\n" >> "$update_file";
cat "$DB_SCHEMA_DIR/$version_A/$file" >> "$update_file";
#and now iterate again through all versions to add diffs
#between previous versions and current one
for version_B in ${versions[*]}
do
#update from version_B should contain all db changes that appeared
#after #version_B (so version_A must be later)
if versionCompLt $version_B $version_A
then
upd_file="$DBSCRIPT_DEST_DIR/db_${version_B}_to_${current_version}.sql";
printf "\n\n-- UPDATE $version_A/$file\n\n" >> "$upd_file";
cat "$DB_SCHEMA_DIR/$version_A/$file" >> "$upd_file";
fi
done
fi
done
done
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
......@@ -8,28 +8,14 @@
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!-- Data Source Declaration -->
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="org.postgresql.Driver" />
<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/map_viewer" />
<property name="user" value="map_viewer" />
<property name="password" value="123qweasdzxc" />
<property name="maxPoolSize" value="100" />
<property name="maxStatements" value="5" />
<property name="minPoolSize" value="5" />
</bean>
<bean id="BaseDao" class="lcsb.mapviewer.persist.dao.BaseDao" abstract="true">
</bean>
<bean id="BaseDao" class="lcsb.mapviewer.persist.dao.BaseDao" abstract="true"/>
<bean id="UserDao" class="lcsb.mapviewer.persist.dao.user.UserDao" parent="BaseDao"/>
<bean id="PrivilegeDao" class="lcsb.mapviewer.persist.dao.user.PrivilegeDao" parent="BaseDao"/>
<bean id="LogDao" class="lcsb.mapviewer.persist.dao.log.LogDao" parent="BaseDao"/>
<bean id="BigFileEntryDao" class="lcsb.mapviewer.persist.dao.cache.BigFileEntryDao" parent="BaseDao"/>
<bean id="UploadedFileEntryDao" class="lcsb.mapviewer.persist.dao.cache.UploadedFileEntryDao" parent="BaseDao"/>
<bean id="ConfigurationDao" class="lcsb.mapviewer.persist.dao.ConfigurationDao" parent="BaseDao"/>
......@@ -200,8 +186,6 @@
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<!--<prop key="hibernate.show_sql">true</prop>-->
<!--<prop key="hibernate.current_session_context_class">thread</prop>-->
<!--<prop key="hibernate.hbm2ddl.auto">create</prop> -->
</props>
</property>
</bean>
......@@ -220,27 +204,4 @@
<bean id="PasswordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>
<!-- These beans are responsible for statistics (used for debuging) -->
<!--
<bean id="hibernateStatisticsMBean" class="org.hibernate.jmx.StatisticsService">
<property name="statisticsEnabled" value="true" />
<property name="sessionFactory" value="#{SessionFactory}" />
</bean>
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter"
lazy-init="false">
<property name="server" ref="mbeanServer" />
<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
<property name="beans">
<map>
<entry key="yourkey:name=hibernateStatistics" value-ref="hibernateStatisticsMBean" />
</map>
</property>
</bean>
-->
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:property-placeholder location="classpath:db.properties" />
<!-- Data Source Declaration -->
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="org.postgresql.Driver" />
<property name="jdbcUrl" value="${database.uri}" />
<property name="user" value="${database.username}" />
<property name="password" value="${database.password}" />
<property name="maxPoolSize" value="100" />
<property name="maxStatements" value="5" />
<property name="minPoolSize" value="5" />
</bean>
</beans>
database.uri=jdbc:postgresql://localhost:5432/map_viewer
database.username=map_viewer
database.password=123qweasdzxc
\ No newline at end of file
......@@ -56,7 +56,10 @@ import lcsb.mapviewer.persist.dao.user.UserDao;
@Transactional(value = "txManager")
@Rollback(true)
@ContextConfiguration(locations = { "/applicationContext-persist.xml", "/test-applicationContext.xml" })
@ContextConfiguration(locations = { "/applicationContext-persist.xml", //
"/test-applicationContext.xml", //
"/dataSource.xml" //
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class PersistTestFunctions {
private Logger logger = Logger.getLogger(PersistTestFunctions.class);
......
......@@ -55,6 +55,7 @@ import org.xml.sax.SAXException;
"/applicationContext-reactome.xml", //
"/applicationContext-persist.xml", //
"/test-applicationContext.xml", //
"/dataSource.xml", //
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class ReactomeTestFunctions {
......
......@@ -63,8 +63,12 @@ import lcsb.mapviewer.services.view.AuthenticationToken;
@Transactional(value = "txManager")
@Rollback(true)
@ContextConfiguration(
locations = { "/applicationContext-persist.xml", "/applicationContext-annotation.xml", "/applicationContext-service.xml", "/applicationContext-rest.xml" })
@ContextConfiguration(locations = { "/applicationContext-persist.xml", //
"/applicationContext-annotation.xml", //
"/applicationContext-service.xml", //
"/applicationContext-rest.xml", //
"/dataSource.xml", //
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class RestTestFunctions {
private Logger logger = Logger.getLogger(RestTestFunctions.class);
......@@ -200,9 +204,9 @@ public abstract class RestTestFunctions {
complexParams.entry(entry4);
complexParams.entry(entry5);
Model model =parser.createModel(complexParams);
Model model = parser.createModel(complexParams);
model.setTileSize(256);
for (ModelSubmodelConnection connection: model.getSubmodelConnections()) {
for (ModelSubmodelConnection connection : model.getSubmodelConnections()) {
connection.getSubmodel().setTileSize(256);
}
model.setProject(new Project());
......
MINERVA installation instructions using RPM Package Manager
===========================================================
These instructions guide you through the installation process of
`MINERVA <https://git-r3lab.uni.lu/piotr.gawron/minerva>`_ on Red Hat
Enterprise Linux 7 or CentOS 7. The server will also host the database
required for the functioning of MINERVA.
.. note::
Content visualization of MINERVA platform is supported by Google
Maps API. Users of MINERVA platform are obliged to comply with the
`Google Maps/Google Earth APIs Terms of Service
<https://www.google.com/intl/en-US_US/help/terms_maps.html>`_.
Overview
--------
The main steps are
* Install `PostgreSQL <https://www.postgresql.org/>`_ and set up a
database.
* Install and configure `Apache Tomcat <https://tomcat.apache.org/>`_.
* Install the MINERVA RPM.
PostgreSQL
----------
Install PostgreSQL and initialise it with
.. code:: shell
yum install -y postgresql-server
postgresql-setup initdb
Ensure that the database authentication on IPv4 on ``localhost`` is
done with md5-based passwords by adding the following line to
``/var/lib/pgsql/data/pg_hba.conf``
.. code::
host all all 127.0.0.1/32 md5
Enable and start postgresql
.. code:: shell
systemctl enable postgresql
systemctl start postgresql
Create the MINERVA database user and the database
.. code:: shell
su - postgres -c "createuser -d -r -s map_viewer"
su - postgres -c "echo \"ALTER USER map_viewer WITH PASSWORD '123qweasdzxc';\"| psql"
su - postgres -c "createdb -O map_viewer map_viewer"
.. warning::
Currently the password for the database user ``map_viewer`` is
hardcoded, therefore make sure the database cannot be accessed
from distrusted hosts.
Apache Tomcat
-------------
Install and enable (don't start yet) Apache Tomcat with
.. code:: shell
yum install -y tomcat
systemctl enable tomcat
In ``/etc/sysconfig/tomcat``, adjust the memory settings, e.g.
.. code::
JAVA_OPTS="-Xms2048M -Xmx4096M"
Make sure to open the port (by default port 8080) to allow incoming
connections, e.g. using ``firewalld`` this can be accomplished with
.. code:: shell
firewall-cmd --permanent --zone=public --add-port=8080/tcp
.. warning::
Currently the administrator password of MINERVA is hardcoded,
therefore make sure the MINERVA cannot be accessed from distrusted
hosts until the password was changed.
MINERVA
-------
Install MINERVA using ``yum``
.. code:: shell
yum install -y minerva-X.Y.Z-1.el7.centos.noarch.rpm
and start tomcat
.. code:: shell
systemctl start tomcat
Now point your browser to the newly installed service, e.g. on a local
network this could be `<http://192.168.0.42:8080/minerva/>`_.
.. warning::
This way of installing MINERVA does **not** ensure that security
updates are installed with ``yum update``, therefore you have to
establish a process to install such updates manually.
#!/bin/bash
set -e
MINERVA_SRC_DIR="$(dirname "$(dirname "$0")")"
# where generated files will be written
RPMBUILD_TEMP="${RPMBUILD_TEMP:-$MINERVA_SRC_DIR/rpm/rpmbuildtemp}"
if [[ "$RPMBUILD_TEMP" =~ ' ' ]]; then
echo "RPMBUILD_TEMP contains whitespace: '$RPMBUILD_TEMP'"
echo "This is not allowed. Please provide a different directory to create the RPM with"
echo " RPMBUILD_TEMP=/path/without/whitespace/ \"$0\""
exit 1
fi
# current date (for automatic changelog)
CURDATE=$(date +"%a %b %d %Y")
# file that should be deployed on tomcat
TOMCAT_FILE="$MINERVA_SRC_DIR/web/target/web-1.0.war"
# file with bash code generating DB schema diffs for different versions
dbschemadiff="$MINERVA_SRC_DIR/management_scripts/db_schema_and_diff.sh"
# directory with database schema
DB_SCHEMA_DIR="$MINERVA_SRC_DIR/persist/src/db"
# destination directory for database upgrade scripts
DBSCRIPT_DEST_DIR="$RPMBUILD_TEMP/BUILD/sql"
# clean build directories
rm -rf "$RPMBUILD_TEMP"
# create directory
mkdir -p "$RPMBUILD_TEMP/"{BUILD,SPECS}
# copy war file and other files
cp "$TOMCAT_FILE" "$RPMBUILD_TEMP/BUILD/minerva.war"
cp "$MINERVA_SRC_DIR/README.md" "$MINERVA_SRC_DIR/CHANGELOG" "$MINERVA_SRC_DIR/rpm/INSTALL.rst" "$MINERVA_SRC_DIR/rpm/logrotate_minerva" "$RPMBUILD_TEMP/BUILD"
mkdir -p "$DBSCRIPT_DEST_DIR"
# copy base sql schema
cp "$DB_SCHEMA_DIR/base.sql" "$DBSCRIPT_DEST_DIR/db_0.sql"
# set $versions and $current_version; generate upgrade scripts in DBSCRIPT_DEST_DIR
source "$dbschemadiff"
# create RPM spec file
cp "$MINERVA_SRC_DIR/rpm/minerva.spec.in" "$RPMBUILD_TEMP/SPECS/minerva.spec"
sed -i "s/__CURRENT_VERSION__/$current_version/g" "$RPMBUILD_TEMP/SPECS/minerva.spec"
sed -i "s/__DATE__/$CURDATE/g" "$RPMBUILD_TEMP/SPECS/minerva.spec"
# build RPM
RPMBUILD_TEMP_ABS="$(readlink -f "$RPMBUILD_TEMP")"
echo "****** Building miverva $current_version RPM in $RPMBUILD_TEMP_ABS ****** "
set -x
rpmbuild -bb --define "_topdir $RPMBUILD_TEMP_ABS" "$RPMBUILD_TEMP_ABS/SPECS/minerva.spec"
set +x
echo "****** Finished building RPM ****** "
/var/log/tomcat/minerva.txt {
copytruncate
size 32k
weekly
dateext
rotate 52
compress
missingok
create 0640 tomcat tomcat
}