Compare commits
30 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 |
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": [
|
||||||
|
|||||||
78
README.md
78
README.md
@@ -11,7 +11,7 @@ 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-unit1
|
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week3-unit5
|
||||||
cd projects/cloud-cap-samples
|
cd projects/cloud-cap-samples
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -25,11 +25,87 @@ npm install
|
|||||||
Now you're ready to run the samples, for example:
|
Now you're ready to run the samples, for example:
|
||||||
```sh
|
```sh
|
||||||
cd packages/bookshop
|
cd packages/bookshop
|
||||||
|
cds deploy
|
||||||
cds watch
|
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.
|
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
|
||||||
|
|
||||||
|
|||||||
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
878
package-lock.json
generated
878
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,14 +8,10 @@
|
|||||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
||||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
||||||
"cleanup": "lerna clean -y && rm -fr node_modules",
|
"cleanup": "lerna clean -y && rm -fr node_modules",
|
||||||
"bookshop": "cds watch packages/bookshop",
|
"bookshop": "cds watch packages/bookshop"
|
||||||
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
|
|
||||||
"reviews-service": "cds watch packages/reviews-service",
|
|
||||||
"bookstore": "cds watch packages/bookstore",
|
|
||||||
"media-server": "cds watch packages/media-server"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^3",
|
"@sap/cds": "^4",
|
||||||
"express": "^4"
|
"express": "^4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
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\"}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
13
packages/bookshop/app/_i18n/i18n.properties
Normal file
13
packages/bookshop/app/_i18n/i18n.properties
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Books = Books
|
||||||
|
Book = Book
|
||||||
|
ID = ID
|
||||||
|
Title = Title
|
||||||
|
Author = Author
|
||||||
|
AuthorID = Author ID
|
||||||
|
Stock = Stock
|
||||||
|
Name = Name
|
||||||
|
AuthorName = Author's Name
|
||||||
|
Authors = Authors
|
||||||
|
Order = Order
|
||||||
|
Orders = Orders
|
||||||
|
Price = Price
|
||||||
13
packages/bookshop/app/_i18n/i18n_de.properties
Normal file
13
packages/bookshop/app/_i18n/i18n_de.properties
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Books = Bücher
|
||||||
|
Book = Buch
|
||||||
|
ID = ID
|
||||||
|
Title = Titel
|
||||||
|
Authors = Autoren
|
||||||
|
Author = Autor
|
||||||
|
AuthorID = ID des Autors
|
||||||
|
AuthorName = Name des Autors
|
||||||
|
Name = Name
|
||||||
|
Stock = Bestand
|
||||||
|
Order = Bestellung
|
||||||
|
Orders = Bestellungen
|
||||||
|
Price = Preis
|
||||||
37
packages/bookshop/app/admin/fiori-service.cds
Normal file
37
packages/bookshop/app/admin/fiori-service.cds
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using AdminService from '../../srv/admin-service';
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Object Page
|
||||||
|
//
|
||||||
|
annotate AdminService.Books with @(
|
||||||
|
UI: {
|
||||||
|
Facets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>General}', Target: '@UI.FieldGroup#General'},
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'},
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Admin}', Target: '@UI.FieldGroup#Admin'},
|
||||||
|
],
|
||||||
|
FieldGroup#General: {
|
||||||
|
Data: [
|
||||||
|
{Value: title},
|
||||||
|
{Value: author_ID},
|
||||||
|
{Value: descr},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
FieldGroup#Details: {
|
||||||
|
Data: [
|
||||||
|
{Value: stock},
|
||||||
|
{Value: price},
|
||||||
|
{Value: currency_code, Label: '{i18n>Currency}'},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
FieldGroup#Admin: {
|
||||||
|
Data: [
|
||||||
|
{Value: createdBy},
|
||||||
|
{Value: createdAt},
|
||||||
|
{Value: modifiedBy},
|
||||||
|
{Value: modifiedAt}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
22
packages/bookshop/app/admin/webapp/Component.js
Normal file
22
packages/bookshop/app/admin/webapp/Component.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
sap.ui.define(["sap/fe/AppComponent"], ac => ac.extend("admin.Component", {
|
||||||
|
metadata:{ manifest:'json' }
|
||||||
|
}))
|
||||||
|
|
||||||
|
// sap.ui.define (["sap/ui/core/UIComponent"], ui5 => ui5.extend("bookshop.Component", {
|
||||||
|
// metadata: { manifest: "json" }
|
||||||
|
// }))
|
||||||
|
// sap.ui.define (["sap/ui/generic/app/AppComponent"], ui5 => ui5.extend("bookshop.Component", {
|
||||||
|
// metadata: { manifest: "json" }
|
||||||
|
// }))
|
||||||
|
|
||||||
|
// jQuery.sap.declare("bookshop.Component");
|
||||||
|
// sap.ui.getCore().loadLibrary("sap.ui.generic.app");
|
||||||
|
// jQuery.sap.require("sap.ui.generic.app.AppComponent");
|
||||||
|
|
||||||
|
// sap.ui.generic.app.AppComponent.extend("bookshop.Component", {
|
||||||
|
// metadata: {
|
||||||
|
// manifest: "json"
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
/* eslint no-undef:0 */
|
||||||
11
packages/bookshop/app/admin/webapp/i18n/i18n.properties
Normal file
11
packages/bookshop/app/admin/webapp/i18n/i18n.properties
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# This is the resource bundle of itelo
|
||||||
|
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case TITLE
|
||||||
|
appTitle=Bookshop Sample
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case DESCRIPTION
|
||||||
|
appSubTitle=CAP Sample Application
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case DESCRIPTION
|
||||||
|
appDescription=CDS Sample Service
|
||||||
128
packages/bookshop/app/admin/webapp/manifest.json
Normal file
128
packages/bookshop/app/admin/webapp/manifest.json
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
{
|
||||||
|
"_version": "1.8.0",
|
||||||
|
"sap.app": {
|
||||||
|
"id": "admin",
|
||||||
|
"type": "application",
|
||||||
|
"title": "Manage Books",
|
||||||
|
"description": "Sample Application",
|
||||||
|
"i18n": "i18n/i18n.properties",
|
||||||
|
"dataSources": {
|
||||||
|
"AdminService": {
|
||||||
|
"uri": "/admin/",
|
||||||
|
"type": "OData",
|
||||||
|
"settings": {
|
||||||
|
"odataVersion": "4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"-sourceTemplate": {
|
||||||
|
"id": "ui5template.basicSAPUI5ApplicationProject",
|
||||||
|
"-id": "ui5template.smartTemplate",
|
||||||
|
"-version": "1.40.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui5": {
|
||||||
|
"dependencies": {
|
||||||
|
"libs": {
|
||||||
|
"sap.fe": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
"i18n": {
|
||||||
|
"type": "sap.ui.model.resource.ResourceModel",
|
||||||
|
"uri": "i18n/i18n.properties"
|
||||||
|
},
|
||||||
|
"": {
|
||||||
|
"dataSource": "AdminService",
|
||||||
|
"settings": {
|
||||||
|
"synchronizationMode": "None",
|
||||||
|
"operationMode": "Server",
|
||||||
|
"autoExpandSelect" : true,
|
||||||
|
"earlyRequests": true,
|
||||||
|
"groupProperties": {
|
||||||
|
"default": {
|
||||||
|
"submit": "Auto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"routing": {
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"pattern": ":?query:",
|
||||||
|
"name": "BooksList",
|
||||||
|
"target": "BooksList"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Books({key}):?query:",
|
||||||
|
"name": "BooksDetails",
|
||||||
|
"target": "BooksDetails"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Books({key}/author({key2}):?query:",
|
||||||
|
"name": "AuthorsDetails",
|
||||||
|
"target": "AuthorsDetails"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"targets": {
|
||||||
|
"BooksList": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksList",
|
||||||
|
"name": "sap.fe.templates.ListReport",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet" : "Books",
|
||||||
|
"navigation" : {
|
||||||
|
"Books" : {
|
||||||
|
"detail" : {
|
||||||
|
"route" : "BooksDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BooksDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksDetailsList",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet" : "Books",
|
||||||
|
"navigation" : {
|
||||||
|
"Authors" : {
|
||||||
|
"detail" : {
|
||||||
|
"route" : "AuthorsDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AuthorsDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "AuthorsDetailsList",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet" : "Authors"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contentDensities": {
|
||||||
|
"compact": true,
|
||||||
|
"cozy": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui": {
|
||||||
|
"technology": "UI5",
|
||||||
|
"fullWidth": false
|
||||||
|
},
|
||||||
|
"sap.fiori": {
|
||||||
|
"registrationIds": [],
|
||||||
|
"archeType": "transactional"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
packages/bookshop/app/browse/fiori-service.cds
Normal file
47
packages/bookshop/app/browse/fiori-service.cds
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using CatalogService from '../../srv/cat-service';
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Object Page
|
||||||
|
//
|
||||||
|
annotate CatalogService.Books with @(
|
||||||
|
UI: {
|
||||||
|
HeaderInfo: {
|
||||||
|
Description: {Value: author}
|
||||||
|
},
|
||||||
|
HeaderFacets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Description}', Target: '@UI.FieldGroup#Descr'},
|
||||||
|
],
|
||||||
|
Facets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Price'},
|
||||||
|
],
|
||||||
|
FieldGroup#Descr: {
|
||||||
|
Data: [
|
||||||
|
{Value: descr},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
FieldGroup#Price: {
|
||||||
|
Data: [
|
||||||
|
{Value: price},
|
||||||
|
{Value: currency.symbol, Label: '{i18n>Currency}'},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Object Page
|
||||||
|
//
|
||||||
|
annotate CatalogService.Books with @(
|
||||||
|
UI: {
|
||||||
|
SelectionFields: [ ID, price, currency_code ],
|
||||||
|
LineItem: [
|
||||||
|
{Value: title},
|
||||||
|
{Value: author, Label:'{i18n>Author}'},
|
||||||
|
{Value: price},
|
||||||
|
{Value: currency.symbol, Label:' '},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
);
|
||||||
22
packages/bookshop/app/browse/webapp/Component.js
Normal file
22
packages/bookshop/app/browse/webapp/Component.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
sap.ui.define(["sap/fe/AppComponent"], ac => ac.extend("bookshop.Component", {
|
||||||
|
metadata:{ manifest:'json' }
|
||||||
|
}))
|
||||||
|
|
||||||
|
// sap.ui.define (["sap/ui/core/UIComponent"], ui5 => ui5.extend("bookshop.Component", {
|
||||||
|
// metadata: { manifest: "json" }
|
||||||
|
// }))
|
||||||
|
// sap.ui.define (["sap/ui/generic/app/AppComponent"], ui5 => ui5.extend("bookshop.Component", {
|
||||||
|
// metadata: { manifest: "json" }
|
||||||
|
// }))
|
||||||
|
|
||||||
|
// jQuery.sap.declare("bookshop.Component");
|
||||||
|
// sap.ui.getCore().loadLibrary("sap.ui.generic.app");
|
||||||
|
// jQuery.sap.require("sap.ui.generic.app.AppComponent");
|
||||||
|
|
||||||
|
// sap.ui.generic.app.AppComponent.extend("bookshop.Component", {
|
||||||
|
// metadata: {
|
||||||
|
// manifest: "json"
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
/* eslint no-undef:0 */
|
||||||
11
packages/bookshop/app/browse/webapp/i18n/i18n.properties
Normal file
11
packages/bookshop/app/browse/webapp/i18n/i18n.properties
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# This is the resource bundle of itelo
|
||||||
|
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case TITLE
|
||||||
|
appTitle=Bookshop Sample
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case DESCRIPTION
|
||||||
|
appSubTitle=CAP Sample Application
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case DESCRIPTION
|
||||||
|
appDescription=CDS Sample Service
|
||||||
106
packages/bookshop/app/browse/webapp/manifest.json
Normal file
106
packages/bookshop/app/browse/webapp/manifest.json
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
{
|
||||||
|
"_version": "1.8.0",
|
||||||
|
"sap.app": {
|
||||||
|
"id": "bookshop",
|
||||||
|
"type": "application",
|
||||||
|
"title": "Browse Books",
|
||||||
|
"description": "Sample Application",
|
||||||
|
"i18n": "i18n/i18n.properties",
|
||||||
|
"dataSources": {
|
||||||
|
"CatalogService": {
|
||||||
|
"uri": "/browse/",
|
||||||
|
"type": "OData",
|
||||||
|
"settings": {
|
||||||
|
"odataVersion": "4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"-sourceTemplate": {
|
||||||
|
"id": "ui5template.basicSAPUI5ApplicationProject",
|
||||||
|
"-id": "ui5template.smartTemplate",
|
||||||
|
"-version": "1.40.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui5": {
|
||||||
|
"dependencies": {
|
||||||
|
"libs": {
|
||||||
|
"sap.fe": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
"i18n": {
|
||||||
|
"type": "sap.ui.model.resource.ResourceModel",
|
||||||
|
"uri": "i18n/i18n.properties"
|
||||||
|
},
|
||||||
|
"": {
|
||||||
|
"dataSource": "CatalogService",
|
||||||
|
"settings": {
|
||||||
|
"synchronizationMode": "None",
|
||||||
|
"operationMode": "Server",
|
||||||
|
"autoExpandSelect": true,
|
||||||
|
"earlyRequests": true,
|
||||||
|
"groupProperties": {
|
||||||
|
"default": {
|
||||||
|
"submit": "Auto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"routing": {
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"pattern": ":?query:",
|
||||||
|
"name": "BooksList",
|
||||||
|
"target": "BooksList"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Books({key}):?query:",
|
||||||
|
"name": "BooksDetails",
|
||||||
|
"target": "BooksDetails"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"targets": {
|
||||||
|
"BooksList": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksList",
|
||||||
|
"name": "sap.fe.templates.ListReport",
|
||||||
|
"options": {
|
||||||
|
"settings": {
|
||||||
|
"entitySet": "Books",
|
||||||
|
"navigation": {
|
||||||
|
"Books": {
|
||||||
|
"detail": {
|
||||||
|
"route": "BooksDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BooksDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksDetailsList",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings": {
|
||||||
|
"entitySet": "Books"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contentDensities": {
|
||||||
|
"compact": true,
|
||||||
|
"cozy": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui": {
|
||||||
|
"technology": "UI5",
|
||||||
|
"fullWidth": false
|
||||||
|
},
|
||||||
|
"sap.fiori": {
|
||||||
|
"registrationIds": [],
|
||||||
|
"archeType": "transactional"
|
||||||
|
}
|
||||||
|
}
|
||||||
74
packages/bookshop/app/common.cds
Normal file
74
packages/bookshop/app/common.cds
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
Common Annotations shared by all apps
|
||||||
|
*/
|
||||||
|
|
||||||
|
using { sap.capire.bookshop as my } from '../db/schema';
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Lists
|
||||||
|
//
|
||||||
|
annotate my.Books with @(
|
||||||
|
UI: {
|
||||||
|
Identification: [{Value:title}],
|
||||||
|
SelectionFields: [ ID, author_ID, price, currency_code ],
|
||||||
|
LineItem: [
|
||||||
|
{Value: ID},
|
||||||
|
{Value: title},
|
||||||
|
{Value: author.name, Label:'{i18n>Author}'},
|
||||||
|
{Value: stock},
|
||||||
|
{Value: price},
|
||||||
|
{Value: currency.symbol, Label:' '},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
author @ValueList.entity:'Authors';
|
||||||
|
};
|
||||||
|
|
||||||
|
annotate my.Authors with @(
|
||||||
|
UI: {
|
||||||
|
Identification: [{Value:name}],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Details
|
||||||
|
//
|
||||||
|
annotate my.Books with @(
|
||||||
|
UI: {
|
||||||
|
HeaderInfo: {
|
||||||
|
TypeName: '{i18n>Book}',
|
||||||
|
TypeNamePlural: '{i18n>Books}',
|
||||||
|
Title: {Value: title},
|
||||||
|
Description: {Value: author.name}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Elements
|
||||||
|
//
|
||||||
|
annotate my.Books with {
|
||||||
|
ID @title:'{i18n>ID}' @UI.HiddenFilter;
|
||||||
|
title @title:'{i18n>Title}';
|
||||||
|
author @title:'{i18n>AuthorID}';
|
||||||
|
price @title:'{i18n>Price}';
|
||||||
|
stock @title:'{i18n>Stock}';
|
||||||
|
descr @UI.MultiLineText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Authors Elements
|
||||||
|
//
|
||||||
|
annotate my.Authors with {
|
||||||
|
ID @title:'{i18n>ID}' @UI.HiddenFilter;
|
||||||
|
name @title:'{i18n>AuthorName}';
|
||||||
|
}
|
||||||
55
packages/bookshop/app/fiori.html
Normal file
55
packages/bookshop/app/fiori.html
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Bookshop</title>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window["sap-ushell-config"] = {
|
||||||
|
defaultRenderer: "fiori2",
|
||||||
|
applications: {
|
||||||
|
"browse-books": {
|
||||||
|
title: "Browse Books",
|
||||||
|
description: "... testing FE v42",
|
||||||
|
additionalInformation: "SAPUI5.Component=bookshop",
|
||||||
|
applicationType : "URL",
|
||||||
|
url: "/browse/webapp",
|
||||||
|
navigationMode: "embedded"
|
||||||
|
},
|
||||||
|
"manage-books": {
|
||||||
|
title: "Manage Books",
|
||||||
|
description: "... testing FE v42",
|
||||||
|
additionalInformation: "SAPUI5.Component=admin",
|
||||||
|
applicationType : "URL",
|
||||||
|
url: "/admin/webapp",
|
||||||
|
navigationMode: "embedded"
|
||||||
|
},
|
||||||
|
"manage-orders": {
|
||||||
|
title: "Manage Orders",
|
||||||
|
description: "... testing FE v42",
|
||||||
|
additionalInformation: "SAPUI5.Component=orders",
|
||||||
|
applicationType : "URL",
|
||||||
|
url: "/orders/webapp",
|
||||||
|
navigationMode: "embedded"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="https://sapui5.hana.ondemand.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
|
||||||
|
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
||||||
|
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
||||||
|
data-sap-ui-compatVersion="edge"
|
||||||
|
data-sap-ui-theme="sap_fiori_3"
|
||||||
|
data-sap-ui-frameOptions="allow"
|
||||||
|
></script>
|
||||||
|
<script>
|
||||||
|
sap.ui.getCore().attachInit(()=> sap.ushell.Container.createRenderer().placeAt("content"))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body class="sapUiBody" id="content"></body>
|
||||||
|
</html>
|
||||||
8
packages/bookshop/app/index.cds
Normal file
8
packages/bookshop/app/index.cds
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
This model controls what gets served to Fiori frontends...
|
||||||
|
*/
|
||||||
|
|
||||||
|
using from './admin/fiori-service';
|
||||||
|
using from './browse/fiori-service';
|
||||||
|
using from './orders/fiori-service';
|
||||||
|
using from './common';
|
||||||
117
packages/bookshop/app/orders/fiori-service.cds
Normal file
117
packages/bookshop/app/orders/fiori-service.cds
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
using AdminService from '../../srv/admin-service';
|
||||||
|
|
||||||
|
annotate AdminService.Books with {
|
||||||
|
price @Common.FieldControl: #ReadOnly;
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Common
|
||||||
|
//
|
||||||
|
annotate AdminService.OrderItems with {
|
||||||
|
book @(
|
||||||
|
Common: {
|
||||||
|
Text: book.title,
|
||||||
|
FieldControl: #Mandatory
|
||||||
|
},
|
||||||
|
ValueList.entity:'Books',
|
||||||
|
);
|
||||||
|
amount @(
|
||||||
|
Common.FieldControl: #Mandatory
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
annotate AdminService.Orders with @(
|
||||||
|
UI: {
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Lists of Orders
|
||||||
|
//
|
||||||
|
SelectionFields: [ createdAt, createdBy ],
|
||||||
|
LineItem: [
|
||||||
|
{Value: createdBy, Label:'Customer'},
|
||||||
|
{Value: createdAt, Label:'Date'}
|
||||||
|
],
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Order Details
|
||||||
|
//
|
||||||
|
HeaderInfo: {
|
||||||
|
TypeName: 'Order', TypeNamePlural: 'Orders',
|
||||||
|
Title: {
|
||||||
|
Label: 'Order number ', //A label is possible but it is not considered on the ObjectPage yet
|
||||||
|
Value: OrderNo
|
||||||
|
},
|
||||||
|
Description: {Value: createdBy}
|
||||||
|
},
|
||||||
|
Identification: [ //Is the main field group
|
||||||
|
{Value: createdBy, Label:'Customer'},
|
||||||
|
{Value: createdAt, Label:'Date'},
|
||||||
|
{Value: OrderNo },
|
||||||
|
],
|
||||||
|
HeaderFacets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Created}', Target: '@UI.FieldGroup#Created'},
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Modified}', Target: '@UI.FieldGroup#Modified'},
|
||||||
|
],
|
||||||
|
Facets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'},
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: 'Items/@UI.LineItem'},
|
||||||
|
],
|
||||||
|
FieldGroup#Details: {
|
||||||
|
Data: [
|
||||||
|
{Value: currency_code, Label:'Currency'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
FieldGroup#Created: {
|
||||||
|
Data: [
|
||||||
|
{Value: createdBy},
|
||||||
|
{Value: createdAt},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
FieldGroup#Modified: {
|
||||||
|
Data: [
|
||||||
|
{Value: modifiedBy},
|
||||||
|
{Value: modifiedAt},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
createdAt @UI.HiddenFilter:false;
|
||||||
|
createdBy @UI.HiddenFilter:false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//The enity types name is AdminService.my_bookshop_OrderItems
|
||||||
|
//The annotations below are not generated in edmx WHY?
|
||||||
|
annotate AdminService.OrderItems with @(
|
||||||
|
UI: {
|
||||||
|
HeaderInfo: {
|
||||||
|
TypeName: 'Order Item', TypeNamePlural: ' ',
|
||||||
|
Title: {
|
||||||
|
Value: book.title
|
||||||
|
},
|
||||||
|
Description: {Value: book.descr}
|
||||||
|
},
|
||||||
|
// There is no filterbar for items so the selctionfileds is not needed
|
||||||
|
SelectionFields: [ book_ID ],
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Lists of OrderItems
|
||||||
|
//
|
||||||
|
LineItem: [
|
||||||
|
{Value: book_ID, Label:'Book'},
|
||||||
|
//The following entry is only used to have the assoication followed in the read event
|
||||||
|
{Value: book.price, Label:'Book Price'},
|
||||||
|
{Value: amount, Label:'Quantity'},
|
||||||
|
],
|
||||||
|
Identification: [ //Is the main field group
|
||||||
|
//{Value: ID, Label:'ID'}, //A guid shouldn't be on the UI
|
||||||
|
{Value: book_ID, Label:'Book'},
|
||||||
|
{Value: amount, Label:'Amount'},
|
||||||
|
],
|
||||||
|
Facets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: '@UI.Identification'},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
);
|
||||||
22
packages/bookshop/app/orders/webapp/Component.js
Normal file
22
packages/bookshop/app/orders/webapp/Component.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
sap.ui.define(["sap/fe/AppComponent"], ac => ac.extend("orders.Component", {
|
||||||
|
metadata:{ manifest:'json' }
|
||||||
|
}))
|
||||||
|
|
||||||
|
// sap.ui.define (["sap/ui/core/UIComponent"], ui5 => ui5.extend("bookshop.Component", {
|
||||||
|
// metadata: { manifest: "json" }
|
||||||
|
// }))
|
||||||
|
// sap.ui.define (["sap/ui/generic/app/AppComponent"], ui5 => ui5.extend("bookshop.Component", {
|
||||||
|
// metadata: { manifest: "json" }
|
||||||
|
// }))
|
||||||
|
|
||||||
|
// jQuery.sap.declare("bookshop.Component");
|
||||||
|
// sap.ui.getCore().loadLibrary("sap.ui.generic.app");
|
||||||
|
// jQuery.sap.require("sap.ui.generic.app.AppComponent");
|
||||||
|
|
||||||
|
// sap.ui.generic.app.AppComponent.extend("bookshop.Component", {
|
||||||
|
// metadata: {
|
||||||
|
// manifest: "json"
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
/* eslint no-undef:0 */
|
||||||
11
packages/bookshop/app/orders/webapp/i18n/i18n.properties
Normal file
11
packages/bookshop/app/orders/webapp/i18n/i18n.properties
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# This is the resource bundle of itelo
|
||||||
|
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case TITLE
|
||||||
|
appTitle=Bookshop Sample
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case DESCRIPTION
|
||||||
|
appSubTitle=CAP Sample Application
|
||||||
|
|
||||||
|
# JCI app descriptor contains lower case DESCRIPTION
|
||||||
|
appDescription=CDS Sample Service
|
||||||
170
packages/bookshop/app/orders/webapp/manifest.json
Normal file
170
packages/bookshop/app/orders/webapp/manifest.json
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
{
|
||||||
|
"_version": "1.8.0",
|
||||||
|
"sap.app": {
|
||||||
|
"id": "orders",
|
||||||
|
"type": "application",
|
||||||
|
"title": "Manage Orders",
|
||||||
|
"description": "Sample Application",
|
||||||
|
"i18n": "i18n/i18n.properties",
|
||||||
|
"dataSources": {
|
||||||
|
"AdminService": {
|
||||||
|
"uri": "/admin/",
|
||||||
|
"type": "OData",
|
||||||
|
"settings": {
|
||||||
|
"odataVersion": "4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"-sourceTemplate": {
|
||||||
|
"id": "ui5template.basicSAPUI5ApplicationProject",
|
||||||
|
"-id": "ui5template.smartTemplate",
|
||||||
|
"-version": "1.40.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui5": {
|
||||||
|
"dependencies": {
|
||||||
|
"libs": {
|
||||||
|
"sap.fe": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
"i18n": {
|
||||||
|
"type": "sap.ui.model.resource.ResourceModel",
|
||||||
|
"uri": "i18n/i18n.properties"
|
||||||
|
},
|
||||||
|
"": {
|
||||||
|
"dataSource": "AdminService",
|
||||||
|
"settings": {
|
||||||
|
"synchronizationMode": "None",
|
||||||
|
"operationMode": "Server",
|
||||||
|
"autoExpandSelect" : true,
|
||||||
|
"earlyRequests": true,
|
||||||
|
"groupProperties": {
|
||||||
|
"default": {
|
||||||
|
"submit": "Auto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"routing": {
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"pattern": ":?query:",
|
||||||
|
"name": "OrdersList",
|
||||||
|
"target": "OrdersList"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Orders({key}):?query:",
|
||||||
|
"name": "OrdersDetails",
|
||||||
|
"target": "OrdersDetails"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Orders({boo})/Items({boo2}):?query:",
|
||||||
|
"name": "OrderItemsDetails",
|
||||||
|
"target": "OrderItemsDetails"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Books({key}):?query:",
|
||||||
|
"name": "BooksDetails",
|
||||||
|
"target": "BooksDetails"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"targets": {
|
||||||
|
"OrdersList": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "OrdersList",
|
||||||
|
"name": "sap.fe.templates.ListReport",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet" : "Orders",
|
||||||
|
"navigation" : {
|
||||||
|
"Orders" : {
|
||||||
|
"detail" : {
|
||||||
|
"route" : "OrdersDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OrdersDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "OrdersDetails",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet": "Orders",
|
||||||
|
"navigation" : {
|
||||||
|
"Items": {
|
||||||
|
"detail": {
|
||||||
|
"route": "OrderItemsDetails"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"book": {
|
||||||
|
"detail": {
|
||||||
|
"route": "BooksDetails"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dummy": {
|
||||||
|
"detail": {
|
||||||
|
"route": "BooksDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OrderItemsDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "OrderItemsDetails",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet": "OrderItems"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BooksDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksDetails",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet": "Books",
|
||||||
|
"navigation": {
|
||||||
|
"author": {
|
||||||
|
"detail": {
|
||||||
|
"route": "AuthorsDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AuthorsDetails": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "AuthorsDetails",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet": "Authors"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contentDensities": {
|
||||||
|
"compact": true,
|
||||||
|
"cozy": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui": {
|
||||||
|
"technology": "UI5",
|
||||||
|
"fullWidth": false
|
||||||
|
},
|
||||||
|
"sap.fiori": {
|
||||||
|
"registrationIds": [],
|
||||||
|
"archeType": "transactional"
|
||||||
|
}
|
||||||
|
}
|
||||||
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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
ID;name
|
ID;name;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath
|
||||||
101;Emily Brontë
|
101;Emily Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire
|
||||||
107;Charlotte Brontë
|
107;Charlotte Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire
|
||||||
150;Edgar Allen Poe
|
150;Edgar Allen Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland
|
||||||
170;Richard Carpenter
|
170;Richard Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
ID;title;author_ID;stock
|
ID;title;descr;author_ID;stock;price;currency_code
|
||||||
201;Wuthering Heights;101;12
|
201;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";101;12;11.11;GBP
|
||||||
207;Jane Eyre;107;11
|
207;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";107;11;12.34;GBP
|
||||||
251;The Raven;150;333
|
251;The Raven;"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";150;333;13.13;USD
|
||||||
252;Eleonora;150;555
|
252;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";150;555;14;USD
|
||||||
271;Catweazle;170;22
|
271;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;170;22;15;EUR
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
ID;locale;title;descr
|
||||||
|
201;de;Sturmhöhe;Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts.
|
||||||
|
207;de;Jane Eyre;Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte
|
||||||
|
252;de;Eleonora;“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit.
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
ID;amount;parent_ID;book_ID;netAmount
|
||||||
|
58040e66-1dcd-4ffb-ab10-fdce32028b79;1;7e2f2640-6866-4dcf-8f4d-3027aa831cad;201;11.11
|
||||||
|
64e718c9-ff99-47f1-8ca3-950c850777d4;1;7e2f2640-6866-4dcf-8f4d-3027aa831cad;271;15
|
||||||
|
e9641166-e050-4261-bfee-d1e797e6cb7f;2;64e718c9-ff99-47f1-8ca3-950c850777d4;252;28
|
||||||
|
3
packages/bookshop/db/data/sap.capire.bookshop-Orders.csv
Normal file
3
packages/bookshop/db/data/sap.capire.bookshop-Orders.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code
|
||||||
|
7e2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-01-31;john.doe@test.com;;1;EUR
|
||||||
|
64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;jane.doe@test.com;;2;EUR
|
||||||
|
7
packages/bookshop/db/data/sap.common-Currencies.csv
Normal file
7
packages/bookshop/db/data/sap.common-Currencies.csv
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
code;symbol;name;descr
|
||||||
|
EUR;€;Euro;European Euro
|
||||||
|
USD;$;US Dollar;United States Dollar
|
||||||
|
CAD;$;Canadian Dollar;Canadian Dollar
|
||||||
|
AUD;$;Australian Dollar;Australian Dollar
|
||||||
|
GBP;£;Pound;Great Britain Pound
|
||||||
|
ILS;₪;Shekel;Israeli New Shekel
|
||||||
|
13
packages/bookshop/db/data/sap.common-Currencies_texts.csv
Normal file
13
packages/bookshop/db/data/sap.common-Currencies_texts.csv
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
code;locale;name;descr
|
||||||
|
EUR;de;Euro;European Euro
|
||||||
|
USD;de;US-Dollar;United States Dollar
|
||||||
|
CAD;de;Kanadischer Dollar;Kanadischer Dollar
|
||||||
|
AUD;de;Australischer Dollar;Australischer Dollar
|
||||||
|
GBP;de;Pfund;Britische Pfund
|
||||||
|
ILS;de;Schekel;Israelische Schekel
|
||||||
|
EUR;fr;euro;de la Zone euro
|
||||||
|
USD;fr;dollar;dollar des États-Unis
|
||||||
|
CAD;fr;dollar canadien;dollar canadien
|
||||||
|
AUD;fr;dollar australien;dollar australien
|
||||||
|
GBP;fr;livre sterling;pound sterling
|
||||||
|
ILS;fr;Shekel;shekel israelien
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +1,35 @@
|
|||||||
namespace sap.capire.bookshop;
|
namespace sap.capire.bookshop;
|
||||||
using { Currency, managed } from '@sap/cds/common';
|
using { Currency, managed, cuid } from '@sap/cds/common';
|
||||||
|
|
||||||
entity Books : managed, additionalInfo {
|
entity Books : managed {
|
||||||
key ID : Integer;
|
key ID : Integer;
|
||||||
title : localized String(111);
|
title : localized String(111);
|
||||||
descr : localized String(1111);
|
descr : localized String(1111);
|
||||||
author : Association to Authors;
|
author : Association to Authors;
|
||||||
stock : Integer;
|
stock : Integer;
|
||||||
price : Decimal(9,2);
|
price : Decimal(9,2);
|
||||||
currency : Currency;
|
currency : Currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Authors : managed {
|
entity Authors : managed {
|
||||||
key ID : Integer;
|
key ID : Integer;
|
||||||
name : String(111);
|
name : String(111);
|
||||||
books : Association to many Books on books.author = $self;
|
dateOfBirth : Date;
|
||||||
|
dateOfDeath : Date;
|
||||||
|
placeOfBirth : String;
|
||||||
|
placeOfDeath : String;
|
||||||
|
books : Association to many Books on books.author = $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Orders : managed {
|
entity Orders : cuid, managed {
|
||||||
key ID : UUID;
|
|
||||||
OrderNo : String @title:'Order Number'; //> readable key
|
OrderNo : String @title:'Order Number'; //> readable key
|
||||||
Items : Composition of many OrderItems on Items.parent = $self;
|
Items : Composition of many OrderItems on Items.parent = $self;
|
||||||
|
total : Decimal(9,2) @readonly;
|
||||||
|
currency : Currency;
|
||||||
}
|
}
|
||||||
entity OrderItems {
|
entity OrderItems : cuid {
|
||||||
key ID : UUID;
|
parent : Association to Orders;
|
||||||
parent : Association to Orders;
|
book : Association to Books;
|
||||||
book : Association to Books;
|
amount : Integer;
|
||||||
amount : Integer;
|
netAmount : Decimal(9,2);
|
||||||
}
|
|
||||||
|
|
||||||
entity Movies: additionalInfo {
|
|
||||||
key ID : Integer;
|
|
||||||
name : String(111);
|
|
||||||
}
|
|
||||||
|
|
||||||
aspect additionalInfo{
|
|
||||||
genre: String(100);
|
|
||||||
language: String(200);
|
|
||||||
}
|
}
|
||||||
|
|||||||
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
94
packages/bookshop/mta.yaml
Normal file
94
packages/bookshop/mta.yaml
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
####### 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
|
||||||
|
- name: capire-bookshop-uaa
|
||||||
|
|
||||||
|
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
|
||||||
|
- 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:
|
||||||
|
##### 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:
|
||||||
|
service: hanatrial
|
||||||
|
properties:
|
||||||
|
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
|
||||||
|
############################################################
|
||||||
@@ -1,14 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "bookshop",
|
"name": "@sap/capire-bookshop",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple CAP project.",
|
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||||
"repository": "<Add your repository here>",
|
"license": "SAP SAMPLE CODE LICENSE",
|
||||||
"license": "ISC",
|
"dependencies": {
|
||||||
"dependencies": {
|
"@sap/cds": "^4",
|
||||||
"@sap/cds": "^3",
|
"express": "^4",
|
||||||
"express": "^4"
|
"hdb": "^0.18.1",
|
||||||
},
|
"passport": "^0.4.1"
|
||||||
"scripts": {
|
},
|
||||||
"start": "npx cds run"
|
"scripts": {
|
||||||
}
|
"start": "cds run --in-memory?",
|
||||||
|
"watch": "cds watch"
|
||||||
|
},
|
||||||
|
"cds": {
|
||||||
|
"requires": {
|
||||||
|
"db": {
|
||||||
|
"kind": "sql",
|
||||||
|
"[production]": {
|
||||||
|
"kind": "hana"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uaa": {
|
||||||
|
"kind": "xsuaa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
### Submit Orders
|
|
||||||
POST http://localhost:4004/browse/Orders
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{ "OrderNo":"2019-09...", "Items":[
|
|
||||||
{ "book_ID":201, "amount":5 }
|
|
||||||
]}
|
|
||||||
|
|
||||||
# Sending this three times should result in a 409: 5 exceeds stock for book #201
|
|
||||||
|
|
||||||
### Check books entity that stock was reduced
|
|
||||||
GET http://localhost:4004/admin/Books(201)
|
|
||||||
BIN
packages/bookshop/sqlite.db
Normal file
BIN
packages/bookshop/sqlite.db
Normal file
Binary file not shown.
@@ -1,7 +1,20 @@
|
|||||||
using { sap.capire.bookshop as my } from '../db/schema';
|
using { sap.capire.bookshop as my } from '../db/schema';
|
||||||
service AdminService @(_requires:'admin') {
|
|
||||||
|
service AdminService @(_requires:'authenticated-user') {
|
||||||
entity Books as projection on my.Books;
|
entity Books as projection on my.Books;
|
||||||
entity Movies as projection on my.Movies;
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable Fiori Draft for Orders
|
||||||
|
annotate AdminService.Orders with @odata.draft.enabled;
|
||||||
|
// annotate AdminService.Books with @odata.draft.enabled;
|
||||||
|
|
||||||
|
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121
|
||||||
|
extend service AdminService with {
|
||||||
|
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)
|
||||||
|
}
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
using { sap.capire.bookshop as my } from '../db/schema';
|
using { sap.capire.bookshop as my } from '../db/schema';
|
||||||
service CatalogService @(path:'/browse') {
|
|
||||||
|
@path:'/browse'
|
||||||
|
service CatalogService {
|
||||||
|
|
||||||
@readonly entity Books as SELECT from my.Books {*,
|
@readonly entity Books as SELECT from my.Books {*,
|
||||||
author.name as author
|
author.name as author
|
||||||
} 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' }
|
||||||
|
]);
|
||||||
@@ -1,28 +1,33 @@
|
|||||||
/**
|
const cds = require('@sap/cds')
|
||||||
* Implementation for CatalogService defined in ./cat-service.cds
|
const { Books } = cds.entities
|
||||||
*/
|
|
||||||
module.exports = (srv)=>{
|
|
||||||
|
|
||||||
// Use reflection to get the csn definition of Books
|
/** Service implementation for CatalogService */
|
||||||
const {Books} = cds.entities
|
module.exports = cds.service.impl(function() {
|
||||||
|
this.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
|
||||||
|
this.before ('CREATE', 'Orders', _reduceStock)
|
||||||
|
})
|
||||||
|
|
||||||
// Add some discount for overstocked books
|
/** Add some discount for overstocked books */
|
||||||
srv.after ('READ','Books', (each)=>{
|
function _addDiscount2 (each,discount) {
|
||||||
if (each.stock > 111) each.title += ' -- 11% discount!'
|
each.title += ` -- ${discount}% discount!`
|
||||||
})
|
}
|
||||||
|
|
||||||
// Reduce stock of books upon incoming orders
|
/** Reduce stock of ordered books if available stock suffices */
|
||||||
srv.before ('CREATE','Orders', async (req)=>{
|
async function _reduceStock (req) {
|
||||||
const tx = cds.transaction(req), order = req.data;
|
const { Items: orderItems } = req.data
|
||||||
if (order.Items) {
|
if (!Array.isArray(orderItems)) return
|
||||||
const affectedRows = await tx.run(order.Items.map(item =>
|
|
||||||
UPDATE(Books) .where({ID:item.book_ID})
|
const all = await cds.transaction(req).run(orderItems.map(item =>
|
||||||
.and(`stock >=`, item.amount)
|
UPDATE(Books)
|
||||||
.set(`stock -=`, item.amount)
|
.set('stock -=', item.amount)
|
||||||
)
|
.where('ID =', item.book_ID).and('stock >=', item.amount)
|
||||||
)
|
))
|
||||||
if (affectedRows.some(row => !row)) req.error(409, 'Sold out, sorry')
|
all.forEach((affectedRows, i) => {
|
||||||
|
if (affectedRows === 0) {
|
||||||
|
req.error(409, `${orderItems[i].amount} exceeds stock for book #${orderItems[i].book_ID}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return all
|
||||||
|
|
||||||
}
|
}
|
||||||
18
packages/bookshop/tests/bookshop.http
Normal file
18
packages/bookshop/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
packages/bookshop/tests/orders.http
Normal file
18
packages/bookshop/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
|
||||||
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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user