From cd3f1395442b5b19f6d8c4c1a4e7808a5fb295c0 Mon Sep 17 00:00:00 2001 From: Wolfgang Koch Date: Fri, 12 Feb 2021 11:52:36 +0100 Subject: [PATCH] pdm annotations --- gdpr/db/data-privacy.cds | 70 ++++++++++++++++++++++++---------------- gdpr/srv/pdm-service.cds | 57 ++++++++++++++++---------------- 2 files changed, 70 insertions(+), 57 deletions(-) diff --git a/gdpr/db/data-privacy.cds b/gdpr/db/data-privacy.cds index 4c8326b5..1070c60a 100644 --- a/gdpr/db/data-privacy.cds +++ b/gdpr/db/data-privacy.cds @@ -1,37 +1,51 @@ // Proxy for importing schema from bookshop sample -using { sap.capire.bookshop } from './schema'; +using {sap.capire.bookshop} from './schema'; // annotations for Data Privacy -annotate bookshop.Customers with @PersonalData.DataSubjectRole: 'Customer'; -annotate bookshop.Customers with @PersonalData.EntitySemantics: 'DataSubject' - { - ID @PersonalData.FieldSemantics: 'DataSubjectID'; - emailAddress @PersonalData.IsPotentiallyPersonal; - firstName @PersonalData.IsPotentiallyPersonal; - lastName @PersonalData.IsPotentiallyPersonal; - creditCardNo @PersonalData.IsPotentiallySensitive; - dateOfBirth @PersonalData.IsPotentiallyPersonal; - } +annotate bookshop.Customers with @PersonalData : { + DataSubjectRole : 'Customer', + EntitySemantics : 'DataSubject' +} +{ + ID @PersonalData.FieldSemantics : 'DataSubjectID'; + emailAddress @PersonalData.IsPotentiallyPersonal; + firstName @PersonalData.IsPotentiallyPersonal; + lastName @PersonalData.IsPotentiallyPersonal; + creditCardNo @PersonalData.IsPotentiallySensitive; + dateOfBirth @PersonalData.IsPotentiallyPersonal; +} -annotate bookshop.CustomerPostalAddress with @PersonalData.DataSubjectRole: 'Customer'; -annotate bookshop.CustomerPostalAddress with @PersonalData.EntitySemantics: 'DataSubjectDetails' - { - Customer @PersonalData.FieldSemantics: 'DataSubjectID'; - street @PersonalData.IsPotentiallyPersonal; - town @PersonalData.IsPotentiallyPersonal; - country @PersonalData.IsPotentiallyPersonal; - } +annotate bookshop.CustomerPostalAddress with @PersonalData : { + DataSubjectRole : 'Customer', + EntitySemantics : 'DataSubjectDetails' +} +{ + Customer @PersonalData.FieldSemantics : 'DataSubjectID'; + street @PersonalData.IsPotentiallyPersonal; + town @PersonalData.IsPotentiallyPersonal; + country @PersonalData.IsPotentiallyPersonal; +} // annotations for Personal Data Manager - Search Fields -annotate bookshop.Customers with @(Communication.Contact : { - n : { - surname: lastName, - given: firstName - }, - bday: dateOfBirth -}); +annotate bookshop.Customers with @(Communication.Contact : { + n : { + surname : lastName, + given : firstName + }, + bday : dateOfBirth +}); // annotations for Audit Log -annotate bookshop.Customers with @AuditLog.Operation: {Read: true, Insert: true, Update: true, Delete: true}; +annotate bookshop.Customers with @AuditLog.Operation : { + Read : true, + Insert : true, + Update : true, + Delete : true +}; -annotate bookshop.CustomerPostalAddress with @AuditLog.Operation: {Read: true, Insert: true, Update: true, Delete: true}; +annotate bookshop.CustomerPostalAddress with @AuditLog.Operation : { + Read : true, + Insert : true, + Update : true, + Delete : true +}; diff --git a/gdpr/srv/pdm-service.cds b/gdpr/srv/pdm-service.cds index 5e17e024..9bfb5a85 100644 --- a/gdpr/srv/pdm-service.cds +++ b/gdpr/srv/pdm-service.cds @@ -1,36 +1,35 @@ //using from '@capire/orders'; -using { sap.capire.bookshop as db } from '../db/data-privacy'; -using { sap.capire.bookshop.Books } from '@capire/bookshop'; -using { sap.capire.bookshop.Orders } from '@capire/orders'; -using { sap.capire.bookshop.OrderItems } from '@capire/orders'; +using {sap.capire.bookshop as db} from '../db/data-privacy'; +using {sap.capire.bookshop.Books} from '@capire/bookshop'; +using {sap.capire.bookshop.Orders} from '@capire/orders'; +using {sap.capire.bookshop.OrderItems} from '@capire/orders'; -//@requires: 'system-user' - service PDMService { +// @requires:'system-user' - todo - security check +service PDMService{ - entity Customers as projection on db.Customers; + entity Customers as projection on db.Customers; + entity CustomerPostalAddress as projection on db.CustomerPostalAddress; - entity CustomerPostalAddress as projection on db.CustomerPostalAddress; + // create view on Orders and Items as flat projection + entity OrderItemView as + select from Orders { + ID, + key Items.ID as Item_ID, + OrderNo, + Customer.ID as Customer_ID, + Customer.email as Customer_Email, + Items.book.ID as Item_Book_ID, + Items.amount as Item_Amount, + Items.netAmount as Item_NetAmount + }; -// create view on Orders and Items as flat projection - entity OrderItemView as - SELECT from Orders - { ID, - key Items.ID as Item_ID, - OrderNo, - Customer.ID as Customer_ID, - Customer.email as Customer_Email, - Items.book.ID as Item_Book_ID, - Items.amount as Item_Amount, - Items.netAmount as Item_NetAmount}; - - // annotate new view - annotate PDMService.OrderItemView with @(PersonalData.EntitySemantics: 'ContractRelated') - { - Item_ID @PersonalData.FieldSemantics: 'LegalGroundID'; - Customer_ID @PersonalData.FieldSemantics: 'DataSubjectID'; - Customer_Email @PersonalData.IsPotentiallyPersonal; - }; + // annotate new view + annotate PDMService.OrderItemView with @(PersonalData.EntitySemantics : 'Other') { + Item_ID @PersonalData.FieldSemantics : 'ContractRelatedID'; + Customer_ID @PersonalData.FieldSemantics : 'DataSubjectID'; + Customer_Email @PersonalData.IsPotentiallyPersonal; + }; - // Data Privacy annotations on 'Customers' and 'CustomerPostalAddress' are derived from original entity definitions +// Data Privacy annotations on 'Customers' and 'CustomerPostalAddress' are derived from original entity definitions - }; \ No newline at end of file +};