Skip to Content

Welcome to Paul the Octopus – one of SAP HANA Cloud’s Community Samples! It will demonstrate how to use all the power and functionality of the Platform in one adorable web application. Do you remember Paul the Octopus from the FIFA World Cup 2010? He successfully predicted the winner of each of seven matches of the Germany national football team, as well as the champion of the final and this Community Sample is dedicated to him. Get ready! This app will not only show you the SAP HANA Cloud Platform’s Services, but will also amuse you. It’s not the usual rather boring “book-store” app – it’s an exciting game. There are plenty of matches every day and Paul is making his predictions for them. Here comes the cool thing – you can state your predictions as well. You can compete with Paul and try to beat him. So, take a deep breath and dive into the adventure with the SAP HANA Cloud Platform. In this blog you will get familiar with:

  • Overall picture
  • First steps of using the SAP HANA Cloud Platform
  • Importing the app as a project and running it
  • Using the Web UI and its functions

Overall picture

Before we get to play with this Community Sample, let’s see the overall picture. You have got a web application that you are going to deploy on the SAP HANA Cloud Platform. When you open your browser you see the user interface and start making requests to the server. The server sends responses to the browser and this whole communication process is handled via REST services.

Good, we got the communication between the server and the client. One more thing. Data for the fixtures (a synonym for a football match) is provided by a separate application that is called the data provider. But how does one app refer to another? It’s quite simple with the SAP HANA Cloud Connectivity Service (Internet Connectivity). What you do is to state the URL of the data provider application – https://octopuspaul.hana.ondemand.com/ptodata/ – in a new destination, named “opta” in the Connectivity tab of the server adapter.

/wp-content/uploads/2012/12/x032_202617.png

To conclude: you have got the UI connected to the back end via restful services and the back end connected to the data provider via Connectivity Service.


First steps of using the SAP HANA Cloud Platform

Before we start, you need to sign up for a SAP HANA Cloud account, download the Eclipse IDE for EE Developers and set up the Eclipse tools for SAP HANA. More information on this topic can be found in the SAP HANA Cloud Documentation Center.

Importing the app as a project and running it

1. Importing

This Community Sample is a web application that makes use of Maven. Here is how to run it. You will need the m2e plugin for Eclipse and the m2e-wtp one (installable from the Eclipse Market). Download the project from https://github.com/SAP/cloud-paulpredicts. Open your HANA Cloud Eclipse IDE (with runtime environment SAP HANA Cloud already set up) and import the project as an Existing Maven project. Create a new server – either local or on the Cloud.

2. Running – here we split into 2 different scenarios – locally and on the Cloud

Common task for both scenarios is creating the Destination, required for consuming the Connectivity Service. Double-click on the server, Connectivity tab, create a new Destination named “opta” and paste the following URL to the URL field: https://octopuspaul.hana.ondemand.com/ptodata/ (see screenshot below)


/wp-content/uploads/2012/12/destination_opta_208629.png

2.1. Local scenario – if you have created a new local server, then:

  • if you work behind a proxy server, then you should configure your proxy settings (host and port). Double click on the server, go to Overview tab and press the Open launch configuration. In the tab (x)= Arguments, VM Arguments add:

-Dhttp.proxyHost=<yourproxyHost> -Dhttp.proxyPort=<yourProxyPort>

-Dhttps.proxyHost=<yourproxyHost> -Dhttps.proxyPort=<yourProxyPort>

and set your proxy hosts and ports:

/wp-content/uploads/2012/12/proxy_208630.png


  • Create local users – double-click on the created server, go to the User tab and create new users with all the properties required. Set a role for every of your users. The role with name “Everyone” is mandatory and if you want to use the admin UI add one more role named “admin”.

/wp-content/uploads/2012/12/users_208670.png

  • Run MongoDB – it is used for the SAP HANA Cloud’s Document Service when running locally. Download MongoDB from here: http://www.mongodb.org/downloads, save the archive, unpack and execute the following command: mongod –dbpath C:\mongodb_data, where “C:\mongodb_data” is an empty directory.

Note: when running locally you will receive the mails on your local file system. In your local server’s folder/work/mailservice/

  • Run the application – right click on the project, Run As, Run on Server and select your server.

    Note: if the option Run on Server is not in the menu then right click on the project, Properties, Project Facets and make sure the Dynamic Web Module is checked and its version is 2.5.

2.2. Cloud scenario – if you have created a new server on the SAP HANA Cloud Platform, then:

  • for using the Mail Service you have got to complete a put-destination operation with a specially prepared file (you can find one in the project, named Session.template). Remove the .template extension(!) and fill in data regarding SMTP, username, password etc for your email account. The put-destination operation can be completed with the Console Client and with a special properties file, containing information about your SAP HANA Cloud account (you can also find this template in the same folder – configuration.properties). Fill in the template and enter the following command in the Console Client:

/wp-content/uploads/2012/12/05_168516.png

  • If you want to assign the admin role for your user when the app is deployed on the Cloud, go to the Cloud’s Cockpit, Authorizations tab and do the same as shown in the following screenshot:

/wp-content/uploads/2012/12/cockpit_authorizations_360299.png

Using the Web UI and its functions

When you open the app with your browser (e.g. http://localhost:8080/server in the local case) you will be prompted to fill in your username and password. Use the data you entered in the users tab above. After successful login you will see the following screen:

/wp-content/uploads/2012/12/07_168518.png

From the left – Paul and the percentage of his correct predictions and on the right – you and your correct predictions. You can change your profile picture if you wish. Just click the default one and a dialog like this will appear:

/wp-content/uploads/2012/12/08_168519.png

Select another image from your file system and that’s it. This feature makes use of SAP HANA Cloud’s Document Service.

The Fixtures tab is separated into 2 sub-tabs – one dedicated to the Future Fixtures and one to the Past Fixtures. In the Future Fixtures tab you can see all the matches you can make prediction for. When clicking on the left side of a row in the table you can see details about the teams that are going to compete right below the table. The ones which you already predicted are marked with orange labels:

/wp-content/uploads/2012/12/09_168520.png

You can make your prediction (or change a previous one) with the button in the last column of each row. A dialog (like the one below this paragraph) is going to pop up and prompts you to select a possible outcome.

/wp-content/uploads/2012/12/10_168521.png

In the Past Fixtures tab you can see whether your predictions had been right or not. The screen looks like this:

/wp-content/uploads/2012/12/11_168522.png

There is an admin UI. If you want to see it, you have to add “admin” right after the “… /server/” part of the URL. Please note that the admin UI is accessible only for Administrators, so you have to assign your user such a role. The admin UI contains monitoring tools (check out the users that use the app, a list of all the teams, fixtures and predictions) and some controlling – you can manually trigger importing fixtures from the data provider and trigger Paul to make his predictions. Here is how the admin UI looks like:

In the users tab you can see a list of all the users that are playing against Paul.


/wp-content/uploads/2012/12/12_168523.png

In the teams tab you can see all the teams that have already played or are going to play.


/wp-content/uploads/2012/12/13_168527.png

In the fixtures tab – probably you have already guessed – that’s right – all the fixtures are there.


/wp-content/uploads/2012/12/14_168528.png

In the predictions tab you can check out all the predictions made by all the users:


/wp-content/uploads/2012/12/15_168529.png

In the jobs tab you can manually trigger data importing and Paul making his predictions:


/wp-content/uploads/2012/12/16_168530.png

Enthusiastic already? Our follow-up blogs in which we get technical and explain how this app was created are now on the final straight.

Here is the first one: Paul Dissected Part 1









To report this post you need to login first.

17 Comments

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

  1. Former Member

    Great job! This fun sample app demonstrates usage of persistence, identity management, document and mail services, and connectivity – in an easy to understand way. Looking forward to the follow-up technical blogs!

    (0) 
  2. Former Member

    Thanks for this blog. Very interesting and thorough example app. I didn’t know mongodb was used when using the Document service locally – I wonder if NWCloud also uses it internally. Really looking forward to your “explanation” blog. Thx.     😉

    (0) 
  3. Robin van het Hof

    Excellent blog and sample app implementation! I have always wondered how I could test document services locally and this blog & application explained that wonderfully!

    Thanks!

    (0) 
  4. Anne Lubig

    Hello,

    at first: nice application!

    I have a problem when importing the project. I downloaded a m2e plugin but I got different error messages for file pom.xml: One is for example:

     

    Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (execution: default-compile, phase: compile)

    Could it be that I have a wrong plugin? Can you tell me which is the right one?

    Thanks,

    Anne

    (0) 
    1. Petar Ivanov
      Post author

      Hi Anne,

      we have some suggestions about what went wrong but we need some more info. Please, contact me via email and we will solve the issue.

      Regards!

      (0) 
  5. Former Member

    Hello, for your REST / JAX-RS implementation I see you went with Apache CXF. Do you know if SAP HANA Cloud Platform will work with Jersey? I am in the initial stages of trying to get our application ported to HCP and was wondering? An initial attempt seemed to present some OSGi errors.

    (0) 
    1. Petar Ivanov
      Post author

      Hi Kevin,

      yes you can use Jersey with HANA Cloud platform. I have tried it myself. If you wish you can contact me via email and I can set-up an example project with Jersey for you.

      Best regards,

      Petar

      (0) 
  6. Former Member

    Great app to have a very quick and comprehensive information on HANA Cloud platform

    I tried the steps mentioned above.

    I could import and build the source using maven  but while running on local server

    I get error “Publishing to SAP HANA Cloud Platform local runtime,,,”. See the log for details

    Not sure where to check this log.

    Any idea will be helpful here

    Thanks in advance

    Apoorv

    (0) 
    1. Petar Ivanov
      Post author

      Hi,

      you may check the logs of your local server in the ‘Server Log’ view (from menu: Window – Show View). After you open the view you are asked to select particular server. Select the one on which you try to run Paul. First look in the file named ‘ljs_trace.log’. If an exception has been thrown it got to be there. My e-mail is public. Feel free to contact me at any time in case of questions.

      PS: since you have built it successfully with Maven without trying to run the app, it might be an IDE issue.

      Regards and thank you for being interested in Paul the Octopus,

      Petar

      (0) 

Leave a Reply