Skip to content
Rolf Thunbo edited this page Mar 17, 2015 · 18 revisions

Front-end

The front-end of the e-PRTR application is a single page GIS AngularJS application that uses a number of REST services for data retrieval.

Translation

For the moment, we only support English but we might need to support other languages. Titles, text, tooltips etc. are stored in a JSON file and integrated using the translationService which is defined in: home.js.

The current resource file can be found here: (eprtr-resource_en-gb.json).

The resource file is divided into main areas:

{"Main Area 1": 
   {
       "key1": "Value", 
       "key2": "Value" ...
   }, 
   "Main Area 2": 
   {
       "key1": "Value" ...
}

It is optional to add a Main Area in the translationService call. If a Main Area is provided only the key, value pais for that is returned, otherwise the entire resource file will be returned.

translationService.get('Main Area 1').then(function (data) {
    $scope.translation_main_area_1 = data;
});

Testing

The frontend contains logic, so it should be tested as well.

The tests are expressed as Jasmine specs (see Jasmine introduction).

Example:

activity-search-filter_test.js

Recommend reading

  1. AngularJS: Up and Running: Enhanced Productivity with Structured Web Apps, Shyam Seshadri and Brad Green

Back-end

The back-end of the e-PRTR application is based on Spring-MVC using JPA 2.1 (Hibernate) as the data abstraction layer between the services and the database.

Entity classes

An entity class can be auto-generated with Eclipse by right clicking the project and choosing the JPA Tools > Generate Entities from Tables menu item. Note that even optional fields are generated as primitives, - so those fields should be manually changed to the corresponding wrapper classes. Also an @Id annotation is required for any entity class, which indicates the primary key of the table being mapped.

Named queries

JPA Named Queries should be preferred over JPA Queries (a.k.a. inline queries).

Querying the database

There are a number of ways to retrieve data from the database using JPA. In this project we use JPA Named Queries and JPA Criteria Queries.

  1. JPA Named Queries
  1. JPA Criteria Queries

Testing

For the backend JUnit tests we use the Unitils JUnit4 test class runner which enables the test to use the @DataSet annotation to import test data and the @SpringApplicationContext annotation to initialize the spring application context.

The backend tests require that tables/views involved has been initialized using Liquibase. The initialization is done as part of the Maven build.

The tables/views are configured in changelog-master.xml and files included by this file.

Testing the Controller

Example:

NaceActivityControllerTest.java

Testing the Repository

Example:

NaceActivityRepositoryTest.java

Recommend reading

  1. Pro JPA 2, Mike Keith and Merrick Schincariol