From 803432b8d970545bdc8b1d119968032084feda01 Mon Sep 17 00:00:00 2001 From: d045778 Date: Thu, 11 Mar 2021 16:58:29 +0100 Subject: [PATCH] changed modeling of suppliers --- suppliers/srv/mashup.cds | 47 +++++++++------------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/suppliers/srv/mashup.cds b/suppliers/srv/mashup.cds index 33d607c9..ab0b13cc 100644 --- a/suppliers/srv/mashup.cds +++ b/suppliers/srv/mashup.cds @@ -3,53 +3,26 @@ you actually want to use from there. */ -using { API_BUSINESS_PARTNER as S4 } from './external/API_BUSINESS_PARTNER.csn'; -extend service S4 with { +using {API_BUSINESS_PARTNER as S4} from './external/API_BUSINESS_PARTNER.csn'; + +context replica { + @cds.autoexpose // or expose explicitly in Catalog and AdminService + @cds.persistence: {table, skip: false} entity Suppliers as projection on S4.A_BusinessPartner { - key BusinessPartner as ID, - BusinessPartnerFullName as name, - // REVISIT: following is not supported so far in cds compiler... - // to_BusinessPartnerAddress as city { - // CityCode as code, - // CityName as name - // } - // REVISIT: following is not supported so far in cqn2odata... - // to_BusinessPartnerAddress.CityCode as city, - // to_BusinessPartnerAddress.CityName as city_name, + key BusinessPartner as ID, + BusinessPartnerFullName as name } } - -/* - You can mashup entities from external services, or projections - thereof, with your project's own entities - */ using { sap.capire.bookshop.Books, CatalogService } from '@capire/bookshop'; extend Books with { - supplier : Association to S4.Suppliers; + supplier : Association to replica.Suppliers; } - -/* - You can also expose external entities through your own services - For this to work, you need to delegate the respective calls - addressed to your services into calls to the external service. - */ -extend service AdminService with { - entity Suppliers as projection on S4.Suppliers; +extend service AdminService with { // why is AdminService visible? + entity Suppliers as projection on replica.Suppliers; } -/* - Optionally add a local persistence to keep replicas of external - entities to have data in fast access locally; much like a cache. - */ -annotate S4.Suppliers with @cds.persistence:{table,skip:false}; - -/** - Having locally cached replicas also allows us to display supplier - data in lists of books, which otherwise would generate unwanted - traffic on S4 backends. - */ extend projection CatalogService.ListOfBooks with { supplier }