-
Notifications
You must be signed in to change notification settings - Fork 1
1 Architecture
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.
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;
});
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
- AngularJS: Up and Running: Enhanced Productivity with Structured Web Apps, Shyam Seshadri and Brad Green
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.
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.
JPA Named Queries should be preferred over JPA Queries (a.k.a. inline queries).
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.
- JPA Named Queries
- should be used for all simple queries such as find by name and find all etc
- ex. eea.eprtr.dao.LovCountryRepository#get
- JPA Criteria Queries
- should be used for all complex queries such as complex filtering queries
- ex. eea.eprtr.dao.FacilitySearchController#facilitySearch
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.
Example:
NaceActivityControllerTest.java
Example:
NaceActivityRepositoryTest.java
- Pro JPA 2, Mike Keith and Merrick Schincariol