-
Notifications
You must be signed in to change notification settings - Fork 141
/
admin-service.cds
65 lines (53 loc) · 1.67 KB
/
admin-service.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
56
57
58
59
60
61
62
63
64
65
using {sap.common.Languages as CommonLanguages} from '@sap/cds/common';
using {my.bookshop as my} from '../db/index';
using {sap.changelog as changelog} from 'com.sap.cds/change-tracking';
extend my.Orders with changelog.changeTracked;
@path : 'admin'
service AdminService @(requires : 'admin') {
entity Books as projection on my.Books excluding { reviews } actions {
action addToOrder(order_ID : UUID, quantity : Integer) returns Orders;
}
entity Authors as projection on my.Authors;
entity Orders as select from my.Orders;
@cds.persistence.skip
entity Upload @odata.singleton {
csv : LargeBinary @Core.MediaType : 'text/csv';
}
}
// Deep Search Items
annotate AdminService.Orders with @cds.search : {
OrderNo,
Items
};
annotate AdminService.OrderItems with @cds.search : {book};
annotate AdminService.Books with @cds.search : {
descr,
title
};
// Enable Fiori Draft for Orders
annotate AdminService.Orders with @odata.draft.enabled;
annotate AdminService.Books with @odata.draft.enabled;
// workaround to enable the value help for languages
// Necessary because auto exposure is currently not working
// for if Languages is only referenced by the generated
// _texts table
extend service AdminService with {
entity Languages as projection on CommonLanguages;
}
// Change-track orders and items
annotate AdminService.Orders {
OrderNo @changelog;
};
annotate AdminService.OrderItems {
quantity @changelog;
book @changelog: [
book.title,
book.isbn
]
};
// Assign identifiers to the tracked entities
annotate AdminService.Orders with @changelog: [OrderNo];
annotate AdminService.OrderItems with @changelog: [
parent.OrderNo,
book.title,
];