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 00000000..5d0ffc50
Binary files /dev/null and b/logs_recent_2.txt differ
diff --git a/logs_recent_3.txt b/logs_recent_3.txt
new file mode 100644
index 00000000..f86ed80b
Binary files /dev/null and b/logs_recent_3.txt differ
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 00000000..4ee73a05
Binary files /dev/null and b/multitenancy/recent_logs.txt differ
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"