Skip to Content
Web application using HANA, HTML5, Java, jQuery (AJAX), and Jersey (an open source project implementing JAX-RS, a Java based REST web services standard)

This application is a complete web application built on HTML5, jQuery, AJAX, and Java based RESTful web services to access the data calculated on HANA platform through HANA JDBC connector.  It shows a way to build web application using complete Java open source solutions.  It still needs the HANA models in the server side to provide those computations.  I explained the HANA models in this blog

Moreover, there is also a BI version using SAP BOBJ Dashboard which can be downloaded from this blog.  The development environment uses Eclipse tool. I packaged the whole source codes into a package.  You can download it from here.  The HANA models need manual work.  Please follow the instruction book to build the analytic views and calculation views.

This example demonstrates a very typical web application infrastructure to access data from HANA. The following table lists all components and the link to download them.  You can build a same environment in your local machine to try this example.  To build the HANA models, you can try to get one SAP HANA One developer edition on Amazon Web Service with free developer license (please check this link for more details.)

Type Explanation Open Source Projects
HTML5 Use HTML5 syntax to draw those charts and the interaction.  I used RGraph. Rgraph
AJAX The efficient way to define the interaction in javascript codes. jQuery
RESTful Web Service

This defines a set of APIs to access the data output model from SAP HANA. HTTP provides multiple features.  GET to retrieve and search data; POST to add data;  PUT to update data; and DELETE to delete data.  For this example, we just use GET to retrieve data.

Jersey

DAO / JDBC connector

Use JDBC to connect SAP HANA to trigger the computation in calculation view or collect the data from analytic view. SAP HANA Client
JSP Application Server Use TomCat application server to support JSP.  I used Xampp project, a free and open source cross-platform web server solution stack package.  TomCat  (Xampp)
Development tool Eclipse based development tool Eclipse Java EE IDE
Testing Tool(Optional) Help you to test the system

FireFox FireBug;

curl:  HTTP GET testing tool

Some credit card companies provide customers with tools to download and analyze their transaction history.  For example, Discover credit card provides the customers a detailed analysis tool in its website (www.discovercard.com).  It allows users to review the transaction history and analyze the customers’ history spending. 

This example is building on the similar data structure as discover credit card web site to show how to build a similar personal spending analysis tool. By following the steps, you will build your own personal spend analysis tool using SAP HANA and Java opensource solutions. You can download your transaction history data and follow this example to analyze it and you can expand it to do your own analysis. This example does provide a personal spending transaction history sample data.

This application uses web service to communicate.  There are two major classes of Web services: REST-compliant Web services and arbitrary Web services.  The REST-compliant Web services manipulate XML representations of Web resources using a uniform set of “stateless” operations.  And the arbitrary Web services expose an arbitrary set of operations. 

This example uses REST-complaint Web service.  In REST based architecture, everything is a resource. A resource is accessed via a common interface based on the HTTP standard methods.  REST allows that resources have different representations, e.g. text, xml, json etc. The REST client can ask for specific representation via the HTTP protocol. 

JAX-RS makes it easy to implement the REST Web Service API in Java.  Quick look at the JAX-RS annotations we used in our example.

@GET: HTTP function

@Path: path the method responds to.

@Produces: Generate one or more response content type(s).

The following table lists the final URL list for this HANA web application. These web service calls will trigger the Java DAO layer to access HANA data through HANA JDBC connector and SQL statements defined.The REST API in this example just use the GET methods which includes the following features:

Method URL Action
GET /psa/trans Retrieve all transactions
GET

/psa/trans/category

Retrieve transaction sum organized by category
GET /psa/trans/monthsum Retrieve transaction monthly sum
GET

/psa/trans/monthavg

Retrieve transaction monthly average
GET /psa/trans/monthavgdif Retrieve the difference of transaction monthly average
GET /psa/trans/classification Retrieve transaction sum by kmeans classification algorithm
GET /psa/trans/report Retrieve transaction report
GET /psa/trans/search/{node} Search for transaction with the search node in their name
GET

/psa/trans/{i}

Retrieve transaction with id == i

You can test the API using cURL.  You need to first deploy your application and then try to call these REST services straight from a browser address bar. For example, you could try:

http://localhost:8080/psa/trans

http://localhost:8080/psa/trans/search/Arizona

http://localhost:8080/psa/trans/5

Moreover, you can test the GET services in FireFox by using the FireBugs.  Or you can use cURL, for example, you can get all transaction by using the following commands: “curl -i -X GET http://localhost:8080/psa/transaction”  This command line will call the API and show you the data get from the HANA server.

The source codes and the war files are attached in this blog.  You can deploy this file to your local tomcat to execute it.  Of course, you need to build those HANA Modelers in your HANA server, and then configure HANA server information in the psa.properties file.  There are different ways to get your own HANA instance.  You can get a developer edition or use SAP HANA One.  To do that, use winrar to open the psa.war file and change the psa.properties file in psa.war\WEB-INF\classes.  Of course, you need to create the HANA models to start this application.

Please let me know your thinking and comments.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply