diff --git a/exercises-java/exercise1/README.md b/exercises-java/exercise1/README.md index 4c80c85..7966d81 100644 --- a/exercises-java/exercise1/README.md +++ b/exercises-java/exercise1/README.md @@ -16,11 +16,11 @@ Before you can start using SAP Application Studio, you need to create your devel -3. Choose a name for your dev space. For example **TechEd19_1XX**. **XX** is the number given to you by your instructor. +3. Choose a name for your dev space. For example **TechEd19**. 4. Choose **SAP Cloud Business Application** as the application type. - By selecting **SAP Cloud Business Application**, your space comes with several extensions out of the box that you'll need to develop CAP applications. For example, CDS tools are built in. This saves unnecessary setup time. + By selecting **SAP Cloud Business Application**, your space comes with several extensions out of the box that you'll need to develop CAP applications. For example, CDS tools are built in. This saves unnecessary setup time. 5. Choose **Create Dev Space**. @@ -46,7 +46,7 @@ Before you can start using SAP Application Studio, you need to create your devel ```bash mvn -B archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds \ - -DarchetypeVersion=1.0.1 -DcdsVersion=3.17.4 \ + -DarchetypeVersion=1.2.0 -DcdsVersion=3.21.2 \ -DgroupId=com.sap.teched.cap -DartifactId=products-service -Dpackage=com.sap.teched.cap.productsservice ``` diff --git a/exercises-java/exercise3/README.md b/exercises-java/exercise3/README.md index eecbe4a..a28f2db 100644 --- a/exercises-java/exercise3/README.md +++ b/exercises-java/exercise3/README.md @@ -25,7 +25,7 @@ For the bookstore, which you'll develop in this exercise we need to create and i ```bash mvn -B archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds \ - -DarchetypeVersion=1.0.1 -DcdsVersion=3.17.4 \ + -DarchetypeVersion=1.2.0 -DcdsVersion=3.21.2 \ -DgroupId=com.sap.teched.cap -DartifactId=bookstore ``` 4. To open the bookstore project in a new workspace: diff --git a/exercises-java/exercise4/README.md b/exercises-java/exercise4/README.md index 9464654..18313a2 100644 --- a/exercises-java/exercise4/README.md +++ b/exercises-java/exercise4/README.md @@ -85,7 +85,9 @@ You will now add a method to the `OrdersService` Java class to decrease the stoc @Before(event = CdsService.EVENT_CREATE, entity = "OrdersService.Orders") public void validateBookAndDecreaseStockViaOrders(List orders) { for(Orders order : orders) { - validateBookAndDecreaseStock(order.getItems()); + if(order.getItems() != null) { + validateBookAndDecreaseStock(order.getItems()); + } } } ``` @@ -106,10 +108,10 @@ You will now add a method to the `OrdersService` Java class to decrease the stoc import com.sap.cds.services.handler.annotations.Before; import com.sap.cds.services.persistence.PersistenceService; - import ordersservice.OrderItems; - import ordersservice.Orders; - import sap.capire.bookstore.Books; - import sap.capire.bookstore.Books_; + import cds.gen.ordersservice.OrderItems; + import cds.gen.ordersservice.Orders; + import cds.gen.sap.capire.bookstore.Books; + import cds.gen.sap.capire.bookstore.Books_; ``` Let's break down what is happening: @@ -247,7 +249,9 @@ Finally, add a method to the `OrdersService` Java class to calculate the `total` public void calculateTotal(List orders) { for (Orders order : orders) { // calculate net amount for expanded items - calculateNetAmount(order.getItems()); + if(order.getItems() != null) { + calculateNetAmount(order.getItems()); + } // get all items of the order CqnSelect selItems = Select.from(OrderItems_.class).where(i -> i.parent().ID().eq(order.getId())); @@ -269,7 +273,7 @@ Finally, add a method to the `OrdersService` Java class to calculate the `total` 2. Also add the following import statements to the top of the `OrdersService` Java class: ```java - import sap.capire.bookstore.OrderItems_; + import cds.gen.sap.capire.bookstore.OrderItems_; ``` Let's break the code down: diff --git a/exercises-java/exercise5/README.md b/exercises-java/exercise5/README.md index 1b6c8ae..f6d1ee7 100644 --- a/exercises-java/exercise5/README.md +++ b/exercises-java/exercise5/README.md @@ -2,6 +2,20 @@ In the last exercise you have added custom coding to your bookstore application. In this exercises you will make the application ready to be deployed to the cloud. In order to make our application cloud-ready, we'll switch to SAP HANA as our database. +## Creating a CloudFoundry Trial account + +The following two exercises require access to an SAP Cloud Platform account with a Subaccount for the Cloud Foundry environment. +The subaccount needs to have the following entitlements assigned to it: + +1. Service: 'SAP HANA Schemas & HDI Containers' or Service 'SAP HANA Schemas & HDI Containers (Trial)' + Plan: 'hdi-shared' + Quota: 1 Unit +2. Service: 'Application Runtime' + Plan: 'MEMORY' + Quota: 1 GiB + +You can use a free trial account for this. Please follow [this tutorial](https://developers.sap.com/tutorials/hcp-create-trial-account.html) to create a free trial account. + ## Initializing the SAP HANA database First you need to create and initialize a SAP HANA database schema in the cloud. As you will deploy your application to SAP Cloud Platform Cloud Foundry Environment, you will also create the SAP HANA service there. @@ -12,9 +26,9 @@ Login to the Cloud Foundry Environment using the cf CLI: 2. Run `cf api ` in the terminal. - The `` endpoint will be provided to you by your instructor. + The `` endpoint can be obtained from the Overview page of your Subaccount in Cloud Cockpit. -3. Run `cf login` and authenticate using the login credentials provided to you by your instructor. +3. Run `cf login` and authenticate using your login credentials. Initializing the SAP HANA database is now as simple as running these commands in the terminal: @@ -22,9 +36,7 @@ Initializing the SAP HANA database is now as simple as running these commands in 2. Run `npm install --save-dev --save-exact @sap/hdi-deploy@3.7.0` -3. Run `cds deploy --to hana:bookstore-hana-` - - Replace `` with the number given to you by your instructor +3. Run `cds deploy --to hana:bookstore-hana` With this command, you've created an SAP HANA service instance. In addition, the command initialized the database schemas inside the SAP HANA HDI container. @@ -51,11 +63,11 @@ The described features are available as a plugin in CAP Java. Therefore, we'll a 3. Make sure that you are in the root of the bookstore project: `cd ~/projects/bookstore` -4. Let's test the SAP HANA connectivity. Start your application by running `mvn spring-boot:run -Dspring.profiles.active=cloud` +4. Let's test the SAP HANA connectivity. Start your application by running `mvn spring-boot:run -Dspring-boot.run.profiles=cloud` - > Note: The Java system property `-Dspring.profiles.active=cloud` ensures that the default configuration using SQLite as the database, which is still defined in the `application.yaml`, does not get activated. + > Note: The Java system property `-Dspring-boot.run.profiles=cloud` ensures that the default configuration using SQLite as the database, which is still defined in the `application.yaml`, does not get activated. -5. You can observe the log lines `Loaded default-env.json from directory '/home/user/projects/bookstore'` and `Registered 'DataSource' bean definition for connected service 'bookstore-hana-'` which indicate that the SAP HANA configuration was picked up. +5. You can observe the log lines `Loaded default-env.json from directory '/home/user/projects/bookstore'` and `Registered primary 'DataSource' bean definition for connected service 'bookstore-hana'` which indicate that the SAP HANA configuration was picked up. 6. Try the following example request, which creates an order together with it's items through a deep insert: diff --git a/exercises-java/exercise6/README.md b/exercises-java/exercise6/README.md index 5c45ac8..f8006fe 100644 --- a/exercises-java/exercise6/README.md +++ b/exercises-java/exercise6/README.md @@ -8,23 +8,23 @@ When deploying an application to Cloud Foundry, you can use a manifest to descri 1. Go to the `~/projects/bookstore` folder and create a new file called `manifest.yml`. -2. Add the following code to the newly created file. Remember to replace `` with the number given to you by your instructor. +2. Add the following code to the newly created file. ```yaml --- applications: - - name: bookstore- + - name: bookstore path: srv/target/bookstore-1.0-SNAPSHOT.jar random-route: true services: - - bookstore-hana- + - bookstore-hana ``` The manifest describes the name of the application and the path where the application archive can be found. Spring Boot applications can be deployed from a single JAR archive, which is what you are making use of here. The route of the application, meaning the HTTP endpoint where it will be available, will be randomized to prevent clashes with other application routes. -The name of SAP HANA service instance you created in [Exercise 5](../exercise5/README.md) is used here under the services section (`bookstore-hana-`) +The name of SAP HANA service instance you created in [Exercise 5](../exercise5/README.md) is used here under the services section (`bookstore-hana`) ## Auto configuration of the SAP HANA database connection @@ -45,7 +45,7 @@ The described feature is again available as a further plugin in CAP Java. Theref Even with the Cloud Foundry feature enabled, CAP Java ensures that your application can run still run locally with SQLite or SAP HANA auto-configured based on default-env.json. It provides a seamless developer experience in all environments. -In [Exercise 5](../exercise5/README.md) you added the additional Java system property `-Dspring.profiles.active=cloud` to your application to ensure that the default SQLite configuration from the `application.yaml` does not take effect. When deploying the application to Cloud Foundry this is done automatically for you by the Cloud Foundry Java Buildpack. +In [Exercise 5](../exercise5/README.md) you added the additional Java system property `-Dspring-boot.run.profiles=cloud` to your application to ensure that the default SQLite configuration from the `application.yaml` does not take effect. When deploying the application to Cloud Foundry this is done automatically for you by the Cloud Foundry Java Buildpack. ## Pushing the application @@ -59,9 +59,7 @@ You are now ready to push your application to the cloud by running the following The manifest will be automatically picked up. -4. Run `cf app bookstore-` to retrieve the application URL, which can be found under `routes`. - - Replace `` with the number given to you by your instructor. +4. Run `cf app bookstore` to retrieve the application URL, which can be found under `routes`. 5. Open this URL to test your application running in the cloud.