This project cover the integration of several Frameworks to create a simple restful service that shows a data about statistics of PISAMATHEMATICS over 20 countries during the last 20 years. The full demo is available on https://iwa-demo.herokuapp.com/
Frameworks and dependencies:
- Spring It is useful for mapping the views, it allows to create applications in MVC model.
- Hibernate This framework allows connect the Database write in
MySQL
,Postgress
,SQL
and implement all methods necessary for establish and easy connections with the DataBase and the Application.- REST-assured For testting purposes
- AngularJS A Javascript Framework for develoment in the client-side very useful and customizable.
- AWS (Optional) Amazon Web Services, Create a virtual machine, configure and start a instance with mySQL using remote connection.
- Heroku (Optional) Is a platform where I uploaded the project, it accepts to deploy a
.WAR
or.JAR
package.- Bootstrap A styling Framework written in
js
. andcss
- D3 A javascript library for charting
The current project has been developed with Maven in Netbeans, so it creates a basic project with all necessary elements to working in web. I customized some of that project including addtional folder an files that allows to work with Spring and Hibernate.
The final estructure looks like:
project
| README.md
| pom.xml
| nb-configuration.xml
|
?-----src
| |
| ?-----main
| | |
| | ?-----java
| | | |
| | | ?-----Controller
| | | | MathematicsController.java
| | | | MathematicsControllerRest.java
| | | |
| | | ?-----Dao
| | | | MathematicsDAO.java
| | | | MathematicsDAOImpl.java
| | | |
| | | ?-----Model
| | | | Mathematics.java
| | | |
| | | ?-----Service
| | | MathematicsService.java
| | | MathematicsServiceImpl.java
| | |
| | ?-----resources
| | |
| | |
| | ?-----webapp
| | spring-servlet.xml
| | web.xml
| | |
| | ?-----WEB-INF
| | home.jsp
| | form.jsp
| | pages/
| | pages/assets
| | ... plugins etc.
| |
| ?-----test
| |
| ?-----java
| controllerTest.java
|
?-----target
spring2.war
... *other files generated by netbeans
If you want to try a webproject you need to tomcat and then you can deploy the file .war
included in the target folder.
In the case of you can try to heroku app, first of all you need to have an account, the free service offer up to 5 applications, for purposes testing. Then you need to create a application in the herokuapp.com as you want to name, but you need to remeber it for deploy your application.
- Install heroku-cli
2 Install deploy plugin heroku-cli
$ heroku plugins:install heroku-cli-deploy
3 Upload the WAR file and wait until process shows Done
$ heroku war:deploy recommender-1.0.war --app appName
4 Abrir el sitio de la aplicación web
The example include a CRUD that you can use with the followings URL's
GET all https://iwa-demo.herokuapp.com/mathematics/get
GET {id} https://iwa-demo.herokuapp.com/{id}
INSERT https://iwa-demo.herokuapp.com/mathematics/insert
DELETE{id} https://iwa-demo.herokuapp.com/mathematics/delete/{id}
UPDATE https://iwa-demo.herokuapp.com/mathematics/update/{id}
It works with a Json file like this:
{
"id": int,
"location": String,
"indicator": String,
"subject": String,
"measure": String,
"frequency": String,
"times": int,
"value_m": float
}
The dataset was obtained from: https://data.oecd.org/pisa/mathematics-performance-pisa.htm
I have added some tests for review if CRUD working fine, but only GET request, if it is necessary in the future i will add more specific test using Restassured
I have added a final version to the git, with a experimental version with export to image, basically It works but also the function creates a Black background, I would like to check this bug with more time. (Export image has not been included in Demo page)