some more cleanup
This commit is contained in:
@@ -12,10 +12,10 @@ const { Books, Addresses } = db.entities // entities in local database
|
|||||||
|
|
||||||
module.exports = (admin => {
|
module.exports = (admin => {
|
||||||
// Handler to delegate ValueHelp requests to S/4 backend, fetching current user's addresses from there
|
// Handler to delegate ValueHelp requests to S/4 backend, fetching current user's addresses from there
|
||||||
admin.on ('READ', 'Addresses', (req) => {
|
admin.on ('READ', 'usersAddresses', (req) => {
|
||||||
const { SELECT } = cds.ql(req) //> convenient alternative to bupa.transaction(req).run(SELECT...)
|
const { SELECT } = cds.ql(req) //> convenient alternative to bupa.transaction(req).run(SELECT...)
|
||||||
return SELECT.from (externalAddresses) .where ({ BusinessPartner: req.user.id || 'anonymous' })
|
return SELECT.from (externalAddresses) .where ({ BusinessPartner: req.user.id || 'anonymous' })
|
||||||
//> this is applying projection generically, i.e. the equivalent of:
|
//> this is applying projection from CDS model generically, i.e. the equivalent of:
|
||||||
// const { A_BusinessPartnerAddress } = bupa.entities
|
// const { A_BusinessPartnerAddress } = bupa.entities
|
||||||
// return SELECT.from (A_BusinessPartnerAddress, a => {
|
// return SELECT.from (A_BusinessPartnerAddress, a => {
|
||||||
// a.AddressID.as('ID'),
|
// a.AddressID.as('ID'),
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ extend service API_BUSINESS_PARTNER with {
|
|||||||
/**
|
/**
|
||||||
* Simplified view on external addresses
|
* Simplified view on external addresses
|
||||||
*/
|
*/
|
||||||
@mashup @cds.autoexpose //> for ValueHelps
|
@mashup entity Addresses as projection on external.A_BusinessPartnerAddress {
|
||||||
entity Addresses as projection on external.A_BusinessPartnerAddress {
|
|
||||||
key AddressID as ID,
|
key AddressID as ID,
|
||||||
key BusinessPartner,
|
key BusinessPartner,
|
||||||
Country as country,
|
Country as country,
|
||||||
@@ -35,15 +34,15 @@ extend service API_BUSINESS_PARTNER with {
|
|||||||
* Mashup w/ services to also serve shipping addresses
|
* Mashup w/ services to also serve shipping addresses
|
||||||
*/
|
*/
|
||||||
using { AdminService } from './admin-service';
|
using { AdminService } from './admin-service';
|
||||||
extend service AdminService {
|
extend service AdminService { // for ValueHelps from S/4 backend
|
||||||
// entity usersAddresses as projection on external.Addresses;
|
@readonly entity usersAddresses as projection on external.Addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: not used so far...
|
// TODO: not used so far...
|
||||||
using { CatalogService } from './cat-service';
|
using { CatalogService } from './cat-service';
|
||||||
extend service CatalogService {
|
extend service CatalogService { // for ValueHelps from S/4 backend
|
||||||
@readonly @requires:'authenticated-user'
|
@requires:'authenticated-user'
|
||||||
entity usersAddresses as projection on external.Addresses;
|
@readonly entity usersAddresses as projection on external.Addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,13 +51,6 @@ extend service CatalogService {
|
|||||||
*/
|
*/
|
||||||
using { sap.capire.bookshop } from '../db/schema';
|
using { sap.capire.bookshop } from '../db/schema';
|
||||||
|
|
||||||
/**
|
|
||||||
* Extend Orders to maintain references to (replicated) external Addresses
|
|
||||||
*/
|
|
||||||
extend bookshop.Orders with {
|
|
||||||
shippingAddress : Association to bookshop.Addresses;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an entity to replicate external address data for quick access,
|
* Add an entity to replicate external address data for quick access,
|
||||||
* e.g. when displaying lists of orders.
|
* e.g. when displaying lists of orders.
|
||||||
@@ -67,3 +59,10 @@ extend bookshop.Orders with {
|
|||||||
entity sap.capire.bookshop.Addresses as SELECT from external.Addresses { *,
|
entity sap.capire.bookshop.Addresses as SELECT from external.Addresses { *,
|
||||||
false as tombstone : Boolean
|
false as tombstone : Boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend Orders to with references to replicated external Addresses
|
||||||
|
*/
|
||||||
|
extend bookshop.Orders with {
|
||||||
|
shippingAddress : Association to bookshop.Addresses;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user