Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding suppliers showing integration with S/4 #196

Draft
wants to merge 112 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
d72ff80
Adding suppliers showing integration with S/4
danjoa Feb 17, 2021
a5c8b51
Make the CatalogService usage more obvious
chgeo Feb 17, 2021
5f176a0
Delete .gitignore
danjoa Feb 17, 2021
796bf62
Delete extensions.json
danjoa Feb 17, 2021
f1d780d
Delete tasks.json
danjoa Feb 17, 2021
f0fead2
Delete launch.json
danjoa Feb 17, 2021
6d3f4c6
Delete settings.json
danjoa Feb 17, 2021
5015eb8
cosmetics
iwonahahn Feb 17, 2021
0aa95a0
cosmetics
iwonahahn Feb 17, 2021
e5bd8ec
cosmetics
iwonahahn Feb 17, 2021
a35782e
Merge branch 'master' into adding-suppliers
danjoa Feb 19, 2021
3320c7e
some corrections and optimizations
danjoa Feb 19, 2021
66bd2f7
Merge branch 'master' into adding-suppliers
danjoa Feb 19, 2021
c23ddc7
Merge branch 'master' into adding-suppliers
danjoa Feb 19, 2021
b44701e
Merge branch 'master' into adding-suppliers
danjoa Mar 8, 2021
3e52a9a
Adding fix-antlr script
danjoa Mar 8, 2021
0ddd70a
Using event : projection on Reviews
danjoa Mar 11, 2021
c672e0f
Merge branch 'master' into adding-suppliers
danjoa Mar 27, 2021
99dc8d3
.
danjoa Mar 27, 2021
2f96b92
.
danjoa Mar 27, 2021
b724ae9
Merge branch 'master' into adding-suppliers
danjoa Mar 27, 2021
7d93036
.
danjoa Mar 27, 2021
c9f7dc6
Merge branch 'master' into adding-suppliers
danjoa Apr 10, 2021
fc08801
Merge branch 'master' into adding-suppliers
danjoa Apr 30, 2021
0d19e56
cosmetic changes
danjoa May 13, 2021
c6239f0
Merged from master
danjoa May 19, 2021
6b08826
Mocking events from SAP S/4HANA
David-Kunz May 18, 2021
adfe170
Convenience
danjoa May 21, 2021
624cea6
running suppliers
danjoa Jun 4, 2021
593228a
cds.events test
danjoa Jun 4, 2021
5e5ace0
Merge branch 'master' into adding-suppliers
danjoa Jun 7, 2021
92a83f7
Update mashup.cds
David-Kunz Jun 7, 2021
944afe3
Using package-lock
danjoa Jun 8, 2021
a54b012
Using file-based-messaging in fiori
danjoa Jun 8, 2021
4bd4446
Async 'served' event
danjoa Jun 8, 2021
4877386
A bit more fault tolerant
David-Kunz Jun 8, 2021
05cdb67
Fixed: books title was missing
danjoa Jun 8, 2021
02f19e2
Simplifying samples
danjoa Jun 8, 2021
edbca44
removed obsolete cds.emit monky patch
danjoa Jun 8, 2021
5ae31f7
Adding suppliers showing integration with S/4
uwe-klinger Apr 16, 2021
4767247
Make the CatalogService usage more obvious
chgeo Feb 17, 2021
e04e9d2
Delete .gitignore
danjoa Feb 17, 2021
2650db4
Delete extensions.json
danjoa Feb 17, 2021
ad385cb
Delete tasks.json
danjoa Feb 17, 2021
5031779
Delete launch.json
danjoa Feb 17, 2021
3f20f4b
Delete settings.json
danjoa Feb 17, 2021
50fd83f
cosmetics
iwonahahn Feb 17, 2021
d21a0e0
cosmetics
iwonahahn Feb 17, 2021
4b48d68
cosmetics
iwonahahn Feb 17, 2021
1b5cc62
some corrections and optimizations
danjoa Feb 19, 2021
43e5f6f
Adding fix-antlr script
danjoa Mar 8, 2021
c899843
Using event : projection on Reviews
danjoa Mar 11, 2021
a4810c3
.
danjoa Mar 27, 2021
0bdf4bb
.
danjoa Mar 27, 2021
87dbb45
.
danjoa Mar 27, 2021
2999c8d
Add todo
uwe-klinger Apr 16, 2021
de806a1
Add example with supplier_ID
uwe-klinger Apr 26, 2021
eb4bc70
Improvements for Supplier replication
uwe-klinger May 3, 2021
98113c4
Own transaction when raising an event
uwe-klinger May 3, 2021
8601bd8
Suppliers moved to bookshop namespace
uwe-klinger May 4, 2021
278258c
Implement eventing
uwe-klinger May 5, 2021
c4bee1f
Fixes and improvements
uwe-klinger May 5, 2021
902afd8
Change event to reflect the real event definition
uwe-klinger May 5, 2021
d04cb80
Updated
uwe-klinger May 7, 2021
0165870
Add suppliers notes app
uwe-klinger May 11, 2021
7ae992c
Implement generic expand and navigation feature
uwe-klinger May 11, 2021
fb5d00b
Improved generic handler remote services
uwe-klinger May 14, 2021
254bb40
Remove monkey patch and profile destination
uwe-klinger May 19, 2021
48ee934
Only profile credentials
uwe-klinger May 19, 2021
5b4210b
Use "db" service to avoid double call of service handlers
uwe-klinger May 19, 2021
9dfe62c
Fixed mocking for last test
uwe-klinger May 20, 2021
c854717
Update mashup.cds
David-Kunz Jun 7, 2021
6b74c23
Async 'served' event
danjoa Jun 8, 2021
0b2182a
Fixed: books title was missing
danjoa Jun 8, 2021
d41a9e1
Simplifying samples
danjoa Jun 8, 2021
9277aa1
removed obsolete cds.emit monky patch
danjoa Jun 8, 2021
6412df7
cosmetic changes
danjoa May 13, 2021
f57ae79
running suppliers
danjoa Jun 4, 2021
5397df5
Remove unwanted file
uwe-klinger Jun 9, 2021
dd28bd0
Minor cleanups
uwe-klinger Jun 9, 2021
4a8379e
Remove notes app
uwe-klinger Jun 9, 2021
d9d7203
Fix unintended diffs
uwe-klinger Jun 9, 2021
c8c10b7
cds.events test
danjoa Jun 4, 2021
80302a0
Remove notes test
uwe-klinger Jun 9, 2021
11c54b2
Fix minor diffs
uwe-klinger Jun 9, 2021
649b9c8
Test script added as requests
uwe-klinger Jun 9, 2021
21359a7
Use type reference
uwe-klinger Jun 9, 2021
8d67c0b
Merged
danjoa Jun 9, 2021
31c110e
added profiles
David-Kunz Jun 10, 2021
5e76c7f
console.log
David-Kunz Jun 10, 2021
4a0db3e
rm sleep
David-Kunz Jun 10, 2021
870f8d0
Add Fiori UI for Book administration
uwe-klinger Jun 11, 2021
097b74d
Adjustments
uwe-klinger Jun 11, 2021
9bbc431
odata-v2 (needs PR) and rm file-based
David-Kunz Jun 11, 2021
86e6983
use enterprise-messaging-shared
David-Kunz Jun 11, 2021
ba3eeff
odata-v2 -> odata otherwise mock won't work
David-Kunz Jun 14, 2021
0cb7349
Cosmetics -> for docs
danjoa Jun 15, 2021
4a8b85f
Added illustrations to ffollow up on workarounds
danjoa Jun 15, 2021
db595a9
better logs
David-Kunz Jun 15, 2021
732b6b0
Add missing profile
uwe-klinger Jun 16, 2021
d2bd4c5
Fix replication error due to removed entity namespace
uwe-klinger Jun 16, 2021
f2877db
Disable search field in value help
uwe-klinger Jun 16, 2021
c6e2fac
mv data
David-Kunz Jun 16, 2021
2b9ceba
illustrations
danjoa Jun 16, 2021
785ecbd
cleaned up code
danjoa Jun 16, 2021
5141df8
better value list
David-Kunz Jun 16, 2021
cabcd40
dot notation in line items
David-Kunz Jun 16, 2021
2e10b1a
after handler
David-Kunz Jun 16, 2021
d977c21
a bit nicer
David-Kunz Jun 16, 2021
e7fbcc1
mv annotation to better place
David-Kunz Jun 16, 2021
8ba8381
dash to dot
David-Kunz Jun 18, 2021
67643b8
merged from master
danjoa Jul 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,35 @@ In case you've a question, find a bug, or otherwise need support, use our [commu
## License

Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE.txt) file.

# Suppliers - in progress for Messaging & Service Consumption -

## TODOs

1. Fix issues when running in same process
2. Automated tests

## Usage

1. Run:

```
CDS_ENV=local-hybrid cds mock API_BUSINESS_PARTNER -p 5001
```

2. Wait until startup is completed
3. Run in a 2nd terminal:

```
CDS_ENV=local-hybrid cds serve all --with-mocks --in-memory
```

4. Now, you can issues the requests listed in `suppliers/requests.http`

## Request Sequence

* TODO
## URLs

* Get books with their replicated supplier: http://localhost:4004/browse/Books?$expand=supplier
* Get remote suppliers: http://localhost:4004/admin/Suppliers?$top=11
5 changes: 3 additions & 2 deletions bookshop/srv/cat-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ using { sap.capire.bookshop as my } from '../db/schema';
service CatalogService @(path:'/browse') {

/** For displaying lists of Books */
@readonly entity ListOfBooks as projection on Books
excluding { descr };
@readonly entity ListOfBooks as projection on Books {
ID, title, author, genre, price, currency
}

/** For display in details pages */
@readonly entity Books as projection on my.Books { *,
Expand Down
2 changes: 1 addition & 1 deletion fiori/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# cds.requires.messaging.kind = file-based-messaging
cds.requires.messaging.kind = file-based-messaging
PORT = 4004
3 changes: 0 additions & 3 deletions fiori/app/bookshop.html

This file was deleted.

3 changes: 0 additions & 3 deletions fiori/app/reviews.html

This file was deleted.

11 changes: 8 additions & 3 deletions fiori/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "1.0.0",
"dependencies": {
"@capire/bookshop": "*",
"@capire/reviews": "*",
"@capire/orders": "*",
"@capire/common": "*",
"@sap/cds": "^5",
"@capire/orders": "*",
"@capire/reviews": "*",
"@capire/suppliers": "*",
"@sap/cds": ">=5",
"express": "^4.17.1",
"passport": "^0.4.1"
},
Expand All @@ -19,6 +20,10 @@
"deploy-format": "hdbtable"
},
"requires": {
"API_BUSINESS_PARTNER": {
"kind": "odata",
"model": "@capire/suppliers"
},
"auth": {
"strategy": "dummy"
},
Expand Down
17 changes: 5 additions & 12 deletions fiori/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@ const cds = require ('@sap/cds')
module.exports = cds.server

cds.once('bootstrap',(app)=>{
app.use ('/orders/webapp', _from('@capire/orders/app/orders/webapp/manifest.json'))
app.use ('/bookshop', _from('@capire/bookshop/app/vue/index.html'))
app.use ('/reviews', _from('@capire/reviews/app/vue/index.html'))
app.serve ('/orders/webapp').from('@capire/orders','app/orders/webapp')
app.serve ('/bookshop').from('@capire/bookshop','app/vue')
app.serve ('/reviews').from('@capire/reviews','app/vue')
})

cds.once('served', require('./srv/mashup'))
cds.once('served', require('@capire/suppliers/srv/mashup'))

// Swagger UI - see https://cap.cloud.sap/docs/advanced/openapi
if (process.env.NODE_ENV !== 'production') {
const cds_swagger = require ('cds-swagger-ui-express')
cds.once ('bootstrap', app => app.use (cds_swagger()) )
cds.once ('bootstrap', app => app.use (require ('cds-swagger-ui-express')()) )
}


// -----------------------------------------------------------------------
// Helper for serving static content from npm-installed packages
const {static} = require('express')
const {dirname} = require('path')
const _from = target => static (dirname (require.resolve(target)))
6 changes: 3 additions & 3 deletions fiori/srv/mashup.cds
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
// Mashing up imported models...
//

using { sap.capire.bookshop.Books } from '@capire/bookshop';

//
// Extend Books with access to Reviews and average ratings
//

using { CatalogService.ListOfBooks, sap.capire.bookshop.Books } from '@capire/bookshop';
using { ReviewsService.Reviews } from '@capire/reviews';
extend Books with {
reviews : Composition of many Reviews on reviews.subject = $self.ID;
rating : Decimal;
rating : Reviews:rating;
}
extend projection ListOfBooks with { rating }

//
// Extend Orders with Books as Products
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@capire/media": "./media",
"@capire/orders": "./orders",
"@capire/reviews": "./reviews",
"@capire/suppliers": "./suppliers",
"@sap/cds": "^5",
"express": "^4"
},
Expand Down
6 changes: 3 additions & 3 deletions reviews/srv/reviews-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ service ReviewsService {
action unlike (review: type of Reviews:ID);

// Async API
event reviewed : {
subject: type of Reviews:subject;
rating: Decimal(2,1)
event reviewed : projection on Reviews {
subject, //> recieved new reviews
rating //> new avg rating
}

// Input validation
Expand Down
2 changes: 2 additions & 0 deletions reviews/test/bookshop/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cds.requires.messaging.kind = file-based-messaging
PORT = 4004
19 changes: 19 additions & 0 deletions reviews/test/bookshop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@capire/fiori",
"version": "1.0.0",
"dependencies": {
"@capire/bookshop": "*",
"@capire/reviews": "*",
"@sap/cds": "^5",
"express": "^4.17.1"
},
"cds": {
"requires": {
"auth": { "strategy": "dummy" },
"ReviewsService": {
"kind": "odata",
"model": "@capire/reviews"
}
}
}
}
20 changes: 20 additions & 0 deletions reviews/test/bookshop/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const cds = require ('@sap/cds')

cds.once('bootstrap',(app)=>{
// Delegate to imported apps (reviews only when mocked)
app.serve ('/bookshop').from ('@capire/bookshop','app/vue')
app.serve ('/reviews',).from ('@capire/reviews','app/vue')
})

cds.once('served', async ()=>{
// Update Books' average ratings when ReviewsService signals updated reviews
const ReviewsService = await cds.connect.to ('ReviewsService')
ReviewsService.on ('reviewed', (msg) => {
console.debug ('> received:', msg.event, msg.data)
const { subject, rating } = msg.data
return UPDATE('Books',subject).with({rating})
})

})

module.exports = cds.server
11 changes: 11 additions & 0 deletions reviews/test/bookshop/services.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace sap.capire.bookshop; //> allows UPDATE('Books')...
//
// Extend Books with access to Reviews and average ratings
//
using { CatalogService.ListOfBooks, sap.capire.bookshop.Books } from '@capire/bookshop';
using { ReviewsService.Reviews } from '@capire/reviews';
extend Books with {
reviews : Composition of many Reviews on reviews.subject = $self.ID;
rating : Reviews:rating;
}
extend projection ListOfBooks with { rating }
12 changes: 10 additions & 2 deletions samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@ Each sub directory essentially is an individual npm package arranged in an [all-
- Late-cut Micro Services
- As well as managed data, input validations, and authorization

## [@capire/suppliers](suppliers)

- Shows how to integrate remote services, in this case the BusinessPartner service from SAP S/4HANA.
- Extending [@capire/bookshop](bookshop) with suppliers from SAP S/4HANA
- Providing that as a pre-built integration & extension package
- Used in [@capire/fiori](fiori)


## [@capire/fiori](fiori)

- A [composite app, reusing and combining](https://cap.cloud.sap/docs/guides/verticalize) these packages:
- [@capire/bookshop](bookshop)
- [@capire/reviews](reviews)
- [@capire/orders](orders)
- [@capire/common](common)
- [@capire/orders](orders)
- [@capire/reviews](reviews)
- [@capire/suppliers](suppliers)
- [Adds an SAP Fiori elements application](https://cap.cloud.sap/docs/guides/fiori/) to bookshop, thereby introducing to:
- [OData Annotations](https://cap.cloud.sap/docs/guides/fiori#adding-odata-annotations) in `.cds` files
- Support for [Fiori Draft](https://cap.cloud.sap/docs/guides/fiori#draft)
Expand Down
1 change: 1 addition & 0 deletions suppliers/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT = 4006
31 changes: 31 additions & 0 deletions suppliers/app/_i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Books = Books
Book = Book
ID = ID
Title = Title
Author = Author
AuthorID = Author ID
Stock = Stock
Name = Name
AuthorName = Author's Name
DateOfBirth = Date of Birth
DateOfDeath = Date of Death
PlaceOfBirth = Place of Birth
PlaceOfDeath = Place of Death
Age = Age
Authors = Authors
Order = Order
Orders = Orders
Price = Price

Genre = Genre
Genres = Genres
SubGenres = Sub Genres

NumCode = Numeric Code
MinorUnit = Minor Unit
Exponent = Exponent

Supplier = Supplier
SupplierName = Supplier Name
Id = Id
Name = Name
18 changes: 18 additions & 0 deletions suppliers/app/_i18n/i18n_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Books = Bücher
Book = Buch
ID = ID
Title = Titel
Authors = Autoren
Author = Autor
AuthorID = ID des Autors
AuthorName = Name des Autors
Age = Alter
Name = Name
Stock = Bestand
Order = Bestellung
Orders = Bestellungen
Price = Preis
Supplier = Lieferant
SupplierName = Lieferantenname
Id = Id
Name = Name
55 changes: 55 additions & 0 deletions suppliers/app/admin-fiori.html
Original file line number Diff line number Diff line change
@@ -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: "w/ SAP Fiori Elements",
additionalInformation: "SAPUI5.Component=bookshop",
applicationType : "URL",
url: "/browse/webapp",
navigationMode: "embedded"
},
"manage-books": {
title: "Manage Books",
description: "w/ SAP Fiori Elements",
additionalInformation: "SAPUI5.Component=admin",
applicationType : "URL",
url: "/admin/webapp",
navigationMode: "embedded"
},
"manage-orders": {
title: "Manage Orders",
description: "w/ SAP Fiori Elements",
additionalInformation: "SAPUI5.Component=orders",
applicationType : "URL",
url: "/orders/webapp",
navigationMode: "embedded"
}
}
};
</script>

<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
<script id="sap-ui-bootstrap" 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>
Loading