Cosmetics -> for docs

This commit is contained in:
Daniel
2021-06-15 12:57:42 +02:00
parent ba3eeff58b
commit 0cb7349e62

View File

@@ -1,23 +1,35 @@
/*
Optionally add projections to external entities, to capture what
you actually want to use from there.
*/
using { sap.capire.bookshop as bookshop } from '@capire/bookshop';
using { API_BUSINESS_PARTNER as S4 } from './external/API_BUSINESS_PARTNER.csn'; using { API_BUSINESS_PARTNER as S4 } from './external/API_BUSINESS_PARTNER.csn';
using { CatalogService, sap.capire.bookshop.Books } from '@capire/bookshop';
namespace sap.capire.bookshop;
@cds.autoexpose // or expose explicitly in Catalog and AdminService
@cds.persistence: {table,skip:false} // add persistency /**
@readonly Add projections to external entities to capture the subset of fields we're
entity sap.capire.bookshop.Suppliers as projection on S4.A_BusinessPartner { actually interested in. This fosters both: (a) minimized network traffic as
well as (b) options to dynamically add extension fields by SaaS tenants.
*/
entity Suppliers as projection on S4.A_BusinessPartner {
key BusinessPartner as ID, key BusinessPartner as ID,
BusinessPartnerFullName as name BusinessPartnerFullName as name,
// to_BusinessPartnerAddress[1: ValidityStartDate <= $now and $now < ValidityEndDate].CityName,
// to_BusinessPartnerAddress[1: ValidityStartDate <= $now and $now < ValidityEndDate].Country,
} }
/**
We can mashup entities from external services, or projections thereof, with
our project's own entities, e.g. by adding relationships as below.
*/
extend Books with {
supplier : Association to Suppliers;
}
/* /*
You can also expose external entities through your own services Optionally expose external entities through own services, e.g. for Value Helps,
For this to work, you need to delegate the respective calls or to display details fetched on demand.
addressed to your services into calls to the external service. For this to work, we need to delegate the respective calls addressed to our
services into calls to the external service.
*/ */
extend service AdminService with { extend service AdminService with {
entity Suppliers as projection on bookshop.Suppliers; entity Suppliers as projection on bookshop.Suppliers;
@@ -25,27 +37,35 @@ extend service AdminService with {
/* /*
You can mashup entities from external services, or projections Optionally add local persistency to replicate data for fast access,
thereof, with your project's own entities e.g. to display lists containing remote data.
*/ */
using { sap.capire.bookshop.Books, CatalogService } from '@capire/bookshop'; annotate Suppliers with @cds.persistence: {table,skip:false};
extend Books with {
supplier : Association to bookshop.Suppliers;
}
/** /**
Having locally cached replicas also allows us to display supplier Having locally cached replicas also allows to display supplier data in lists
data in lists of books, which otherwise would generate unwanted of books, which otherwise would generate unwanted traffic on S4 backends.
traffic on S4 backends.
*/ */
extend projection CatalogService.ListOfBooks with { extend projection CatalogService.ListOfBooks with {
supplier.name as supplier supplier.name as supplier
} }
// Extend S4 service with an event (events are not included in EDMX files)
/**
Optionally declare events emitted from the source, but not included in
imported APIs (e.g. as in case of EDMXes from API Hub).
This allows CAP's advanced support for events and messaging to kick in,
e.g. to automatically emit to and subscribe to events from message brokers
behind the scenes.
Note: as sync and async APIs from S/4 sources are not correlated, we have
to specify the event type names, e.g. as be found at:
https://api.sap.com/event/SAPS4HANACloudBusinessEvents_BusinessPartner/resource
*/
extend service S4 { extend service S4 {
@type: 'sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1' event BusinessPartner.Changed @(type: 'sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1') {
event BusinessPartner.Changed {
BusinessPartner: S4.A_BusinessPartner:BusinessPartner; BusinessPartner: S4.A_BusinessPartner:BusinessPartner;
} }
} }