Compare commits
1 Commits
adding-sup
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc69311ebe |
@@ -21,18 +21,18 @@
|
|||||||
},
|
},
|
||||||
"requires": {
|
"requires": {
|
||||||
"API_BUSINESS_PARTNER": {
|
"API_BUSINESS_PARTNER": {
|
||||||
"kind": "odata",
|
"kind": "odata-v2",
|
||||||
"model": "@capire/suppliers"
|
"model": "@capire/suppliers"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"strategy": "dummy"
|
"strategy": "dummy"
|
||||||
},
|
},
|
||||||
"ReviewsService": {
|
"ReviewsService": {
|
||||||
"kind": "odata",
|
"kind": "odata-v4",
|
||||||
"model": "@capire/reviews"
|
"model": "@capire/reviews"
|
||||||
},
|
},
|
||||||
"OrdersService": {
|
"OrdersService": {
|
||||||
"kind": "odata",
|
"kind": "odata-v4",
|
||||||
"model": "@capire/orders"
|
"model": "@capire/orders"
|
||||||
},
|
},
|
||||||
"db": {
|
"db": {
|
||||||
|
|||||||
@@ -23,3 +23,9 @@ using { sap.capire.orders.Orders_Items } from '@capire/orders';
|
|||||||
extend Orders_Items with {
|
extend Orders_Items with {
|
||||||
book : Association to Books on product.ID = book.ID
|
book : Association to Books on product.ID = book.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using { OrdersService.Orders } from '@capire/orders';
|
||||||
|
// extend service CatalogService with {
|
||||||
|
// entity OrdereredBooks as projection on Orders;
|
||||||
|
// }
|
||||||
|
|||||||
9
orders/api/external.cds
Normal file
9
orders/api/external.cds
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
context external {
|
||||||
|
|
||||||
|
/** This is a stand-in for arbitrary ordered Products */
|
||||||
|
entity Products @(cds.persistence.skip:'always') {
|
||||||
|
key ID : String;
|
||||||
|
data : String;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
orders/api/orders-service-comp.cds
Normal file
21
orders/api/orders-service-comp.cds
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using { cuid, managed, User, Currency } from '@sap/cds/common';
|
||||||
|
using { sap.capire.orders as my } from '../db/schema';
|
||||||
|
using { external.Products } from './external';
|
||||||
|
|
||||||
|
|
||||||
|
service OrdersService {
|
||||||
|
|
||||||
|
entity Orders : cuid, managed {
|
||||||
|
OrderNo : String @title:'Order Number'; //> readable key
|
||||||
|
Items : Composition of many {
|
||||||
|
key ID : UUID;
|
||||||
|
product : Association to Products;
|
||||||
|
amount : Integer;
|
||||||
|
title : String; //> intentionally replicated as snapshot from product.title
|
||||||
|
price : Double;
|
||||||
|
};
|
||||||
|
buyer : User;
|
||||||
|
currency : Currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
orders/api/orders-service.cds
Normal file
40
orders/api/orders-service.cds
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using { cuid, managed, User, Currency } from '@sap/cds/common';
|
||||||
|
using { sap.capire.orders as my } from '../db/schema';
|
||||||
|
using { external.Products } from './external';
|
||||||
|
|
||||||
|
|
||||||
|
// GET Orders
|
||||||
|
// GET Orders()/Items
|
||||||
|
// GET Orders?$Items
|
||||||
|
|
||||||
|
service OwnService {
|
||||||
|
entity Orders as projection on OrdersService.Orders;
|
||||||
|
entity Products as projection on OrdersService.Products;
|
||||||
|
}
|
||||||
|
|
||||||
|
service OrdersService {
|
||||||
|
|
||||||
|
entity Orders : cuid, managed {
|
||||||
|
OrderNo : String @title:'Order Number'; //> readable key
|
||||||
|
Items : Composition of many Orders_Items; // on Items.up_ = $self;
|
||||||
|
// MoreItems : Composition of many Orders_Items; // on Items.up_ = $self;
|
||||||
|
// Items_ID
|
||||||
|
buyer : User;
|
||||||
|
currency : Currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Orders_Items {
|
||||||
|
key ID : UUID;
|
||||||
|
// up_ : Association to Orders;
|
||||||
|
product : Association to Products; //> {ID}
|
||||||
|
// product_ID
|
||||||
|
amount : Integer;
|
||||||
|
title : String; //> intentionally replicated as snapshot from product.title
|
||||||
|
price : Double;
|
||||||
|
}
|
||||||
|
|
||||||
|
// entity Products {
|
||||||
|
// key ID : UUID;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
using from './srv/mashup';
|
|
||||||
@@ -25,16 +25,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"[local-hybrid]": {
|
"[local-hybrid]": { "messaging": { "kind": "file-based-messaging" }},
|
||||||
"messaging": {
|
"[hybrid]": { "messaging": { "kind": "enterprise-messaging-shared" }}
|
||||||
"kind": "file-based-messaging"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"[hybrid]": {
|
|
||||||
"messaging": {
|
|
||||||
"kind": "enterprise-messaging-shared"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3261
suppliers/srv/external/API_BUSINESS_PARTNER.edmx
vendored
3261
suppliers/srv/external/API_BUSINESS_PARTNER.edmx
vendored
File diff suppressed because it is too large
Load Diff
10
suppliers/srv/external/API_BUSINESS_PARTNER.js
vendored
10
suppliers/srv/external/API_BUSINESS_PARTNER.js
vendored
@@ -1,10 +0,0 @@
|
|||||||
const cds = require('@sap/cds');
|
|
||||||
|
|
||||||
module.exports = cds.service.impl(function () {
|
|
||||||
const { A_BusinessPartner } = this.entities;
|
|
||||||
|
|
||||||
// https://api.sap.com/event/SAPS4HANACloudBusinessEvents_BusinessPartner/resource
|
|
||||||
this.after('UPDATE', A_BusinessPartner, async data => {
|
|
||||||
await this.emit("BusinessPartner.Changed", { BusinessPartner: data.BusinessPartner });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
Can't render this file because it contains an unexpected character in line 2 and column 30.
|
1
suppliers/test/index.cds
Normal file
1
suppliers/test/index.cds
Normal file
@@ -0,0 +1 @@
|
|||||||
|
using from '../srv/mashup';
|
||||||
7
suppliers/test/mocked.js
Normal file
7
suppliers/test/mocked.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
let { API_BUSINESS_PARTNER:S4 } = cds.services
|
||||||
|
|
||||||
|
// Mocking event emitter according to:
|
||||||
|
// https://api.sap.com/event/SAPS4HANACloudBusinessEvents_BusinessPartner/resource
|
||||||
|
S4.after ('UPDATE', 'A_BusinessPartner', data =>
|
||||||
|
S4.emit ('BusinessPartner.Changed', { BusinessPartner: data.BusinessPartner })
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user