forked from SAP-samples/cloud-cap-samples-java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
books.cds
55 lines (50 loc) · 1.61 KB
/
books.cds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace my.bookshop;
using {
Currency,
sap,
managed,
cuid
} from '@sap/cds/common';
using my.bookshop.Reviews from './reviews';
using my.bookshop.TechnicalBooleanFlag from './common';
@fiori.draft.enabled
entity Books : cuid, managed {
title : localized String(111);
descr : localized String(1111);
author : Association to Authors;
genre : Association to Genres;
stock : Integer;
price : Decimal(9, 2);
currency : Currency;
rating : Decimal(2, 1);
reviews : Association to many Reviews
on reviews.book = $self;
isReviewable : TechnicalBooleanFlag not null default true;
}
entity Authors : cuid, managed {
@assert.format : '^\p{Lu}.*' // assert that name starts with a capital letter
name : String(111);
dateOfBirth : Date;
dateOfDeath : Date;
placeOfBirth : String;
placeOfDeath : String;
books : Association to many Books
on books.author = $self;
}
// annotations for Data Privacy
annotate Authors with
@PersonalData : { DataSubjectRole : 'Author', EntitySemantics : 'DataSubject' }
@AuditLog.Operation : { Read : true, Insert : true, Update : true, Delete : true }
{
ID @PersonalData.FieldSemantics : 'DataSubjectID';
name @PersonalData.IsPotentiallySensitive;
}
/**
* Hierarchically organized Code List for Genres
*/
entity Genres : sap.common.CodeList {
key ID : Integer;
parent : Association to Genres;
children : Composition of many Genres
on children.parent = $self;
}