Compare commits
39 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99861ca588 | ||
|
|
b5fc3fe4fa | ||
|
|
b371e10fdf | ||
|
|
9d31d66c78 | ||
|
|
b34b1b0a17 | ||
|
|
7d39278e79 | ||
|
|
8395c3fbfc | ||
|
|
6e5c23bc22 | ||
|
|
57803e8f2b | ||
|
|
7bbd4ffdb3 | ||
|
|
ece7aa99cc | ||
|
|
e8156ce08a | ||
|
|
2bf65fb50f | ||
|
|
23cc571d8a | ||
|
|
50b1f1bb15 | ||
|
|
3b818b18c1 | ||
|
|
2d7630449c | ||
|
|
f4f41aca52 | ||
|
|
a0d63890ac | ||
|
|
c2ef8c9a69 | ||
|
|
44cf281360 | ||
|
|
cfc1ebc881 | ||
|
|
fef327f344 | ||
|
|
9932d02d57 | ||
|
|
cad3a32c78 | ||
|
|
05a5a68463 | ||
|
|
73cf655715 | ||
|
|
3c094c201b | ||
|
|
a458c7bb0d | ||
|
|
e0e330c43a | ||
|
|
6d0194acc0 | ||
|
|
db75a99808 | ||
|
|
a04755efed | ||
|
|
ba72d7f478 | ||
|
|
cd808c76dd | ||
|
|
630bb2b19c | ||
|
|
f9a7aa59de | ||
|
|
9205e0893a | ||
|
|
7137bf227e |
2
.npmrc
2
.npmrc
@@ -1 +1 @@
|
|||||||
@sap:registry=https://npm.sap.com
|
registry=https://registry.npmjs.org
|
||||||
39
.vscode/launch.json
vendored
39
.vscode/launch.json
vendored
@@ -5,18 +5,45 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "bookshop", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
"name": "bookshop",
|
||||||
"args": [ "--", "cds", "run", "--in-memory" ],
|
"request": "launch",
|
||||||
|
"type": "node",
|
||||||
|
"runtimeExecutable": "npx",
|
||||||
|
"runtimeArgs": [
|
||||||
|
"-n"
|
||||||
|
],
|
||||||
|
"args": [
|
||||||
|
"--",
|
||||||
|
"cds",
|
||||||
|
"run",
|
||||||
|
"--in-memory"
|
||||||
|
],
|
||||||
"cwd": "${workspaceFolder}/packages/bookshop",
|
"cwd": "${workspaceFolder}/packages/bookshop",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"skipFiles": ["<node_internals>/**"]
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cds run ...", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
"name": "cds run ...",
|
||||||
"args": [ "--", "cds", "run", "--with-mocks", "--in-memory?" ],
|
"request": "launch",
|
||||||
|
"type": "node",
|
||||||
|
"runtimeExecutable": "npx",
|
||||||
|
"runtimeArgs": [
|
||||||
|
"-n"
|
||||||
|
],
|
||||||
|
"args": [
|
||||||
|
"--",
|
||||||
|
"cds",
|
||||||
|
"run",
|
||||||
|
"--with-mocks",
|
||||||
|
"--in-memory?"
|
||||||
|
],
|
||||||
"cwd": "${workspaceFolder}/packages/${input:service}",
|
"cwd": "${workspaceFolder}/packages/${input:service}",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"skipFiles": ["<node_internals>/**"]
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
|
|||||||
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@@ -1,24 +0,0 @@
|
|||||||
#!/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'
|
|
||||||
}
|
|
||||||
105
README.md
105
README.md
@@ -2,20 +2,6 @@
|
|||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@@ -25,8 +11,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 -b openSAP-week4-unit4
|
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week3-unit5
|
||||||
cd cloud-cap-samples
|
cd projects/cloud-cap-samples
|
||||||
```
|
```
|
||||||
|
|
||||||
In the `cloud-cap-samples` folder run:
|
In the `cloud-cap-samples` folder run:
|
||||||
@@ -34,6 +20,93 @@ 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 deploy
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Hints
|
||||||
|
- If your demo user logon window does not show up: clear the browsers login data
|
||||||
|
- If your port is still in use run in your terminal:
|
||||||
|
```
|
||||||
|
> pkill node //kill running node proceses
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy to Cloud Foundry
|
||||||
|
|
||||||
|
Clean-up the CF space in your trial account if you already used it before. Make sure that there are no services or applications deployed.
|
||||||
|
|
||||||
|
Generation of the XSUAA service configuration file xs-security.json:
|
||||||
|
```sh
|
||||||
|
cds compile srv/ --to xsuaa > xs-security.json
|
||||||
|
```
|
||||||
|
|
||||||
|
In this unit we use [MTA](https://sap.github.io/cloud-mta-build-tool/) to do the deployment to CF
|
||||||
|
```sh
|
||||||
|
npm install -g mbt
|
||||||
|
```
|
||||||
|
You can generate the MTA.yaml from CDS and do manual modifications or simply use the already generated and adapted mta.yaml in the branch and directly generate the .mtar file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### BEGIN OPTIONAL PART
|
||||||
|
|
||||||
|
If you want to generate the MTA.YAML yourself please do the following:
|
||||||
|
|
||||||
|
- Generate the mta.yaml with the HANA dependency
|
||||||
|
```sh
|
||||||
|
cds add hana --force
|
||||||
|
cds add mta
|
||||||
|
```
|
||||||
|
|
||||||
|
- Add the path to the generated xs-security.json in the MTA.YAML
|
||||||
|
```
|
||||||
|
parameters:
|
||||||
|
path: ./xs-security.json
|
||||||
|
service:xsuaa
|
||||||
|
service-plan: application
|
||||||
|
....
|
||||||
|
```
|
||||||
|
- Add the application block in the MTA.YAML
|
||||||
|
```
|
||||||
|
############## APP #########################
|
||||||
|
- name: capire-bookshop-app
|
||||||
|
type: nodejs
|
||||||
|
path: gen/app
|
||||||
|
parameters:
|
||||||
|
memory: 256M
|
||||||
|
build-parameters:
|
||||||
|
requires:
|
||||||
|
- name: capire-bookshop-srv
|
||||||
|
requires:
|
||||||
|
- name: capire-bookshop-uaa
|
||||||
|
- name: srv-binding
|
||||||
|
group: destinations
|
||||||
|
properties:
|
||||||
|
forwardAuthToken: true
|
||||||
|
name: srv-binding
|
||||||
|
url: ~{srv-url}
|
||||||
|
```
|
||||||
|
- Make sure to use service hanatrial instead of hana in the MTA.YAML
|
||||||
|
```
|
||||||
|
parameters:
|
||||||
|
service: hanatrial
|
||||||
|
```
|
||||||
|
#### END OPTIONAL PART
|
||||||
|
|
||||||
|
Generate the .mtar file for the deployment and deploy to cloud foundry:
|
||||||
|
```sh
|
||||||
|
mbt build -t ./
|
||||||
|
cf login -a https://api.cf.eu10.hana.ondemand.com
|
||||||
|
cf deploy sap.capire-bookshop_1.0.0.mtar
|
||||||
|
```
|
||||||
|
|
||||||
## 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>
|
||||||
|
|||||||
12
db/package.json
Normal file
12
db/package.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "deploy",
|
||||||
|
"dependencies": {
|
||||||
|
"@sap/hdi-deploy": "^3.8.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
lerna.json
Normal file
1
lerna.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"packages":["packages/*"],"version":"1.0.0"}
|
||||||
906
package-lock.json
generated
906
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@@ -1,29 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "@sap/capire-bookshop",
|
"name": "@sap/capire-samples",
|
||||||
"version": "1.0.0",
|
"description": "The umbrella project for all samples to easily setup for local development and tests.",
|
||||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
||||||
"license": "SAP SAMPLE CODE LICENSE",
|
"author": "daniel.hutzel@sap.com",
|
||||||
|
"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": "^4",
|
||||||
"express": "^4",
|
"express": "^4"
|
||||||
"@sap/hana-client": "^2.4.182"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"sqlite3": "^4.1.1"
|
"sqlite3": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"--add-these-to-devDependencies-for-tests": {
|
||||||
"start": "cds run",
|
"@types/jest": "*",
|
||||||
"watch": "cds watch"
|
"jest": "*"
|
||||||
},
|
},
|
||||||
"cds": {
|
"license": "SAP SAMPLE CODE LICENSE"
|
||||||
"requires": {
|
|
||||||
"db": {
|
|
||||||
"kind": "hana",
|
|
||||||
"model": [
|
|
||||||
"db",
|
|
||||||
"srv"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
67
packages/bookshop/.cdsrc.json
Normal file
67
packages/bookshop/.cdsrc.json
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
{
|
||||||
|
"odata": {
|
||||||
|
"version": "v4"
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"target": "gen",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"src": "db",
|
||||||
|
"for": "hana",
|
||||||
|
"options": {
|
||||||
|
"model": [
|
||||||
|
"db",
|
||||||
|
"srv"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "srv",
|
||||||
|
"for": "node-cf",
|
||||||
|
"options": {
|
||||||
|
"model": [
|
||||||
|
"db",
|
||||||
|
"srv",
|
||||||
|
"app"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "app",
|
||||||
|
"for": "fiori",
|
||||||
|
"options": {
|
||||||
|
"model": [
|
||||||
|
"app"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"auth": {
|
||||||
|
"passport": {
|
||||||
|
"strategy": "mock",
|
||||||
|
"users": {
|
||||||
|
"alice": {
|
||||||
|
"password": "123",
|
||||||
|
"ID": "alice",
|
||||||
|
"roles": [
|
||||||
|
"admin",
|
||||||
|
"authenticated-user"
|
||||||
|
],
|
||||||
|
"xs.user.attributes": {
|
||||||
|
"currency": [
|
||||||
|
"USD"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bob": {
|
||||||
|
"password": "123",
|
||||||
|
"ID": "bob",
|
||||||
|
"roles": [
|
||||||
|
"authenticated-user"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
packages/bookshop/.vscode/launch.json
vendored
Normal file
29
packages/bookshop/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Run bookshop",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node",
|
||||||
|
"cwd": "/home/user/projects/cloud-cap-samples/packages/bookshop",
|
||||||
|
"runtimeExecutable": "npx",
|
||||||
|
"runtimeArgs": [
|
||||||
|
"-n"
|
||||||
|
],
|
||||||
|
"args": [
|
||||||
|
"--",
|
||||||
|
"cds",
|
||||||
|
"run",
|
||||||
|
"--in-memory?"
|
||||||
|
],
|
||||||
|
"console": "internalConsole",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"run.config": "{\"handlerId\":\"cap_run_config_handler_id\",\"runnableId\":\"/home/user/projects/cloud-cap-samples/packages/bookshop\"}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
packages/bookshop/app/package.json
Normal file
11
packages/bookshop/app/package.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "capire-bookshop-approuter",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"dependencies": {
|
||||||
|
"@sap/approuter": "^8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "node node_modules/@sap/approuter/approuter.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
22
packages/bookshop/app/xs-app.json
Normal file
22
packages/bookshop/app/xs-app.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"welcomeFile": "/fiori.html",
|
||||||
|
"authenticationMethod": "route",
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"source": "^/.*(html|js)$",
|
||||||
|
"localDir": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "^/sapui5/.*",
|
||||||
|
"localDir": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "^/.*/webapp/.*",
|
||||||
|
"localDir": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/",
|
||||||
|
"destination": "srv-binding"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
12
packages/bookshop/db/package.json
Normal file
12
packages/bookshop/db/package.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "deploy",
|
||||||
|
"dependencies": {
|
||||||
|
"@sap/hdi-deploy": "^3.8.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^12"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
136
packages/bookshop/db/src/.hdiconfig
Normal file
136
packages/bookshop/db/src/.hdiconfig
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"file_suffixes": {
|
||||||
|
"csv": {
|
||||||
|
"plugin_name": "com.sap.hana.di.tabledata.source"
|
||||||
|
},
|
||||||
|
"hdbafllangprocedure": {
|
||||||
|
"plugin_name": "com.sap.hana.di.afllangprocedure"
|
||||||
|
},
|
||||||
|
"hdbanalyticprivilege": {
|
||||||
|
"plugin_name": "com.sap.hana.di.analyticprivilege"
|
||||||
|
},
|
||||||
|
"hdbcalculationview": {
|
||||||
|
"plugin_name": "com.sap.hana.di.calculationview"
|
||||||
|
},
|
||||||
|
"hdbcollection": {
|
||||||
|
"plugin_name": "com.sap.hana.di.collection"
|
||||||
|
},
|
||||||
|
"hdbconstraint": {
|
||||||
|
"plugin_name": "com.sap.hana.di.constraint"
|
||||||
|
},
|
||||||
|
"hdbdropcreatetable": {
|
||||||
|
"plugin_name": "com.sap.hana.di.dropcreatetable"
|
||||||
|
},
|
||||||
|
"hdbflowgraph": {
|
||||||
|
"plugin_name": "com.sap.hana.di.flowgraph"
|
||||||
|
},
|
||||||
|
"hdbfunction": {
|
||||||
|
"plugin_name": "com.sap.hana.di.function"
|
||||||
|
},
|
||||||
|
"hdbgraphworkspace": {
|
||||||
|
"plugin_name": "com.sap.hana.di.graphworkspace"
|
||||||
|
},
|
||||||
|
"hdbhadoopmrjob": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
|
||||||
|
},
|
||||||
|
"hdbindex": {
|
||||||
|
"plugin_name": "com.sap.hana.di.index"
|
||||||
|
},
|
||||||
|
"hdblibrary": {
|
||||||
|
"plugin_name": "com.sap.hana.di.library"
|
||||||
|
},
|
||||||
|
"hdbmigrationtable": {
|
||||||
|
"plugin_name": "com.sap.hana.di.table.migration"
|
||||||
|
},
|
||||||
|
"hdbprocedure": {
|
||||||
|
"plugin_name": "com.sap.hana.di.procedure"
|
||||||
|
},
|
||||||
|
"hdbprojectionview": {
|
||||||
|
"plugin_name": "com.sap.hana.di.projectionview"
|
||||||
|
},
|
||||||
|
"hdbprojectionviewconfig": {
|
||||||
|
"plugin_name": "com.sap.hana.di.projectionview.config"
|
||||||
|
},
|
||||||
|
"hdbreptask": {
|
||||||
|
"plugin_name": "com.sap.hana.di.reptask"
|
||||||
|
},
|
||||||
|
"hdbresultcache": {
|
||||||
|
"plugin_name": "com.sap.hana.di.resultcache"
|
||||||
|
},
|
||||||
|
"hdbrole": {
|
||||||
|
"plugin_name": "com.sap.hana.di.role"
|
||||||
|
},
|
||||||
|
"hdbroleconfig": {
|
||||||
|
"plugin_name": "com.sap.hana.di.role.config"
|
||||||
|
},
|
||||||
|
"hdbsearchruleset": {
|
||||||
|
"plugin_name": "com.sap.hana.di.searchruleset"
|
||||||
|
},
|
||||||
|
"hdbsequence": {
|
||||||
|
"plugin_name": "com.sap.hana.di.sequence"
|
||||||
|
},
|
||||||
|
"hdbstatistics": {
|
||||||
|
"plugin_name": "com.sap.hana.di.statistics"
|
||||||
|
},
|
||||||
|
"hdbstructuredprivilege": {
|
||||||
|
"plugin_name": "com.sap.hana.di.structuredprivilege"
|
||||||
|
},
|
||||||
|
"hdbsynonym": {
|
||||||
|
"plugin_name": "com.sap.hana.di.synonym"
|
||||||
|
},
|
||||||
|
"hdbsynonymconfig": {
|
||||||
|
"plugin_name": "com.sap.hana.di.synonym.config"
|
||||||
|
},
|
||||||
|
"hdbsystemversioning": {
|
||||||
|
"plugin_name": "com.sap.hana.di.systemversioning"
|
||||||
|
},
|
||||||
|
"hdbtable": {
|
||||||
|
"plugin_name": "com.sap.hana.di.table"
|
||||||
|
},
|
||||||
|
"hdbtabledata": {
|
||||||
|
"plugin_name": "com.sap.hana.di.tabledata"
|
||||||
|
},
|
||||||
|
"hdbtabletype": {
|
||||||
|
"plugin_name": "com.sap.hana.di.tabletype"
|
||||||
|
},
|
||||||
|
"hdbtrigger": {
|
||||||
|
"plugin_name": "com.sap.hana.di.trigger"
|
||||||
|
},
|
||||||
|
"hdbview": {
|
||||||
|
"plugin_name": "com.sap.hana.di.view"
|
||||||
|
},
|
||||||
|
"hdbvirtualfunction": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualfunction"
|
||||||
|
},
|
||||||
|
"hdbvirtualfunctionconfig": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualfunction.config"
|
||||||
|
},
|
||||||
|
"hdbvirtualpackagehadoop": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
|
||||||
|
},
|
||||||
|
"hdbvirtualpackagesparksql": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
|
||||||
|
},
|
||||||
|
"hdbvirtualprocedure": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualprocedure"
|
||||||
|
},
|
||||||
|
"hdbvirtualprocedureconfig": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
|
||||||
|
},
|
||||||
|
"hdbvirtualtable": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualtable"
|
||||||
|
},
|
||||||
|
"hdbvirtualtableconfig": {
|
||||||
|
"plugin_name": "com.sap.hana.di.virtualtable.config"
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
||||||
|
},
|
||||||
|
"txt": {
|
||||||
|
"plugin_name": "com.sap.hana.di.copyonly"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
####### appName = capire-bookshop
|
####### appName = capire-bookshop
|
||||||
####### language=nodejs; multiTenant=
|
####### language=nodejs; multiTenant=
|
||||||
####### approuter=
|
####### approuter=
|
||||||
|
|
||||||
_schema-version: '3.1'
|
_schema-version: '3.1'
|
||||||
ID: sap.capire-bookshop
|
ID: sap.capire-bookshop
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
@@ -30,6 +29,7 @@ modules:
|
|||||||
requires:
|
requires:
|
||||||
#### Resources extracted from CAP configuration ####
|
#### Resources extracted from CAP configuration ####
|
||||||
- name: capire-bookshop-db
|
- name: capire-bookshop-db
|
||||||
|
- name: capire-bookshop-uaa
|
||||||
|
|
||||||
provides:
|
provides:
|
||||||
- name: srv-binding # required by consumers of CAP services (e.g. approuter)
|
- name: srv-binding # required by consumers of CAP services (e.g. approuter)
|
||||||
@@ -48,8 +48,26 @@ modules:
|
|||||||
requires:
|
requires:
|
||||||
#### Hana and xsuaa resources extracted from CAP configuration ####
|
#### Hana and xsuaa resources extracted from CAP configuration ####
|
||||||
- name: capire-bookshop-db
|
- name: capire-bookshop-db
|
||||||
|
- name: capire-bookshop-uaa
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
|
############## APP #########################
|
||||||
|
- name: capire-bookshop-app
|
||||||
|
type: nodejs
|
||||||
|
path: gen/app
|
||||||
|
parameters:
|
||||||
|
memory: 256M
|
||||||
|
build-parameters:
|
||||||
|
requires:
|
||||||
|
- name: capire-bookshop-srv
|
||||||
|
requires:
|
||||||
|
- name: capire-bookshop-uaa
|
||||||
|
- name: srv-binding
|
||||||
|
group: destinations
|
||||||
|
properties:
|
||||||
|
forwardAuthToken: true
|
||||||
|
name: srv-binding
|
||||||
|
url: ~{srv-url}
|
||||||
|
|
||||||
############## RESOURCES ##################################
|
############## RESOURCES ##################################
|
||||||
resources:
|
resources:
|
||||||
@@ -59,6 +77,18 @@ resources:
|
|||||||
type: com.sap.xs.hdi-container
|
type: com.sap.xs.hdi-container
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
|
service: hanatrial
|
||||||
properties:
|
properties:
|
||||||
hdi-service-name: ${service-name} # required for Java case
|
hdi-service-name: ${service-name} # required for Java case
|
||||||
|
- name: capire-bookshop-uaa
|
||||||
|
|
||||||
|
type: org.cloudfoundry.managed-service
|
||||||
|
parameters:
|
||||||
|
##### Path to xs-security.json to add roles and scopes ####
|
||||||
|
path: ./xs-security.json
|
||||||
|
service: xsuaa
|
||||||
|
service-plan: application
|
||||||
|
config:
|
||||||
|
xsappname: capire-bookshop-${space} # name + space dependency
|
||||||
|
tenant-mode: dedicated
|
||||||
############################################################
|
############################################################
|
||||||
29
packages/bookshop/package.json
Normal file
29
packages/bookshop/package.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"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": "^4",
|
||||||
|
"express": "^4",
|
||||||
|
"hdb": "^0.18.1",
|
||||||
|
"passport": "^0.4.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "cds run --in-memory?",
|
||||||
|
"watch": "cds watch"
|
||||||
|
},
|
||||||
|
"cds": {
|
||||||
|
"requires": {
|
||||||
|
"db": {
|
||||||
|
"kind": "sql",
|
||||||
|
"[production]": {
|
||||||
|
"kind": "hana"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uaa": {
|
||||||
|
"kind": "xsuaa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
packages/bookshop/sqlite.db
Normal file
BIN
packages/bookshop/sqlite.db
Normal file
Binary file not shown.
@@ -14,3 +14,7 @@ annotate AdminService.Orders with @odata.draft.enabled;
|
|||||||
extend service AdminService with {
|
extend service AdminService with {
|
||||||
entity OrderItems as select from my.OrderItems;
|
entity OrderItems as select from my.OrderItems;
|
||||||
}
|
}
|
||||||
|
// Restrict access to orders to users with role "admin"
|
||||||
|
annotate AdminService.Orders with @(restrict: [
|
||||||
|
{ grant: 'READ', to: 'admin' }
|
||||||
|
]);
|
||||||
10
packages/bookshop/srv/admin-service.js
Normal file
10
packages/bookshop/srv/admin-service.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/** Service implementation for AdminService */
|
||||||
|
module.exports = cds.service.impl(function() {
|
||||||
|
this.before ('CREATE', 'Orders', _checkOrderCreateAuth)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
/** Check authorization */
|
||||||
|
function _checkOrderCreateAuth (req) {
|
||||||
|
req.user.currency[0] === req.data.currency_code || req.reject(403)
|
||||||
|
}
|
||||||
@@ -8,6 +8,10 @@ service CatalogService {
|
|||||||
} excluding { createdBy, modifiedBy };
|
} excluding { createdBy, modifiedBy };
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
@insertonly entity Orders as projection on my.Orders;
|
entity Orders as projection on my.Orders;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Example for an instance restriction
|
||||||
|
annotate CatalogService.Orders with @(restrict: [
|
||||||
|
{ grant: 'READ', where: 'currency_code = $user.currency' }
|
||||||
|
]);
|
||||||
@@ -14,13 +14,20 @@ function _addDiscount2 (each,discount) {
|
|||||||
|
|
||||||
/** Reduce stock of ordered books if available stock suffices */
|
/** Reduce stock of ordered books if available stock suffices */
|
||||||
async function _reduceStock (req) {
|
async function _reduceStock (req) {
|
||||||
const { Items: OrderItems } = req.data
|
const { Items: orderItems } = req.data
|
||||||
return cds.transaction(req) .run (()=> OrderItems.map (order =>
|
if (!Array.isArray(orderItems)) return
|
||||||
UPDATE (Books) .set ('stock -=', order.amount)
|
|
||||||
.where ('ID =', order.book_ID) .and ('stock >=', order.amount)
|
const all = await cds.transaction(req).run(orderItems.map(item =>
|
||||||
)) .then (all => all.forEach ((affectedRows,i) => {
|
UPDATE(Books)
|
||||||
if (affectedRows === 0) req.error (409,
|
.set('stock -=', item.amount)
|
||||||
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
.where('ID =', item.book_ID).and('stock >=', item.amount)
|
||||||
)
|
))
|
||||||
}))
|
all.forEach((affectedRows, i) => {
|
||||||
|
if (affectedRows === 0) {
|
||||||
|
req.error(409, `${orderItems[i].amount} exceeds stock for book #${orderItems[i].book_ID}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return all
|
||||||
|
|
||||||
}
|
}
|
||||||
37
packages/bookshop/xs-security.json
Normal file
37
packages/bookshop/xs-security.json
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"xsappname": "capire-bookshop",
|
||||||
|
"tenant-mode": "dedicated",
|
||||||
|
"scopes": [
|
||||||
|
{
|
||||||
|
"name": "$XSAPPNAME.admin",
|
||||||
|
"description": "admin"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attributes": [
|
||||||
|
{
|
||||||
|
"name": "currency",
|
||||||
|
"description": "currency",
|
||||||
|
"valueType": "s",
|
||||||
|
"valueRequired": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"role-templates": [
|
||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"description": "generated",
|
||||||
|
"scope-references": [
|
||||||
|
"$XSAPPNAME.admin"
|
||||||
|
],
|
||||||
|
"attribute-references": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userattributes",
|
||||||
|
"description": "generated",
|
||||||
|
"default-role-name": "Attributes of a User",
|
||||||
|
"scope-references": [],
|
||||||
|
"attribute-references": [
|
||||||
|
"currency"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
###
|
|
||||||
# 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'
|
|
||||||
Reference in New Issue
Block a user