Hello World!
These are the two words every developer knows best.
First, let me introduce myself. My name is Ilhan Myumyun, a newbie in the fantastic cloud world, with great passion for creating software. When I first opened the documentation of SAP HANA Cloud Platform I thought: ‘Wow, there are 4 services (persistence, connectivity, document and identity service) + the mail configurations. It will take some time before I get to code…’. But it turned out that I was absolutely wrong :smile: .
Now, I am presenting you what I have developed. After carefully reading the documentation, as well as playing around with one great sample – Paul the Octopus (which is a really nice work by the way), I made an app that is far away from being just a Hello World! application. And the best part is that it uses all the SAP HANA Cloud Platform services. And even better – it took me less than three weeks. (Bear in mind that I am still a student who attends classes, studies for exams, and in addition, I’m fighting against crime during the night, dressed like a superhero!..Well, OK, the superhero thing – not true :smile: ). But I am not only an enthusiast- my goal is to incorporate every new feature of the platform in this application.
Well, after this humble and “short” introduction, let’s take a look at the very application. It’s a library application.
How it works?
I guess you can’t wait to see some code. You can find it here.
How to run this app?
Let’s take a tour from downloading the source to having the application up and running.
7. You need to enter some more properties:
(Hint: you can simply import the destination that is located in the src/main/resources)
For the mail configurations you need a Mail destination (only if running the application on SAP HANA Cloud. In the local server scenario you will receive the messages on your local file system, folder: /Servers/<your server name>-config/work/mailservice and you don’t need a Mail destination)
(Hint: you can simply import the destination that is located in the src/main/resources and fill in the required data)
If you have chosen to create a local server instead of one on SAP HANA Cloud, you will need to add local users:
3. Assign the desired roles to your local users.
If you are running this sample on SAP HANA Cloud and you would like to assign an admin role to a particular user, you have to use SAP HANA Cloud Cockpit:
If you have chosen to create a local server and you work behind a proxy, you need the following properties added to your VM arguments in the run configurations:
-Dhttp.proxyHost=<yourproxyHost> -Dhttp.proxyPort=<yourProxyPort>
-Dhttps.proxyHost=<yourproxyHost> -Dhttps.proxyPort=<yourProxyPort>
You also need mongodb in the local scenario to store your profile images via the document service. You can download mongodb from here: http://www.mongodb.org/downloads. Unpack the downloaded archive and run the following command: mongod --dbpath C:\mongodb_data, where "C:\mongodb_data" is an empty directory.
Now, the most pleasant part: Right-click on the project, then choose Run As -> Run on Server and select the server you have just created.
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.
And you are ready! :smile:
Let’s open the application’s URL in the browser and sign in. First, we will get familiar with the screens an ordinary customer (role Everyone) can see:
Below you can see details of the book “Zorro” by Johnston McCulley. The cover of the book is displayed, as well as some additional information and a link to the book in Open Library:
The 5th column of this table shows the overall rating of the book. The 6th column, named Action, contains two buttons. Reserve button with which the user can reserve the desired book, of course if it is not already reserved. You can use the "Return" button wich makes the book available for reserving again. It is disabled, if the book is not reserved.
Here, the user can see the books that he/she has borrowed from the library, the remaining days before the book should be returned (by default the period is 30 days) and in the 4th column the user can rate the book.
Initially, the default image is displayed + some basic user information available from the identity service.
The user can click on the Browse button, select a different image and it will be set as profile picture. The image itself is stored into the document service repository.
The user can click on the Edit button and change some data (the user cannot upload images before the changes are saved). There is a client side validation that checks the user’s input (e.g. phone should be in a special format, not as free text). If the input is not correct, the Save button is disabled:
After the input is correct, the changes can be saved:
2. Now let’s see what an admin user can see:
In the Library view there are two additional buttons in Action column - Edit and Remove. The Edit button is enabled if the book is not reserved. If there is a typo in the title or author, the admin can fix this error via clicking this button. If the admin decides that a certain book will no longer be available for customers, he/she can easily remove it by the Remove button (also enabled if the book is not reserved). With the Return button the admin sets the book available for other customers to borrow it.
There is another button below the table – Add New Books. With this button the admin can add more books to the library. There are three fields that can be filled with input – ISBN, title and author. The first one is not mandatory because this application is only a sample, and there are not many people who are going to search over the Internet for the right ISBN number for the book they want to add. So it is possible to add a book without an ISBN. The second two are mandatory. Of course, I have prepared some predefined books that have got ISBNs as well. The link with thetitle is only enabled if ISBN is provided. See the screenshots below:
Here, the client side validation reminds the user that Author should be typed as well before clicking on the Save button. You can also use the predefined books:
Finally, there is additional tab, named All Users. The admin can chek the users that ever used the Library application.
Their e-mails are also available, so the admin can write to someone, if he needs to. For example, if some of the users forgot to return their books in time.
Log out functionality is also provided. After the user signs out, then he/she is redirected to another view:
From here he/she can sign in again and use this sample application.
So…
Do you like the app? Be prepared! My plans are to incorporate every new feature of SAP HANA Cloud Platform into this sample application and to demonstrate it to you in a fascinating way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
19 | |
13 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 |