luxmeter/pgalise — pull request #2 by richtekp (2013-11-12 07:49:24+00:00)
Title: Inheritance reorganization, change of graph library, change to PostGIS

Details of changes for current pull request:
There's possible overlapping with changes of former pull requests, because improvements have been extended
1.) Enforcement of type safety:
The passing of ids (in all forms of primitives) has been widely replaced with passing of objects.
2.) Reorganizing modulization:
The current inheritance of classes and package dependencies seemed to be incompatible with the enforced type safety which make it necessary to break the current hierarchy and dependency between packages. The latter have been mostly combined in shared, weather, traffic. Some parts might be abstracted again one day. A recreation of a class diagramm using tool support is recommended (organisation of classes should be much easier now that type safety is enforced).
3.) enhancement of EJB tests
Almost every test is now able to be executed in OpenEJBs embedded container providing out-of-box testing without setup
4.) JPA port
most code which used manual database access has been transformed to use JPA (if necessary new classes have been created to handle existing tasks)
5.) PostGIS integration:
switching to Hibernate spatial with PostGIS dependency required the enforcement of Postgresql database (credentials stayed the same). The following script can be used to install Postgis 2.0.2 and setup a postgres database on a Debian-based system (assuming you can gain root permissions on your account):

PGALISE_DB=$HOME/postgis
PGALISE_USER=*******
PGALISE_PW=****
sudo apt-get install postgresql
#sudo apt-get install postgis postgresql-9.1-postgis
POSTGIS_DIR=`mktemp -d`
sudo apt-get build-dep postgis # only sufficient if repository version would be 2.x
sudo apt-get install libgdal-dev
cd $POSTGIS_DIR
git clone https://github.com/postgis/postgis.git
cd postgis
git checkout 2.0.3
./autogen.sh
./configure # building outside source root doesnt't seem to be supported
make -j8
sudo make install

mkdir -p $PGALISE_DB
sudo chown postgres:postgres $PGALISE_DB
POSTGRES_DIR=/usr/lib/postgres/9.1/bin
sudo su postgres -c "$POSTGRES_DIR/initdb -D $PGALISE_DB"
sudo su postgres -c "/usr/lib/postgresql/9.1/bin/postgres -D /home/richter/postgis -p 5201 -h localhost" &
sleep 5 # well...
sudo su postgres -c "echo \"create user $PGALISE_USER with password '$PGALISE_PW'\" | psql -p 5201 -h localhost"
sudo su postgres -c "echo \"create extension postgis;\" | psql -p 5201 -h localhost"
sudo su postgres -c "echo \"create extension postgis_topology;\" | psql -p 5201 -h localhost"
sudo su postgres -c "echo \"create database pgalise \" | psql -p 5201 -h localhost"
sudo su postgres -c "echo \"create database pgalise_test \" | psql -p 5201 -h localhost"
sudo su postgres -c "echo \"grant all on database pgalise to $PGALISE_USER\" | psql -p 5201 -h localhost"
sudo su postgres -c "echo \"grant all on database pgalise_test to $PGALISE_USER\" | psql -p 5201 -h localhost"

The change in the database system might appear as a big step, but together with the exclusive usage of JPA it is as easy as plug & play
6.) weathercollector integrated in project:
The passing of object via database without usage of existing data structures seemed unnecessary. Therefore weathercollector has been made dependent mainly of weather and other projects. It should still be possible to invoke it as a separate process to acchieve constant data collection.
7.) enforcement of exceptions:
a lot of critical errors which were formerly ignored and displayed with Exception.printStackTrace are now wrapped into RuntimeException. This made some issues visible which also cause possible test failures. This change should be seen as an optional hint on critical parts of the framework. It is up to the person responsible for merging to skip these hints as they might be considered to be too strict5 at some points.
8.) Switching to type safe graph library jgrapht
The switch to jgrapht providing type save management of node and edges in navigation graphs (which should bring a performance improvement) caused necessity to add some classes like NavigationNode and NavigationEdge which are a blessing in terms of object orientated information management.
9.) Improvement of weather module
The weather module has been improved in terms of tests and functionality (providing better data management and abstracting inheritance hierarchies with duplicate properties)