From c458bf0f470ed5be0a7bd4170fb85607b3a834a0 Mon Sep 17 00:00:00 2001 From: Wolfgang Koch Date: Fri, 30 Apr 2021 11:13:14 +0200 Subject: [PATCH] rebuild sample to self cont --- fiori/.env | 2 - fiori/app/_i18n/i18n.properties | 26 -- fiori/app/_i18n/i18n_de.properties | 14 - fiori/app/admin-fiori.html | 55 ---- fiori/app/admin/fiori-service.cds | 93 ------- fiori/app/admin/webapp/Component.js | 8 - fiori/app/admin/webapp/i18n/i18n.properties | 11 - fiori/app/admin/webapp/manifest.json | 128 --------- fiori/app/bookshop.html | 3 - fiori/app/browse/fiori-service.cds | 50 ---- fiori/app/browse/webapp/Component.js | 7 - fiori/app/browse/webapp/i18n/i18n.properties | 11 - fiori/app/browse/webapp/manifest.json | 106 -------- fiori/app/common.cds | 257 ------------------ fiori/app/reviews.html | 3 - fiori/app/services.cds | 12 - fiori/db/hana/index.cds | 10 - fiori/db/schema.cds | 8 - fiori/db/sqlite/index.cds | 10 - fiori/package.json | 44 --- fiori/server.js | 18 -- fiori/srv/mashup.cds | 25 -- fiori/srv/mashup.js | 59 ---- fiori/test/requests.http | 77 ------ logs_recent_2.txt | Bin 0 -> 6766 bytes logs_recent_3.txt | Bin 0 -> 280916 bytes .../db/data/sap.capire.bookshop-Authors.csv | 5 + .../db/data/sap.capire.bookshop-Books.csv | 6 + .../data/sap.capire.bookshop-Books_texts.csv | 5 + .../db/data/sap.capire.bookshop-Genres.csv | 16 ++ .../db/data/sap.capire.orders-Orders.csv | 3 + .../data/sap.capire.orders-Orders_Items.csv | 4 + multitenancy/db/schema.cds | 7 +- multitenancy/db/schema_bookshop.cds | 31 +++ multitenancy/db/schema_orders.cds | 23 ++ multitenancy/package-lock.json | 18 +- multitenancy/package.json | 158 +++++------ multitenancy/package_simple.json | 52 ++++ multitenancy/recent_logs.txt | Bin 0 -> 294208 bytes multitenancy/server.js | 2 + multitenancy/srv/admin-service.cds | 7 + multitenancy/srv/admin-service.js | 12 + multitenancy/srv/cat-service.cds | 16 ++ multitenancy/srv/cat-service.js | 26 ++ multitenancy/srv/multitenancy-service.cds | 15 - multitenancy/srv/orders-service.cds | 5 + multitenancy/srv/orders-service.js | 37 +++ package.json | 4 +- 48 files changed, 335 insertions(+), 1154 deletions(-) delete mode 100644 fiori/.env delete mode 100644 fiori/app/_i18n/i18n.properties delete mode 100644 fiori/app/_i18n/i18n_de.properties delete mode 100644 fiori/app/admin-fiori.html delete mode 100644 fiori/app/admin/fiori-service.cds delete mode 100644 fiori/app/admin/webapp/Component.js delete mode 100644 fiori/app/admin/webapp/i18n/i18n.properties delete mode 100644 fiori/app/admin/webapp/manifest.json delete mode 100644 fiori/app/bookshop.html delete mode 100644 fiori/app/browse/fiori-service.cds delete mode 100644 fiori/app/browse/webapp/Component.js delete mode 100644 fiori/app/browse/webapp/i18n/i18n.properties delete mode 100644 fiori/app/browse/webapp/manifest.json delete mode 100644 fiori/app/common.cds delete mode 100644 fiori/app/reviews.html delete mode 100644 fiori/app/services.cds delete mode 100644 fiori/db/hana/index.cds delete mode 100644 fiori/db/schema.cds delete mode 100644 fiori/db/sqlite/index.cds delete mode 100644 fiori/package.json delete mode 100644 fiori/server.js delete mode 100644 fiori/srv/mashup.cds delete mode 100644 fiori/srv/mashup.js delete mode 100644 fiori/test/requests.http create mode 100644 logs_recent_2.txt create mode 100644 logs_recent_3.txt create mode 100644 multitenancy/db/data/sap.capire.bookshop-Authors.csv create mode 100644 multitenancy/db/data/sap.capire.bookshop-Books.csv create mode 100644 multitenancy/db/data/sap.capire.bookshop-Books_texts.csv create mode 100644 multitenancy/db/data/sap.capire.bookshop-Genres.csv create mode 100644 multitenancy/db/data/sap.capire.orders-Orders.csv create mode 100644 multitenancy/db/data/sap.capire.orders-Orders_Items.csv create mode 100644 multitenancy/db/schema_bookshop.cds create mode 100644 multitenancy/db/schema_orders.cds create mode 100644 multitenancy/package_simple.json create mode 100644 multitenancy/recent_logs.txt create mode 100644 multitenancy/srv/admin-service.cds create mode 100644 multitenancy/srv/admin-service.js create mode 100644 multitenancy/srv/cat-service.cds create mode 100644 multitenancy/srv/cat-service.js delete mode 100644 multitenancy/srv/multitenancy-service.cds create mode 100644 multitenancy/srv/orders-service.cds create mode 100644 multitenancy/srv/orders-service.js diff --git a/fiori/.env b/fiori/.env deleted file mode 100644 index 36644fa6..00000000 --- a/fiori/.env +++ /dev/null @@ -1,2 +0,0 @@ -# cds.requires.messaging.kind = file-based-messaging -PORT = 4004 \ No newline at end of file diff --git a/fiori/app/_i18n/i18n.properties b/fiori/app/_i18n/i18n.properties deleted file mode 100644 index 83681bcf..00000000 --- a/fiori/app/_i18n/i18n.properties +++ /dev/null @@ -1,26 +0,0 @@ -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 \ No newline at end of file diff --git a/fiori/app/_i18n/i18n_de.properties b/fiori/app/_i18n/i18n_de.properties deleted file mode 100644 index 7724f685..00000000 --- a/fiori/app/_i18n/i18n_de.properties +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/fiori/app/admin-fiori.html b/fiori/app/admin-fiori.html deleted file mode 100644 index 6c229e6b..00000000 --- a/fiori/app/admin-fiori.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - Bookshop - - - - - - - - - - \ No newline at end of file diff --git a/fiori/app/admin/fiori-service.cds b/fiori/app/admin/fiori-service.cds deleted file mode 100644 index 8e97fdbe..00000000 --- a/fiori/app/admin/fiori-service.cds +++ /dev/null @@ -1,93 +0,0 @@ -using { AdminService } from '../../db/schema'; - -//////////////////////////////////////////////////////////////////////////// -// -// Books Object Page -// - -annotate AdminService.Books with @( - UI: { - Facets: [ - {$Type: 'UI.ReferenceFacet', Label: '{i18n>General}', Target: '@UI.FieldGroup#General'}, - {$Type: 'UI.ReferenceFacet', Label: '{i18n>Translations}', Target: 'texts/@UI.LineItem'}, - {$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: genre_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} - ] - } - } -); - -annotate AdminService.Authors with @( - UI: { - HeaderInfo: { - Description: {Value: lifetime} - }, - Facets: [ - {$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'}, - {$Type: 'UI.ReferenceFacet', Label: '{i18n>Books}', Target: 'books/@UI.LineItem'}, - ], - FieldGroup#Details: { - Data: [ - {Value: placeOfBirth}, - {Value: placeOfDeath}, - {Value: dateOfBirth}, - {Value: dateOfDeath}, - {Value: age, Label: '{i18n>Age}'}, - ] - }, - } -); - - - -//////////////////////////////////////////////////////////// -// -// Draft for Localized Data -// - -annotate sap.capire.bookshop.Books with @fiori.draft.enabled; -annotate AdminService.Books with @odata.draft.enabled; - -annotate AdminService.Books_texts with @( - UI: { - Identification: [{Value:title}], - SelectionFields: [ locale, title ], - LineItem: [ - {Value: locale, Label: 'Locale'}, - {Value: title, Label: 'Title'}, - {Value: descr, Label: 'Description'}, - ] - } -); - -// Add Value Help for Locales -annotate AdminService.Books_texts { - locale @ValueList:{entity:'Languages',type:#fixed} -} -// In addition we need to expose Languages through AdminService -using { sap } from '@sap/cds/common'; -extend service AdminService { - entity Languages as projection on sap.common.Languages; -} diff --git a/fiori/app/admin/webapp/Component.js b/fiori/app/admin/webapp/Component.js deleted file mode 100644 index c3137017..00000000 --- a/fiori/app/admin/webapp/Component.js +++ /dev/null @@ -1,8 +0,0 @@ -sap.ui.define(["sap/fe/core/AppComponent"], function(AppComponent) { - "use strict"; - return AppComponent.extend("admin.Component", { - metadata: { manifest: "json" } - }); -}); - -/* eslint no-undef:0 */ \ No newline at end of file diff --git a/fiori/app/admin/webapp/i18n/i18n.properties b/fiori/app/admin/webapp/i18n/i18n.properties deleted file mode 100644 index 28b03dff..00000000 --- a/fiori/app/admin/webapp/i18n/i18n.properties +++ /dev/null @@ -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 diff --git a/fiori/app/admin/webapp/manifest.json b/fiori/app/admin/webapp/manifest.json deleted file mode 100644 index 25047c29..00000000 --- a/fiori/app/admin/webapp/manifest.json +++ /dev/null @@ -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.templates": {} - } - }, - "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" - } -} \ No newline at end of file diff --git a/fiori/app/bookshop.html b/fiori/app/bookshop.html deleted file mode 100644 index e7c07e25..00000000 --- a/fiori/app/bookshop.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/fiori/app/browse/fiori-service.cds b/fiori/app/browse/fiori-service.cds deleted file mode 100644 index f59a36b4..00000000 --- a/fiori/app/browse/fiori-service.cds +++ /dev/null @@ -1,50 +0,0 @@ -using CatalogService from '@capire/bookshop'; - -//////////////////////////////////////////////////////////////////////////// -// -// Books Object Page -// -annotate CatalogService.Books with @( - UI: { - HeaderInfo: { - TypeName: 'Book', - TypeNamePlural: 'Books', - 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: genre.name}, - {Value: price}, - {Value: currency.symbol, Label:' '}, - ] - }, -); diff --git a/fiori/app/browse/webapp/Component.js b/fiori/app/browse/webapp/Component.js deleted file mode 100644 index 7914d295..00000000 --- a/fiori/app/browse/webapp/Component.js +++ /dev/null @@ -1,7 +0,0 @@ -sap.ui.define(["sap/fe/core/AppComponent"], function(AppComponent) { - "use strict"; - return AppComponent.extend("bookshop.Component", { - metadata: { manifest: "json" } - }); -}); -/* eslint no-undef:0 */ \ No newline at end of file diff --git a/fiori/app/browse/webapp/i18n/i18n.properties b/fiori/app/browse/webapp/i18n/i18n.properties deleted file mode 100644 index 28b03dff..00000000 --- a/fiori/app/browse/webapp/i18n/i18n.properties +++ /dev/null @@ -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 diff --git a/fiori/app/browse/webapp/manifest.json b/fiori/app/browse/webapp/manifest.json deleted file mode 100644 index 4a2e0a62..00000000 --- a/fiori/app/browse/webapp/manifest.json +++ /dev/null @@ -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.templates": {} - } - }, - "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" - } -} diff --git a/fiori/app/common.cds b/fiori/app/common.cds deleted file mode 100644 index 614f03b3..00000000 --- a/fiori/app/common.cds +++ /dev/null @@ -1,257 +0,0 @@ -/* - Common Annotations shared by all apps -*/ - -using { sap.capire.bookshop as my } from '@capire/bookshop'; -using { sap.common } from '@capire/common'; - -//////////////////////////////////////////////////////////////////////////// -// -// Books Lists -// -annotate my.Books with @( - Common.SemanticKey: [title], - UI: { - Identification: [{Value:title}], - SelectionFields: [ ID, author_ID, price, currency_code ], - LineItem: [ - {Value: ID}, - {Value: title}, - {Value: author.name, Label:'{i18n>Author}'}, - {Value: genre.name}, - {Value: stock}, - {Value: price}, - {Value: currency.symbol, Label:' '}, - ] - } -) { - author @ValueList.entity:'Authors'; -}; - -//////////////////////////////////////////////////////////////////////////// -// -// 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}'; - genre @title:'{i18n>Genre}' @Common: { Text: genre.name, TextArrangement: #TextOnly }; - author @title:'{i18n>Author}' @Common: { Text: author.name, TextArrangement: #TextOnly }; - price @title:'{i18n>Price}'; - stock @title:'{i18n>Stock}'; - descr @UI.MultiLineText; -} - -//////////////////////////////////////////////////////////////////////////// -// -// Genres List -// -annotate my.Genres with @( - Common.SemanticKey: [name], - UI: { - SelectionFields: [ name ], - LineItem:[ - {Value: name}, - {Value: parent.name, Label: 'Main Genre'}, - ], - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Genre Details -// -annotate my.Genres with @( - UI: { - Identification: [{Value:name}], - HeaderInfo: { - TypeName: '{i18n>Genre}', - TypeNamePlural: '{i18n>Genres}', - Title: {Value: name}, - Description: {Value: ID} - }, - Facets: [ - {$Type: 'UI.ReferenceFacet', Label: '{i18n>SubGenres}', Target: 'children/@UI.LineItem'}, - ], - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Genres Elements -// -annotate my.Genres with { - ID @title: '{i18n>ID}'; - name @title: '{i18n>Genre}'; -} - -//////////////////////////////////////////////////////////////////////////// -// -// Authors List -// -annotate my.Authors with @( - Common.SemanticKey: [name], - UI: { - Identification: [{Value:name}], - SelectionFields: [ name ], - LineItem:[ - {Value: ID}, - {Value: name}, - {Value: dateOfBirth}, - {Value: dateOfDeath}, - {Value: placeOfBirth}, - {Value: placeOfDeath}, - ], - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Author Details -// -annotate my.Authors with @( - UI: { - HeaderInfo: { - TypeName: '{i18n>Author}', - TypeNamePlural: '{i18n>Authors}', - Title: {Value: name}, - Description: {Value: dateOfBirth} - }, - Facets: [ - {$Type: 'UI.ReferenceFacet', Target: 'books/@UI.LineItem'}, - ], - } -); - - -//////////////////////////////////////////////////////////////////////////// -// -// Authors Elements -// -annotate my.Authors with { - ID @title:'{i18n>ID}' @UI.HiddenFilter; - name @title:'{i18n>Name}'; - dateOfBirth @title:'{i18n>DateOfBirth}'; - dateOfDeath @title:'{i18n>DateOfDeath}'; - placeOfBirth @title:'{i18n>PlaceOfBirth}'; - placeOfDeath @title:'{i18n>PlaceOfDeath}'; -} - -//////////////////////////////////////////////////////////////////////////// -// -// Languages List -// -annotate common.Languages with @( - Common.SemanticKey: [code], - Identification: [{Value:code}], - UI: { - SelectionFields: [ name, descr ], - LineItem:[ - {Value: code}, - {Value: name}, - ], - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Language Details -// -annotate common.Languages with @( - UI: { - HeaderInfo: { - TypeName: '{i18n>Language}', - TypeNamePlural: '{i18n>Languages}', - Title: {Value: name}, - Description: {Value: descr} - }, - Facets: [ - {$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'}, - ], - FieldGroup#Details: { - Data: [ - {Value: code}, - {Value: name}, - {Value: descr} - ] - }, - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Currencies List -// -annotate common.Currencies with @( - Common.SemanticKey: [code], - Identification: [{Value:code}], - UI: { - SelectionFields: [ name, descr ], - LineItem:[ - {Value: descr}, - {Value: symbol}, - {Value: code}, - ], - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Currency Details -// -annotate common.Currencies with @( - UI: { - HeaderInfo: { - TypeName: '{i18n>Currency}', - TypeNamePlural: '{i18n>Currencies}', - Title: {Value: descr}, - Description: {Value: code} - }, - Facets: [ - {$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'}, - {$Type: 'UI.ReferenceFacet', Label: '{i18n>Extended}', Target: '@UI.FieldGroup#Extended'}, - ], - FieldGroup#Details: { - Data: [ - {Value: name}, - {Value: symbol}, - {Value: code}, - {Value: descr} - ] - }, - FieldGroup#Extended: { - Data: [ - {Value: numcode}, - {Value: minor}, - {Value: exponent} - ] - }, - } -); - -//////////////////////////////////////////////////////////////////////////// -// -// Currencies Elements -// -annotate common.Currencies with { - numcode @title:'{i18n>NumCode}'; - minor @title:'{i18n>MinorUnit}'; - exponent @title:'{i18n>Exponent}'; -} diff --git a/fiori/app/reviews.html b/fiori/app/reviews.html deleted file mode 100644 index 75af8860..00000000 --- a/fiori/app/reviews.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/fiori/app/services.cds b/fiori/app/services.cds deleted file mode 100644 index 595023e9..00000000 --- a/fiori/app/services.cds +++ /dev/null @@ -1,12 +0,0 @@ -/* - This model controls what gets served to Fiori frontends... -*/ - -using from './admin/fiori-service'; -using from './browse/fiori-service'; -using from './common'; - -using from '@capire/common'; - -// only works in case of embedded orders service -using from '@capire/orders/app/orders/fiori-service'; diff --git a/fiori/db/hana/index.cds b/fiori/db/hana/index.cds deleted file mode 100644 index 04822ad0..00000000 --- a/fiori/db/hana/index.cds +++ /dev/null @@ -1,10 +0,0 @@ -// -// Add Author.age and .lifetime with a DB-specific function -// - -using { AdminService } from '../schema'; - -extend projection AdminService.Authors with { - YEARS_BETWEEN(dateOfBirth, dateOfDeath) as age: Integer, - YEAR(dateOfBirth) || ' – ' || YEAR(dateOfDeath) as lifetime : String -} diff --git a/fiori/db/schema.cds b/fiori/db/schema.cds deleted file mode 100644 index 479fdbfb..00000000 --- a/fiori/db/schema.cds +++ /dev/null @@ -1,8 +0,0 @@ -using { sap.capire.bookshop } from '@capire/bookshop'; - -// Forward-declare calculated fields to be filled in database-specific ways -// TODO find a better way to have 'default' fields that still can be overwritten. -extend bookshop.Authors with { - virtual age: Integer; - virtual lifetime: String; -} diff --git a/fiori/db/sqlite/index.cds b/fiori/db/sqlite/index.cds deleted file mode 100644 index 019335ef..00000000 --- a/fiori/db/sqlite/index.cds +++ /dev/null @@ -1,10 +0,0 @@ -// -// Add Author.age and .lifetime with a DB-specific function -// - -using { AdminService } from '../schema'; - -extend projection AdminService.Authors with { - strftime('%Y',dateOfDeath)-strftime('%Y',dateOfBirth) as age: Integer, - strftime('%Y',dateOfBirth) || ' – ' || strftime('%Y',dateOfDeath) as lifetime : String -} diff --git a/fiori/package.json b/fiori/package.json deleted file mode 100644 index 55127e9b..00000000 --- a/fiori/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@capire/fiori", - "version": "1.0.0", - "dependencies": { - "@capire/bookshop": "../bookshop", - "@capire/reviews": "../reviews", - "@capire/orders": "../orders", - "@capire/common": "../common", - "@sap/cds": ">=4", - "express": "^4.17.1", - "passport": "^0.4.1" - }, - "scripts": { - "start": "cds run --in-memory?", - "watch": "cds watch" - }, - "cds": { - "hana": { - "deploy-format": "hdbtable" - }, - "requires": { - "auth": { - "strategy": "dummy" - }, - "ReviewsService": { - "kind": "odata", - "model": "@capire/reviews" - }, - "OrdersService": { - "kind": "odata", - "model": "@capire/orders" - }, - "db": { - "kind": "sql", - "[development]": { - "model": "db/sqlite" - }, - "[production]": { - "model": "db/hana" - } - } - } - } -} diff --git a/fiori/server.js b/fiori/server.js deleted file mode 100644 index a8dc4298..00000000 --- a/fiori/server.js +++ /dev/null @@ -1,18 +0,0 @@ -const cds = require ('@sap/cds') - -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')) -}) - -cds.once('served', require('./srv/mashup')) - -module.exports = cds.server - - -// ----------------------------------------------------------------------- -// 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))) diff --git a/fiori/srv/mashup.cds b/fiori/srv/mashup.cds deleted file mode 100644 index 97f21771..00000000 --- a/fiori/srv/mashup.cds +++ /dev/null @@ -1,25 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Mashing up imported models... -// - -using { sap.capire.bookshop.Books } from '@capire/bookshop'; - -// -// Extend Books with access to Reviews and average ratings -// - -using { ReviewsService.Reviews } from '@capire/reviews'; -extend Books with { - reviews : Composition of many Reviews on reviews.subject = $self.ID; - rating : Decimal; -} - -// -// Extend Orders with Books as Products -// - -using { sap.capire.orders.Orders_Items } from '@capire/orders'; -extend Orders_Items with { - book : Association to Books on product.ID = book.ID -} diff --git a/fiori/srv/mashup.js b/fiori/srv/mashup.js deleted file mode 100644 index e8acf174..00000000 --- a/fiori/srv/mashup.js +++ /dev/null @@ -1,59 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Mashing up provided and required services... -// -module.exports = async()=>{ // called by server.js - - const cds = require('@sap/cds') - const CatalogService = await cds.connect.to ('CatalogService') - const ReviewsService = await cds.connect.to ('ReviewsService') - const OrdersService = await cds.connect.to ('OrdersService') - const db = await cds.connect.to ('db') - - // reflect entity definitions used below... - const { Books } = db.entities ('sap.capire.bookshop') - - // - // Delegate requests to read reviews to the ReviewsService - // Note: prepend is neccessary to intercept generic default handler - // - CatalogService.prepend (srv => srv.on ('READ', 'Books/reviews', (req) => { - console.debug ('> delegating request to ReviewsService') - const [id] = req.params, { columns, limit } = req.query.SELECT - return ReviewsService.tx(req).read ('Reviews',columns).limit(limit).where({subject:String(id)}) - })) - - // - // Create an order with the OrdersService when CatalogService signals a new order - // - CatalogService.on ('OrderedBook', async (msg) => { - const { book, amount, buyer } = msg.data - const { title, price } = await db.tx(msg).read (Books, book, b => { b.title, b.price }) - return OrdersService.tx(msg).create ('Orders').entries({ - OrderNo: 'Order at '+ (new Date).toLocaleString(), - Items: [{ product:{ID:`${book}`}, title, price, amount }], - buyer, createdBy: buyer - }) - }) - - // - // Update Books' average ratings when ReviewsService signals updatd reviews - // - ReviewsService.on ('reviewed', (msg) => { - console.debug ('> received:', msg.event, msg.data) - const { subject, rating } = msg.data - return UPDATE(Books,subject).with({rating}) - // ^ Note: the framework will execute this and take care for db.tx - }) - - // - // Reduce stock of ordered books for orders are created from Orders admin UI - // - OrdersService.on ('OrderChanged', (msg) => { - console.debug ('> received:', msg.event, msg.data) - const { product, deltaAmount } = msg.data - return UPDATE (Books) .where ('ID =', product) - .and ('stock >=', deltaAmount) - .set ('stock -=', deltaAmount) - }) -} diff --git a/fiori/test/requests.http b/fiori/test/requests.http deleted file mode 100644 index badacbfe..00000000 --- a/fiori/test/requests.http +++ /dev/null @@ -1,77 +0,0 @@ - -@bookshop = http://localhost:4004 -@reviews-service = {{bookshop}}/reviews -# Uncomment this when running a separate reviews service -@reviews-service = http://localhost:4005/reviews - - - -################################################# -# -# Reviews Service -# - -GET {{reviews-service}}/Reviews - -### - -POST {{reviews-service}}/Reviews -Authorization: Basic {{$processEnv USER}}: -Content-Type: application/json - -{"subject":"201", "title":"boo", "rating":3 } - - - -################################################# -# -# Bookshop Services -# - -GET {{bookshop}}/browse/Books/201/reviews? -&$select=rating,date,title -&$top=3 - -### - -GET {{bookshop}}/browse/Books(201)? -&$select=ID,title,rating -&$expand=reviews - - - -################################################# -# -# Orders Service, incl. draft choreography -# -@newOrderID = e939604c-ab83-4d4f-bdb6-95fe30b3773e - -GET {{bookshop}}/orders/Orders - -### Create order, still inactive -POST {{bookshop}}/orders/Orders -Content-Type: application/json - -{"ID": "{{newOrderID}}"} - -### Get inactive order. We have to specify `IsActiveEntity`. -GET {{bookshop}}/orders/Orders(ID={{newOrderID}},IsActiveEntity=false) - -### Activate order using `.../.draftActivate` -POST {{bookshop}}/orders/Orders(ID={{newOrderID}},IsActiveEntity=false)/OrdersService.draftActivate -Content-Type: application/json - -### Get active order -GET {{bookshop}}/orders/Orders(ID={{newOrderID}},IsActiveEntity=true) - -### Create author -POST {{bookshop}}/admin/Authors -Content-Type: application/json -Authorization: Basic alice: - -{ - "ID": 200, - "name": "William Shakespeare", - "dateOfBirth": "1564-04-26", - "dateOfDeath": "1616-04-23" -} diff --git a/logs_recent_2.txt b/logs_recent_2.txt new file mode 100644 index 0000000000000000000000000000000000000000..5d0ffc50621b88852e51d2a819091134c8954959 GIT binary patch literal 6766 zcmeH~TW`}q5QXO%iC@5rRS5}%V%JGa+JF$fM1lv}sw(0EA^{j4}R$y*|K1r`5Nk|}?U z(b*g`tH3%N$RxMs#ct*KfBZyym)*478e8VucY5m9wzo)YcRpWdtabQ*pB~>H+avdS z{NJ-8yD75s0`&%E(YEb`?+vTaE>ddTw=FPw;o9qz9w_YC5l_H-Y=^c->yuS&mwMg4 zAaQ6P(Im+X4WF;79Wd{JR%H9MPIx1GNBceXj_W(3_Yj@ZQQ$pb4<4hDePDhzBckWV zK7GD~s4z`=I#vT2;d@D`(Pxxx`epx9>K0$>uQ{nRkbBNfJ$vdTs$ie+*TnUmAlsxZ zeVGQ?HM4(;mW&}99WpDwvb8&FUz;iZnVp4@cHCkAKKmcy60kdQq>0@wKv291T&a4< z;0OtES!Y8S2iF`6uB=-Cp#kzbIhnRDts0VThfqxG93A4UZ{N^Su}!#Efmb2uiBC;l&tsz8_JgA zdW0=w*x$vsX1+qV+e7kU<9Szh@kDv9-hLEMd1OUVik0Sr>-al1$=N=Dt9dSDw`fRg zwh2oWt;6jvDvCr&wzSTwr~<-Yjmu9L y;$ozTVUiijG9vXq8OmgF8jbswFGHCwp39t}Oc&YdWhm2K_wr^a)5Z1Q`S1sYJod2w literal 0 HcmV?d00001 diff --git a/logs_recent_3.txt b/logs_recent_3.txt new file mode 100644 index 0000000000000000000000000000000000000000..f86ed80b2553c89f1b1f5cdb26ad47061a18dfb2 GIT binary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dd;3cRnVTmPW z`8M&Ht+;fER}x*q^B%s1+kb@RQ@n1)-&yAA{Dh>I_GOBbRHF|-i>+6hmw;_nJCZnS zDS5K2ABu}(lyeWIB->LwlO^{$XFA+OImmhm>oBIdCEN;@ny-BK2#;poNpAB4Jht#Y z>*!HDm7* z|Be5vp?QekSrcByXT}X@9p*MMsLmYTEJ-k9GO*@o74H+An`Iqnt;H?cVbW?<1m~AikcUEkD4VZx8VL z083wD`769Wi0?hayUqN*ONhEBh>8jRdJw+G=hG(+vYN%V;W$PGYtkFUH19Y+!JSo4 zv8Ol##WkXe$1Bd=`vz^=>-hdrT#GaHeh!k8@awq7W9;Lm)tKNvzQ$VI>yw*r;BlSH zoJC|B`@GXVTa|X5=MgC{`+R%0FaPG8P?|x7?fi0_aUyY%n*U@8Th99~H^+vRcsE|o zSjFs&IRWzq&We17|DWbPNi!m{E&6<}SeGTzpFkc7%Z@5~=vQ6_o&TvH|I>UqW+aKe|B{RR0TpM;bO&Z93#NLpt zea@3D@)?fYwC7>CHfISAaMZX!9y^`+{Ia$0S5S}JvCteHb`hZ|4=jo7Y0R`zmXYpu zpR(p@J4AzJJG4<$MEo9cz#-540_w=c1u(Rzq31 zp-Av==b2+S6nP>gW!`dzVw;nUq1a}0ccwVMp?D=Vuc63u$}?(ThN92YtD)$V)iD(P Oa{DwCeXjGz!~X$$YX{K) literal 0 HcmV?d00001 diff --git a/multitenancy/db/data/sap.capire.bookshop-Authors.csv b/multitenancy/db/data/sap.capire.bookshop-Authors.csv new file mode 100644 index 00000000..f97bfeed --- /dev/null +++ b/multitenancy/db/data/sap.capire.bookshop-Authors.csv @@ -0,0 +1,5 @@ +ID;name;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath +101;Emily Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire +107;Charlotte Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire +150;Edgar Allen Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland +170;Richard Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England \ No newline at end of file diff --git a/multitenancy/db/data/sap.capire.bookshop-Books.csv b/multitenancy/db/data/sap.capire.bookshop-Books.csv new file mode 100644 index 00000000..cb3044aa --- /dev/null +++ b/multitenancy/db/data/sap.capire.bookshop-Books.csv @@ -0,0 +1,6 @@ +ID;title;descr;author_ID;stock;price;currency_code;genre_ID +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;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;11 +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;16 +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;16 +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;13 \ No newline at end of file diff --git a/multitenancy/db/data/sap.capire.bookshop-Books_texts.csv b/multitenancy/db/data/sap.capire.bookshop-Books_texts.csv new file mode 100644 index 00000000..94fa7a18 --- /dev/null +++ b/multitenancy/db/data/sap.capire.bookshop-Books_texts.csv @@ -0,0 +1,5 @@ +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. +201;fr;Les Hauts de Hurlevent;Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme d’Ellis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal. +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. \ No newline at end of file diff --git a/multitenancy/db/data/sap.capire.bookshop-Genres.csv b/multitenancy/db/data/sap.capire.bookshop-Genres.csv new file mode 100644 index 00000000..1ea3793b --- /dev/null +++ b/multitenancy/db/data/sap.capire.bookshop-Genres.csv @@ -0,0 +1,16 @@ +ID;parent_ID;name +10;;Fiction +11;10;Drama +12;10;Poetry +13;10;Fantasy +14;10;Science Fiction +15;10;Romance +16;10;Mystery +17;10;Thriller +18;10;Dystopia +19;10;Fairy Tale +20;;Non-Fiction +21;20;Biography +22;21;Autobiography +23;20;Essay +24;20;Speech diff --git a/multitenancy/db/data/sap.capire.orders-Orders.csv b/multitenancy/db/data/sap.capire.orders-Orders.csv new file mode 100644 index 00000000..6ad3d700 --- /dev/null +++ b/multitenancy/db/data/sap.capire.orders-Orders.csv @@ -0,0 +1,3 @@ +ID;createdAt;createdBy;buyer;OrderNo;currency_code +7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR +64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR \ No newline at end of file diff --git a/multitenancy/db/data/sap.capire.orders-Orders_Items.csv b/multitenancy/db/data/sap.capire.orders-Orders_Items.csv new file mode 100644 index 00000000..b3025abe --- /dev/null +++ b/multitenancy/db/data/sap.capire.orders-Orders_Items.csv @@ -0,0 +1,4 @@ +ID;up__ID;amount;product_ID;title;price +58040e66-1dcd-4ffb-ab10-fdce32028b79;7e2f2640-6866-4dcf-8f4d-3027aa831cad;1;201;Wuthering Heights;11.11 +64e718c9-ff99-47f1-8ca3-950c850777d4;7e2f2640-6866-4dcf-8f4d-3027aa831cad;1;271;Catweazle;15 +e9641166-e050-4261-bfee-d1e797e6cb7f;64e718c9-ff99-47f1-8ca3-950c850777d4;2;252;Eleonora;28 \ No newline at end of file diff --git a/multitenancy/db/schema.cds b/multitenancy/db/schema.cds index 925d7484..aac1fe1d 100644 --- a/multitenancy/db/schema.cds +++ b/multitenancy/db/schema.cds @@ -1,6 +1,3 @@ -namespace sap.capire.multitenancy; -using { sap.capire.bookshop.Books } from '../../bookshop'; -using { sap.capire.orders.Orders } from '../../orders'; -using { sap.capire.orders.Orders_Items } from '../../orders'; -using { Country, managed, cuid } from '@sap/cds/common'; +using from './schema_bookshop'; +using from './schema_orders'; diff --git a/multitenancy/db/schema_bookshop.cds b/multitenancy/db/schema_bookshop.cds new file mode 100644 index 00000000..ec8b119a --- /dev/null +++ b/multitenancy/db/schema_bookshop.cds @@ -0,0 +1,31 @@ +using { Currency, managed, sap } from '@sap/cds/common'; +namespace sap.capire.bookshop; + +entity Books : managed { + key ID : Integer; + title : localized String(111); + descr : localized String(1111); + author : Association to Authors; + genre : Association to Genres; + stock : Integer; + price : Decimal; + currency : Currency; + image : LargeBinary @Core.MediaType : 'image/png'; +} + +entity Authors : managed { + key ID : Integer; + name : String(111); + dateOfBirth : Date; + dateOfDeath : Date; + placeOfBirth : String; + placeOfDeath : String; + books : Association to many Books on books.author = $self; +} + +/** Hierarchically organized Code List for Genres */ +entity Genres : sap.common.CodeList { + key ID : Integer; + parent : Association to Genres; + children : Composition of many Genres on children.parent = $self; +} diff --git a/multitenancy/db/schema_orders.cds b/multitenancy/db/schema_orders.cds new file mode 100644 index 00000000..0911a4c4 --- /dev/null +++ b/multitenancy/db/schema_orders.cds @@ -0,0 +1,23 @@ +using { Currency, User, managed, cuid } from '@sap/cds/common'; +namespace sap.capire.orders; + +entity Orders : cuid, managed { + OrderNo : String @title:'Order Number'; //> readable key + Items : Composition of many Orders_Items on Items.up_ = $self; + buyer : User; + currency : Currency; +} + +entity Orders_Items { + key ID : UUID; + up_ : Association to Orders; + product : Association to Products @assert.integrity:false; // REVISIT: this is a temporary workaround for a glitch in cds-runtime + amount : Integer; + title : String; //> intentionally replicated as snapshot from product.title + price : Double; +} + +/** This is a stand-in for arbitrary ordered Products */ +entity Products @(cds.persistence.skip:'always') { + key ID : String; +} diff --git a/multitenancy/package-lock.json b/multitenancy/package-lock.json index 8163a9c8..137fb237 100644 --- a/multitenancy/package-lock.json +++ b/multitenancy/package-lock.json @@ -8,7 +8,6 @@ "version": "1.0.0", "license": "UNLICENSED", "dependencies": { - "@capire/fiori": "../fiori", "@sap/cds": "5.0.6", "@sap/cds-mtx": "1.2.1", "@sap/hana-client": "^2", @@ -25,6 +24,7 @@ "../fiori": { "name": "@capire/fiori", "version": "1.0.0", + "extraneous": true, "dependencies": { "@capire/bookshop": "../bookshop", "@capire/common": "../common", @@ -35,10 +35,6 @@ "passport": "^0.4.1" } }, - "node_modules/@capire/fiori": { - "resolved": "../fiori", - "link": true - }, "node_modules/@dabh/diagnostics": { "version": "2.0.2", "resolved": "http://nexus.wdf.sap.corp:8081/nexus/repository/build.milestones.npm/@dabh/diagnostics/-/diagnostics-2.0.2.tgz", @@ -2925,18 +2921,6 @@ } }, "dependencies": { - "@capire/fiori": { - "version": "file:../fiori", - "requires": { - "@capire/bookshop": "../bookshop", - "@capire/common": "../common", - "@capire/orders": "../orders", - "@capire/reviews": "../reviews", - "@sap/cds": ">=4", - "express": "^4.17.1", - "passport": "^0.4.1" - } - }, "@dabh/diagnostics": { "version": "2.0.2", "resolved": "http://nexus.wdf.sap.corp:8081/nexus/repository/build.milestones.npm/@dabh/diagnostics/-/diagnostics-2.0.2.tgz", diff --git a/multitenancy/package.json b/multitenancy/package.json index 4f094e60..0644c12c 100644 --- a/multitenancy/package.json +++ b/multitenancy/package.json @@ -1,84 +1,84 @@ { - "name": "multitenancy", - "version": "1.0.0", - "description": "A simple CAP project.", - "repository": "", - "license": "UNLICENSED", - "private": true, - "dependencies": { - "@capire/fiori": "../fiori", - "@sap/cds": "5.0.6", - "@sap/cds-mtx": "1.2.1", - "@sap/hana-client": "^2", - "@sap/hdi-deploy": "^4", - "@sap/instance-manager": "^2", - "@sap/xssec": "^3", - "express": "^4", - "passport": "^0" + "name": "multitenancy", + "version": "1.0.0", + "description": "A simple CAP project.", + "repository": "", + "license": "UNLICENSED", + "private": true, + "dependencies": { + "@sap/cds": "5.0.6", + "@sap/cds-mtx": "1.2.1", + "@sap/hana-client": "^2", + "@sap/hdi-deploy": "^4", + "@sap/instance-manager": "^2", + "@sap/xssec": "^3", + "express": "^4", + "passport": "^0" + }, + "devDependencies": { + "sqlite3": "^5.0.2" + }, + "scripts": { + "start": "cds run", + "watch": "cds watch" + }, + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "es2020": true, + "node": true, + "jest": true, + "mocha": true }, - "devDependencies": { - "sqlite3": "^5.0.2" + "globals": { + "SELECT": true, + "INSERT": true, + "UPDATE": true, + "DELETE": true, + "CREATE": true, + "DROP": true, + "CDL": true, + "CQL": true, + "CXL": true, + "cds": true }, - "scripts": { - "start": "cds run" - }, - "eslintConfig": { - "extends": "eslint:recommended", - "env": { - "es2020": true, - "node": true, - "jest": true, - "mocha": true - }, - "globals": { - "SELECT": true, - "INSERT": true, - "UPDATE": true, - "DELETE": true, - "CREATE": true, - "DROP": true, - "CDL": true, - "CQL": true, - "CXL": true, - "cds": true - }, - "rules": { - "no-console": "off", - "require-atomic-updates": "off" - } - }, - "cds": { - "requires": { - "multitenancy": true, - "auth": { - "strategy": "JWT" - }, - "db": { - "kind": "hana", - "vcap": { - "label": "service-manager" - } - }, - "uaa": { - "kind": "xsuaa" - } - }, - "hana": { - "deploy-format": "hdbtable" - }, - "mtx": { - "element-prefix": "Z_", - "namespace-blacklist": [ - "com.sap.", - "sap." - ], - "entity-whitelist": [], - "service-whitelist": [] - }, - "auth": { - "passport": { - "strategy": "JWT" - } - } + "rules": { + "no-console": "off", + "require-atomic-updates": "off" } + }, + "cds": { + "requires": { + "multitenancy": true, + "auth": { + "strategy": "JWT" + }, + "db": { + "kind": "hana", + "vcap": { + "label": "service-manager" + } + }, + "uaa": { + "kind": "xsuaa" + } + }, + "hana": { + "deploy-format": "hdbtable" + }, + "mtx": { + "element-prefix": "Z_", + "namespace-blacklist": [ + "com.sap.", + "sap." + ], + "entity-whitelist": [], + "service-whitelist": [] + }, + "auth": { + "passport": { + "strategy": "JWT" + } + } + } } diff --git a/multitenancy/package_simple.json b/multitenancy/package_simple.json new file mode 100644 index 00000000..a66eb449 --- /dev/null +++ b/multitenancy/package_simple.json @@ -0,0 +1,52 @@ +{ + "name": "multitenancy", + "version": "1.0.0", + "description": "A simple CAP project.", + "repository": "", + "license": "UNLICENSED", + "private": true, + "dependencies": { + "@sap/cds": "5.0.6", + "express": "^4", + "passport": "^0" + }, + "devDependencies": { + "sqlite3": "^5.0.2" + }, + "scripts": { + "start": "cds run", + "watch": "cds watch" + }, + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "es2020": true, + "node": true, + "jest": true, + "mocha": true + }, + "globals": { + "SELECT": true, + "INSERT": true, + "UPDATE": true, + "DELETE": true, + "CREATE": true, + "DROP": true, + "CDL": true, + "CQL": true, + "CXL": true, + "cds": true + }, + "rules": { + "no-console": "off", + "require-atomic-updates": "off" + } + }, + "cds": { + "requires": { + "db": { + "kind": "sql" + } + } + } +} diff --git a/multitenancy/recent_logs.txt b/multitenancy/recent_logs.txt new file mode 100644 index 0000000000000000000000000000000000000000..4ee73a0544bfa4ff632be27f34f2ce7fd314874f GIT binary patch literal 294208 zcmeI5U2oJ_mxa%DOZ^Mxri9cIsFm+8U`C?}4H8_CAe2^LAQUAb4ZJ`ylZ1D~pP!k% z?Nq}#Eqc1_waWI|N2RKA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`G5rn~~-jQQ5=d8p>4TVLrltw;IYIhSHaR-X9feC|Dx8hN8;}XDGUi(1sF`R2M_R zaw_wucr_F*&&Yatr;BuA_Zxe4V&8IRbFS_7KAonIHa$yU?9u;v*B;;9RzN=4^ILo6^G}SvB`pMOk0*jCMN{`=Xc{cXjbx9xG$u77o8ueWT;O*_K(q0Mc7 zsp@*hlzclhre61bQe6xM%c;zt;?+>NJR=(lmn_dvxb2Q>C|s_*c$kmyuh&Bv#!&k5 z&ocuBL%|XmQ?B%=G3^hQPhObSf6XcVda0gM?xsa@N?lGkL(ygQ{k*%Ip+qFr#Za)E bs-bXsMm7{K+3{wic}7(Bu(*aYws`nI%(8xz literal 0 HcmV?d00001 diff --git a/multitenancy/server.js b/multitenancy/server.js index ef63e68e..ac4e1ec7 100644 --- a/multitenancy/server.js +++ b/multitenancy/server.js @@ -1,7 +1,9 @@ const cds = require ('@sap/cds'); + cds.on('bootstrap', async app => { await cds.mtx.in(app); }); + module.exports = cds.server; diff --git a/multitenancy/srv/admin-service.cds b/multitenancy/srv/admin-service.cds new file mode 100644 index 00000000..58ff9bb1 --- /dev/null +++ b/multitenancy/srv/admin-service.cds @@ -0,0 +1,7 @@ +using { sap.capire.bookshop as my } from '../db/schema'; + +//service AdminService @(requires:'admin') { +service AdminService { + entity Books as projection on my.Books; + entity Authors as projection on my.Authors; +} diff --git a/multitenancy/srv/admin-service.js b/multitenancy/srv/admin-service.js new file mode 100644 index 00000000..0cdae4d8 --- /dev/null +++ b/multitenancy/srv/admin-service.js @@ -0,0 +1,12 @@ +const cds = require('@sap/cds') + +module.exports = cds.service.impl (function(){ + this.before ('NEW','Authors', genid) + this.before ('NEW','Books', genid) +}) + +/** Generate primary keys for target entity in request */ +async function genid (req) { + const {ID} = await cds.tx(req).run (SELECT.one.from(req.target).columns('max(ID) as ID')) + req.data.ID = ID - ID % 100 + 100 + 1 +} diff --git a/multitenancy/srv/cat-service.cds b/multitenancy/srv/cat-service.cds new file mode 100644 index 00000000..652cc289 --- /dev/null +++ b/multitenancy/srv/cat-service.cds @@ -0,0 +1,16 @@ +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 }; + + /** For display in details pages */ + @readonly entity Books as projection on my.Books { *, + author.name as author + } excluding { createdBy, modifiedBy }; + + //@__requires: 'authenticated-user' + action submitOrder ( book: Books:ID, amount: Integer ) returns { stock: Integer }; + event OrderedBook : { book: Books:ID; amount: Integer; buyer: String }; +} diff --git a/multitenancy/srv/cat-service.js b/multitenancy/srv/cat-service.js new file mode 100644 index 00000000..a27aa397 --- /dev/null +++ b/multitenancy/srv/cat-service.js @@ -0,0 +1,26 @@ +const cds = require('@sap/cds') +const { Books } = cds.entities ('sap.capire.bookshop') + +class CatalogService extends cds.ApplicationService { init(){ + + // Reduce stock of ordered books if available stock suffices + this.on ('submitOrder', async req => { + const {book,amount} = req.data + let {stock} = await SELECT `stock` .from (Books,book) + if (stock >= amount) { + await UPDATE (Books,book) .with (`stock -=`, amount) + await this.emit ('OrderedBook', { book, amount, buyer:req.user.id }) + return { stock } + } + else return req.error (409,`${amount} exceeds stock for book #${book}`) + }) + + // Add some discount for overstocked books + this.after ('READ','ListOfBooks', each => { + if (each.stock > 111) each.title += ` -- 11% discount!` + }) + + return super.init() +}} + +module.exports = { CatalogService } diff --git a/multitenancy/srv/multitenancy-service.cds b/multitenancy/srv/multitenancy-service.cds deleted file mode 100644 index 645d5154..00000000 --- a/multitenancy/srv/multitenancy-service.cds +++ /dev/null @@ -1,15 +0,0 @@ -using {sap.capire.bookshop as bookshop } from '../../bookshop/db/schema'; -using {sap.capire.orders as orders } from '../../orders/db/schema'; - -service MultitenancyService { - entity Books as projection on bookshop.Books; - entity Orders as projection on orders.Orders; - entity Orders_Items as projection on orders.Orders_Items; -} - -using AdminService from '../../bookshop/srv/admin-service'; -using CatalogService from '../../bookshop/srv/cat-service'; - -annotate AdminService with @restrict : false; -annotate CatalogService with @restrict : false; - diff --git a/multitenancy/srv/orders-service.cds b/multitenancy/srv/orders-service.cds new file mode 100644 index 00000000..119373db --- /dev/null +++ b/multitenancy/srv/orders-service.cds @@ -0,0 +1,5 @@ +using { sap.capire.orders as my } from '../db/schema'; + +service OrdersService { + entity Orders as projection on my.Orders; +} diff --git a/multitenancy/srv/orders-service.js b/multitenancy/srv/orders-service.js new file mode 100644 index 00000000..10420410 --- /dev/null +++ b/multitenancy/srv/orders-service.js @@ -0,0 +1,37 @@ +const cds = require ('@sap/cds') +class OrdersService extends cds.ApplicationService { + + /** register custom handlers */ + init(){ + const { Orders_Items:OrderItems } = this.entities + + this.before ('UPDATE', 'Orders', async function(req) { + const { ID, Items } = req.data + if (Items) for (let { product_ID, amount } of Items) { + const { amount:before } = await cds.tx(req).run ( + SELECT.one.from (OrderItems, oi => oi.amount) .where ({up__ID:ID, product_ID}) + ) + if (amount != before) await this.orderChanged (product_ID, amount-before) + } + }) + + this.before ('DELETE', 'Orders', async function(req) { + const { ID } = req.data + const Items = await cds.tx(req).run ( + SELECT.from (OrderItems, oi => { oi.product_ID, oi.amount }) .where ({up__ID:ID}) + ) + if (Items) await Promise.all (Items.map(it => this.orderChanged (it.product_ID, -it.amount))) + }) + + return super.init() + } + + /** order changed -> broadcast event */ + orderChanged (product, deltaAmount) { + // Emit events to inform subscribers about changes in orders + console.log ('> emitting:', 'OrderChanged', { product, deltaAmount }) + return this.emit ('OrderChanged', { product, deltaAmount }) + } + +} +module.exports = OrdersService diff --git a/package.json b/package.json index d8b32c62..951257fd 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "@capire/hello": "./hello", "@capire/media": "./media", "@capire/orders": "./orders", - "@capire/reviews": "./reviews" + "@capire/reviews": "./reviews", + "@capire/multitenancy": "./multitenancy" }, "devDependencies": { "chai": "^4.2.0", @@ -25,6 +26,7 @@ "bookshop": "cds watch bookshop", "fiori": "cds watch fiori", "media": "cds watch media", + "multitenancy": "cds watch multitenancy", "mocha": "npx mocha || echo", "jest": "npx jest", "test": "npm run jest --silent"