Compare commits
12 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27ed4b7af2 | ||
|
|
0601038f0f | ||
|
|
e657e2c398 | ||
|
|
f7a5809576 | ||
|
|
64adf115f3 | ||
|
|
b7aee4e0e0 | ||
|
|
13480ad99e | ||
|
|
8071faa62d | ||
|
|
9ea294586a | ||
|
|
a56a11ff3e | ||
|
|
b4084b45cb | ||
|
|
26e3c0d753 |
2
.npmrc
2
.npmrc
@@ -1 +1 @@
|
|||||||
registry=https://registry.npmjs.org
|
@sap:registry=https://npm.sap.com
|
||||||
39
.vscode/launch.json
vendored
39
.vscode/launch.json
vendored
@@ -5,45 +5,18 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "bookshop",
|
"name": "bookshop", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
||||||
"request": "launch",
|
"args": [ "--", "cds", "run", "--in-memory" ],
|
||||||
"type": "node",
|
|
||||||
"runtimeExecutable": "npx",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"-n"
|
|
||||||
],
|
|
||||||
"args": [
|
|
||||||
"--",
|
|
||||||
"cds",
|
|
||||||
"run",
|
|
||||||
"--in-memory"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/packages/bookshop",
|
"cwd": "${workspaceFolder}/packages/bookshop",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"skipFiles": [
|
"skipFiles": ["<node_internals>/**"]
|
||||||
"<node_internals>/**"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cds run ...",
|
"name": "cds run ...", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
||||||
"request": "launch",
|
"args": [ "--", "cds", "run", "--with-mocks", "--in-memory?" ],
|
||||||
"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": [
|
"skipFiles": ["<node_internals>/**"]
|
||||||
"<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-week3-unit5
|
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week2-unit2
|
||||||
cd projects/cloud-cap-samples
|
cd projects/cloud-cap-samples
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -25,87 +25,11 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "deploy",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/hdi-deploy": "^3.8.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^8"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
848
package-lock.json
generated
848
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
|||||||
"bookshop": "cds watch packages/bookshop"
|
"bookshop": "cds watch packages/bookshop"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^4",
|
"@sap/cds": "^3",
|
||||||
"express": "^4"
|
"express": "^4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
{
|
|
||||||
"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
29
packages/bookshop/.vscode/launch.json
vendored
@@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"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\"}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
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}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
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 */
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
{
|
|
||||||
"_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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
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:' '},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
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 */
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
{
|
|
||||||
"_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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
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}';
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<!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>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
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';
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
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'},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
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 */
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
{
|
|
||||||
"_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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "capire-bookshop-approuter",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"description": "",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/approuter": "^8"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"welcomeFile": "/fiori.html",
|
|
||||||
"authenticationMethod": "route",
|
|
||||||
"routes": [
|
|
||||||
{
|
|
||||||
"source": "^/.*(html|js)$",
|
|
||||||
"localDir": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "^/sapui5/.*",
|
|
||||||
"localDir": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "^/.*/webapp/.*",
|
|
||||||
"localDir": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/",
|
|
||||||
"destination": "srv-binding"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "deploy",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/hdi-deploy": "^3.8.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^12"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
namespace sap.capire.bookshop;
|
namespace sap.capire.bookshop;
|
||||||
using { Currency, managed, cuid } from '@sap/cds/common';
|
using { Currency, managed, cuid } from '@sap/cds/common';
|
||||||
|
using { sap.capire.products.Products } from '../../products';
|
||||||
|
|
||||||
|
/*
|
||||||
entity Books : managed {
|
entity Books : managed {
|
||||||
key ID : Integer;
|
key ID : Integer;
|
||||||
title : localized String(111);
|
title : localized String(111);
|
||||||
@@ -9,6 +11,14 @@ entity Books : managed {
|
|||||||
stock : Integer;
|
stock : Integer;
|
||||||
price : Decimal(9,2);
|
price : Decimal(9,2);
|
||||||
currency : Currency;
|
currency : Currency;
|
||||||
|
} */
|
||||||
|
|
||||||
|
entity Books : Products {
|
||||||
|
author : Association to Authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Magazines : Products {
|
||||||
|
publisher : String;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Authors : managed {
|
entity Authors : managed {
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
####### 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
|
|
||||||
############################################################
|
|
||||||
@@ -4,10 +4,8 @@
|
|||||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
"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",
|
"license": "SAP SAMPLE CODE LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^4",
|
"@sap/cds": "^3",
|
||||||
"express": "^4",
|
"express": "^4"
|
||||||
"hdb": "^0.18.1",
|
|
||||||
"passport": "^0.4.1"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "cds run --in-memory?",
|
"start": "cds run --in-memory?",
|
||||||
@@ -16,13 +14,7 @@
|
|||||||
"cds": {
|
"cds": {
|
||||||
"requires": {
|
"requires": {
|
||||||
"db": {
|
"db": {
|
||||||
"kind": "sql",
|
"kind": "sql"
|
||||||
"[production]": {
|
|
||||||
"kind": "hana"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"uaa": {
|
|
||||||
"kind": "xsuaa"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -10,11 +10,7 @@ service AdminService @(_requires:'authenticated-user') {
|
|||||||
annotate AdminService.Orders with @odata.draft.enabled;
|
annotate AdminService.Orders with @odata.draft.enabled;
|
||||||
// annotate AdminService.Books with @odata.draft.enabled;
|
// annotate AdminService.Books with @odata.draft.enabled;
|
||||||
|
|
||||||
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121
|
// Temporary workaround -> cap/issues#3121
|
||||||
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' }
|
|
||||||
]);
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/** 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,10 +8,6 @@ service CatalogService {
|
|||||||
} excluding { createdBy, modifiedBy };
|
} excluding { createdBy, modifiedBy };
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
entity Orders as projection on my.Orders;
|
@insertonly 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,20 +14,13 @@ 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
|
||||||
if (!Array.isArray(orderItems)) return
|
return cds.transaction(req) .run (()=> OrderItems.map (order =>
|
||||||
|
UPDATE (Books) .set ('stock -=', order.amount)
|
||||||
const all = await cds.transaction(req).run(orderItems.map(item =>
|
.where ('ID =', order.book_ID) .and ('stock >=', order.amount)
|
||||||
UPDATE(Books)
|
)) .then (all => all.forEach ((affectedRows,i) => {
|
||||||
.set('stock -=', item.amount)
|
if (affectedRows === 0) req.error (409,
|
||||||
.where('ID =', item.book_ID).and('stock >=', item.amount)
|
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||||
))
|
)
|
||||||
all.forEach((affectedRows, i) => {
|
}))
|
||||||
if (affectedRows === 0) {
|
|
||||||
req.error(409, `${orderItems[i].amount} exceeds stock for book #${orderItems[i].book_ID}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return all
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
19
packages/products/db/schema.cds
Normal file
19
packages/products/db/schema.cds
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
namespace sap.capire.products;
|
||||||
|
|
||||||
|
using { Currency, managed, sap.common.CodeList } from '@sap/cds/common';
|
||||||
|
|
||||||
|
entity Products : managed {
|
||||||
|
key ID : String;
|
||||||
|
title : localized String(111);
|
||||||
|
descr : localized String(1111);
|
||||||
|
stock : Integer;
|
||||||
|
price : Decimal(9,2);
|
||||||
|
currency : Currency;
|
||||||
|
category : Association to Categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Categories : CodeList {
|
||||||
|
key ID : Integer;
|
||||||
|
parent : Association to Categories;
|
||||||
|
children : Composition of many Categories on children.parent = $self;
|
||||||
|
}
|
||||||
1
packages/products/index.cds
Normal file
1
packages/products/index.cds
Normal file
@@ -0,0 +1 @@
|
|||||||
|
using from './db/schema';
|
||||||
15
packages/products/package.json
Normal file
15
packages/products/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "@sap/products",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A reuse package providing domain models and services to manage product catalogs.",
|
||||||
|
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
||||||
|
"license": "SAP SAMPLE CODE LICENSE",
|
||||||
|
"dependencies": {
|
||||||
|
"@sap/cds": "^3",
|
||||||
|
"express": "^4"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"db",
|
||||||
|
"index.cds"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user