Compare commits
15 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7333001683 | ||
|
|
d6e051fcb8 | ||
|
|
059df03cc1 | ||
|
|
669c5249ff | ||
|
|
1a3fb3ffab | ||
|
|
f2c458db7a | ||
|
|
5c7a3e6860 | ||
|
|
ece590be9c | ||
|
|
19ba5c2d9c | ||
|
|
3e6a23e43d | ||
|
|
2857ab7fa0 | ||
|
|
ecd2152be5 | ||
|
|
ce3094a30d | ||
|
|
8f0f032e6c | ||
|
|
7c52a3b4f2 |
24
Jenkinsfile
vendored
Normal file
24
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file bootstraps the codified Continuous Delivery pipeline for extensions of SAP solutions, such as SAP S/4HANA.
|
||||||
|
* The pipeline helps you to deliver software changes quickly and in a reliable manner.
|
||||||
|
* A suitable Jenkins instance is required to run the pipeline.
|
||||||
|
* The Jenkins can easily be bootstraped using the life-cycle script located inside the 'cx-server' directory.
|
||||||
|
*
|
||||||
|
* More information on getting started with Continuous Delivery can be found in the following places:
|
||||||
|
* - GitHub repository: https://github.com/SAP/cloud-s4-sdk-pipeline
|
||||||
|
* - Blog Post: https://blogs.sap.com/2017/09/20/continuous-integration-and-delivery
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set pipelineVersion to a fixed released version (e.g. "v15") when running in a productive environment.
|
||||||
|
* To find out about available versions and release notes, visit: https://github.com/SAP/cloud-s4-sdk-pipeline/releases
|
||||||
|
*/
|
||||||
|
String pipelineVersion = "v28"
|
||||||
|
|
||||||
|
node {
|
||||||
|
deleteDir()
|
||||||
|
sh "git clone --depth 1 https://github.com/SAP/cloud-s4-sdk-pipeline.git -b ${pipelineVersion} pipelines"
|
||||||
|
load './pipelines/s4sdk-pipeline.groovy'
|
||||||
|
}
|
||||||
29
README.md
29
README.md
@@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
Find here the samples for the openSAP course [Building Applications with the SAP Cloud Application Programming Model](https://open.sap.com/courses/cp7).
|
Find here the samples for the openSAP course [Building Applications with the SAP Cloud Application Programming Model](https://open.sap.com/courses/cp7).
|
||||||
|
|
||||||
|
## Notes on the Demo in Week 4 Unit 4
|
||||||
|
To add all pipeline specific file to your project, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cds add pipeline
|
||||||
|
```
|
||||||
|
|
||||||
|
Details on how to start your Jenkins in your own environment can be found in the [Operations Guide](https://github.com/SAP/devops-docker-cx-server/blob/master/docs/operations/cx-server-operations-guide.md).
|
||||||
|
|
||||||
|
Please note that other than shown in the video Jenkins now is secured by default with an admin user and password.
|
||||||
|
After you have started Jenkins with the command `cx-server start`, you can get the initial password by running `./cx-server initial-credentials`.
|
||||||
|
|
||||||
|
The pipeline documentation can be found [here](https://sap.github.io/jenkins-library/pipelines/cloud-sdk/introduction/).
|
||||||
|
|
||||||
## Get Access to SAP Business Application Studio
|
## Get Access to SAP Business Application Studio
|
||||||
The recommended environment for the course is SAP Business Application Studio. Watch [unit 2 of week 1](https://open.sap.com/courses/cp7/items/51pzQUzbXHr2kdbOmVs6jI) for how to get access.
|
The recommended environment for the course is SAP Business Application Studio. Watch [unit 2 of week 1](https://open.sap.com/courses/cp7/items/51pzQUzbXHr2kdbOmVs6jI) for how to get access.
|
||||||
|
|
||||||
@@ -11,8 +25,8 @@ In SAP Business Application Studio, open a terminal.
|
|||||||
Then clone the repo with this specific branch:
|
Then clone the repo with this specific branch:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week2-unit3
|
git clone https://github.com/sap-samples/cloud-cap-samples -b openSAP-week4-unit4
|
||||||
cd projects/cloud-cap-samples
|
cd cloud-cap-samples
|
||||||
```
|
```
|
||||||
|
|
||||||
In the `cloud-cap-samples` folder run:
|
In the `cloud-cap-samples` folder run:
|
||||||
@@ -20,17 +34,6 @@ In the `cloud-cap-samples` folder run:
|
|||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run
|
|
||||||
|
|
||||||
Now you're ready to run the samples, for example:
|
|
||||||
```sh
|
|
||||||
cd packages/bookshop
|
|
||||||
cds watch
|
|
||||||
```
|
|
||||||
|
|
||||||
After that, watch out for the little popup in the lower right corner of SAP Business Application Studio that asks you to open the application in your browser.
|
|
||||||
|
|
||||||
|
|
||||||
## Get Support
|
## Get Support
|
||||||
|
|
||||||
Check out the cap docs at https://cap.cloud.sap. <br>
|
Check out the cap docs at https://cap.cloud.sap. <br>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ entity Books : managed {
|
|||||||
currency : Currency;
|
currency : Currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@cds.autoexpose
|
|
||||||
entity Authors : managed {
|
entity Authors : managed {
|
||||||
key ID : Integer;
|
key ID : Integer;
|
||||||
name : String(111);
|
name : String(111);
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"packages":["packages/*"],"version":"1.0.0"}
|
|
||||||
64
mta.yaml
Normal file
64
mta.yaml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
####### Generated mta.yaml based on template version 0.2.0
|
||||||
|
####### appName = capire-bookshop
|
||||||
|
####### language=nodejs; multiTenant=
|
||||||
|
####### approuter=
|
||||||
|
|
||||||
|
_schema-version: '3.1'
|
||||||
|
ID: sap.capire-bookshop
|
||||||
|
version: 1.0.0
|
||||||
|
description: "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages."
|
||||||
|
|
||||||
|
build-parameters:
|
||||||
|
before-all:
|
||||||
|
- builder: custom
|
||||||
|
commands:
|
||||||
|
- npm install
|
||||||
|
- cds build/all
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
enable-parallel-deployments: true
|
||||||
|
|
||||||
|
modules:
|
||||||
|
############## SERVER MODULE ##########################
|
||||||
|
- name: capire-bookshop-srv
|
||||||
|
type: nodejs
|
||||||
|
path: gen/srv
|
||||||
|
properties:
|
||||||
|
EXIT: 1 # required by deploy.js task to terminate
|
||||||
|
|
||||||
|
|
||||||
|
requires:
|
||||||
|
#### Resources extracted from CAP configuration ####
|
||||||
|
- name: capire-bookshop-db
|
||||||
|
|
||||||
|
provides:
|
||||||
|
- name: srv-binding # required by consumers of CAP services (e.g. approuter)
|
||||||
|
properties:
|
||||||
|
srv-url: ${default-url}
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
############## SIDECAR MODULE #########################
|
||||||
|
- name: db
|
||||||
|
|
||||||
|
type: hdb
|
||||||
|
path: gen/db
|
||||||
|
parameters:
|
||||||
|
app-name: capire-bookshop-db
|
||||||
|
requires:
|
||||||
|
#### Hana and xsuaa resources extracted from CAP configuration ####
|
||||||
|
- name: capire-bookshop-db
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
|
############## RESOURCES ##################################
|
||||||
|
resources:
|
||||||
|
##### Services extracted from CAP configuration ####
|
||||||
|
##### 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
|
||||||
|
- name: capire-bookshop-db
|
||||||
|
type: com.sap.xs.hdi-container
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
properties:
|
||||||
|
hdi-service-name: ${service-name} # required for Java case
|
||||||
|
############################################################
|
||||||
28
package-lock.json
generated
28
package-lock.json
generated
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@sap/capire-samples",
|
"name": "@sap/capire-bookshop",
|
||||||
"requires": true,
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": {
|
"@sap/cds": {
|
||||||
"version": "3.33.1",
|
"version": "3.33.1",
|
||||||
@@ -192,6 +193,29 @@
|
|||||||
"winston": "^3.2.1"
|
"winston": "^3.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@sap/hana-client": {
|
||||||
|
"version": "2.4.191",
|
||||||
|
"resolved": "https://npm.sap.com/@sap/hana-client/-/hana-client-2.4.191.tgz",
|
||||||
|
"integrity": "sha512-OkdZPJenVuoFbkMBcgBN0nd75xVEi4Szf5NdeUyCQfpE5UecuPrn1rJj4sW9QJdsPammB+fY1ihF7ErgDe4gFg==",
|
||||||
|
"requires": {
|
||||||
|
"debug": "3.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"debug": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"@sap/odata-server": {
|
"@sap/odata-server": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://npm.sap.com/@sap/odata-server/-/odata-server-1.6.0.tgz",
|
"resolved": "https://npm.sap.com/@sap/odata-server/-/odata-server-1.6.0.tgz",
|
||||||
|
|||||||
38
package.json
38
package.json
@@ -1,25 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "@sap/capire-samples",
|
"name": "@sap/capire-bookshop",
|
||||||
"description": "The umbrella project for all samples to easily setup for local development and tests.",
|
"version": "1.0.0",
|
||||||
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||||
"author": "daniel.hutzel@sap.com",
|
"license": "SAP SAMPLE CODE LICENSE",
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
|
||||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
|
||||||
"cleanup": "lerna clean -y && rm -fr node_modules",
|
|
||||||
"bookshop": "cds watch packages/bookshop"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^3",
|
"@sap/cds": "^3",
|
||||||
"express": "^4"
|
"express": "^4",
|
||||||
|
"@sap/hana-client": "^2.4.182"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"sqlite3": "*"
|
"sqlite3": "^4.1.1"
|
||||||
},
|
},
|
||||||
"--add-these-to-devDependencies-for-tests": {
|
"scripts": {
|
||||||
"@types/jest": "*",
|
"start": "cds run",
|
||||||
"jest": "*"
|
"watch": "cds watch"
|
||||||
},
|
},
|
||||||
"license": "SAP SAMPLE CODE LICENSE"
|
"cds": {
|
||||||
|
"requires": {
|
||||||
|
"db": {
|
||||||
|
"kind": "hana",
|
||||||
|
"model": [
|
||||||
|
"db",
|
||||||
|
"srv"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@sap/capire-bookshop",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
|
||||||
"license": "SAP SAMPLE CODE LICENSE",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/cds": "^3",
|
|
||||||
"express": "^4"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "cds run --in-memory?",
|
|
||||||
"watch": "cds watch"
|
|
||||||
},
|
|
||||||
"cds": {
|
|
||||||
"requires": {
|
|
||||||
"db": {
|
|
||||||
"kind": "sql"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
### Browse Books
|
|
||||||
GET http://localhost:4004/browse/Books
|
|
||||||
|
|
||||||
### Browse Books with expanded Authors
|
|
||||||
GET http://localhost:4004/browse/Books?$expand=author
|
|
||||||
|
|
||||||
### Try to insert into Books
|
|
||||||
POST http://localhost:4004/browse/Books
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"title": "Anna Karenina",
|
|
||||||
"stock": 10
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
### List all Orders - deep read
|
|
||||||
GET http://localhost:4004/admin/Orders?
|
|
||||||
&$expand=Items
|
|
||||||
|
|
||||||
### Submit Orders - deep insert
|
|
||||||
POST http://localhost:4004/browse/Orders
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{ "OrderNo":"1234", "Items":[
|
|
||||||
{ "book_ID":201, "amount":5 },
|
|
||||||
{ "book_ID":207, "amount":3 }
|
|
||||||
]}
|
|
||||||
|
|
||||||
### Try to get the Orders
|
|
||||||
GET http://localhost:4004/browse/Orders
|
|
||||||
47
pipeline_config.yml
Normal file
47
pipeline_config.yml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
###
|
||||||
|
# This file configures the SAP Cloud SDK Continuous Delivery pipeline of your project.
|
||||||
|
# For a reference of the configuration concept and available options, please have a look into its documentation.
|
||||||
|
#
|
||||||
|
# The documentation for the most recent pipeline version can always be found at:
|
||||||
|
# https://github.com/SAP/cloud-s4-sdk-pipeline/blob/master/configuration.md
|
||||||
|
# If you are using a fixed version of the pipeline, please make sure to view the corresponding version from the tag
|
||||||
|
# list of GitHub (e.g. "v15" when you configured pipelineVersion = "v15" in the Jenkinsfile).
|
||||||
|
#
|
||||||
|
# For general information on how to get started with Continuous Delivery, visit:
|
||||||
|
# https://blogs.sap.com/2017/09/20/continuous-integration-and-delivery
|
||||||
|
#
|
||||||
|
# We aim to keep the pipeline configuration as stable as possible. However, major changes might also imply breaking
|
||||||
|
# changes in the configuration. Before doing an update, please check the the release notes of all intermediate releases
|
||||||
|
# and adapt this file if necessary.
|
||||||
|
#
|
||||||
|
# This is a YAML-file. YAML is a indentation-sensitive file format. Please make sure to properly indent changes to it.
|
||||||
|
###
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### General project setup
|
||||||
|
general:
|
||||||
|
productiveBranch: 'openSAP-week4-unit4'
|
||||||
|
|
||||||
|
### Step-specific configuration
|
||||||
|
steps:
|
||||||
|
|
||||||
|
|
||||||
|
### Stage-specific configuration
|
||||||
|
stages:
|
||||||
|
|
||||||
|
# integrationTests:
|
||||||
|
# credentials:
|
||||||
|
# - alias: 'mySystemAlias'
|
||||||
|
# credentialId: 'mySystemCredentialsId'
|
||||||
|
|
||||||
|
# s4SdkQualityChecks:
|
||||||
|
# nonErpDestinations:
|
||||||
|
# - 'myCustomDestination'
|
||||||
|
|
||||||
|
# productionDeployment:
|
||||||
|
# cfTargets:
|
||||||
|
# - org: 'myOrg'
|
||||||
|
# space: 'mySpace'
|
||||||
|
# apiEndpoint: 'https://api.cf.eu10.hana.ondemand.com'
|
||||||
|
# credentialsId: 'cf-deploy-sap'
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using { sap.capire.bookshop as my } from '../db/schema';
|
using { sap.capire.bookshop as my } from '../db/schema';
|
||||||
|
|
||||||
service AdminService @(_requires:'authenticated-user',path:'/admin') {
|
service AdminService @(_requires:'authenticated-user') {
|
||||||
entity Books as projection on my.Books;
|
entity Books as projection on my.Books;
|
||||||
entity Authors as projection on my.Authors;
|
entity Authors as projection on my.Authors;
|
||||||
entity Orders as select from my.Orders;
|
entity Orders as select from my.Orders;
|
||||||
@@ -10,7 +10,7 @@ service AdminService @(_requires:'authenticated-user',path:'/admin') {
|
|||||||
annotate AdminService.Orders with @odata.draft.enabled;
|
annotate AdminService.Orders with @odata.draft.enabled;
|
||||||
// annotate AdminService.Books with @odata.draft.enabled;
|
// annotate AdminService.Books with @odata.draft.enabled;
|
||||||
|
|
||||||
// Temporary workaround -> cap/issues#3121
|
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121
|
||||||
extend service AdminService with {
|
extend service AdminService with {
|
||||||
entity OrderItems as select from my.OrderItems;
|
entity OrderItems as select from my.OrderItems;
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,9 @@ using { sap.capire.bookshop as my } from '../db/schema';
|
|||||||
@path:'/browse'
|
@path:'/browse'
|
||||||
service CatalogService {
|
service CatalogService {
|
||||||
|
|
||||||
@readonly entity Books as SELECT from my.Books { * } excluding { createdBy, modifiedBy };
|
@readonly entity Books as SELECT from my.Books {*,
|
||||||
|
author.name as author
|
||||||
|
} excluding { createdBy, modifiedBy };
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
@insertonly entity Orders as projection on my.Orders;
|
@insertonly entity Orders as projection on my.Orders;
|
||||||
18
tests/bookshop.http
Normal file
18
tests/bookshop.http
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
### Service Document
|
||||||
|
GET http://localhost:4004/browse
|
||||||
|
|
||||||
|
### Service $metadata document
|
||||||
|
GET http://localhost:4004/browse/$metadata
|
||||||
|
|
||||||
|
### Browsing Books
|
||||||
|
GET http://localhost:4004/browse/Books?
|
||||||
|
# &$select=title,author
|
||||||
|
# &$expand=currency
|
||||||
|
# &sap-language=de
|
||||||
|
|
||||||
|
### Browsing Authors
|
||||||
|
GET http://localhost:4004/admin/Authors?
|
||||||
|
# &$select=name,dateOfBirth,placeOfBirth
|
||||||
|
# &$expand=books($select=title;$expand=currency)
|
||||||
|
# &$filter=ID eq 101
|
||||||
|
# &sap-language=de
|
||||||
18
tests/orders.http
Normal file
18
tests/orders.http
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
### List Books with their current stocks
|
||||||
|
GET http://localhost:4004/admin/Books?$select=ID,stock
|
||||||
|
|
||||||
|
### List all Orders
|
||||||
|
GET http://localhost:4004/admin/Orders?
|
||||||
|
&$expand=Items
|
||||||
|
|
||||||
|
### Submit Orders
|
||||||
|
POST http://localhost:4004/browse/Orders
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{ "OrderNo":"2019-09...", "Items":[
|
||||||
|
{ "book_ID":201, "amount":5 },
|
||||||
|
{ "book_ID":207, "amount":3 }
|
||||||
|
]}
|
||||||
|
|
||||||
|
# Sending this three times should result in a 409: 5 exceeds stock for book #201
|
||||||
Reference in New Issue
Block a user