Skip to content

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

Notifications You must be signed in to change notification settings

andresjz/RESTFUL-java-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTFUL EXAMPLE SPRING HIBERNATE MVC!

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/


Dependencies

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. and css
  • D3 A javascript library for charting

Structure project

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

TOMCAT or GLASHFISH SERVER

If you want to try a webproject you need to tomcat and then you can deploy the file .war included in the target folder.

HEROKU

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.

  1. 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

https://appName.herokuapp.com

Routes

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

Test

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

Graphs

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)

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages