-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.cds
239 lines (217 loc) · 5.79 KB
/
schema.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
using {
cuid,
managed,
Currency,
Country,
sap.common.CodeList as CodeList
} from './common';
namespace my.cave;
aspect Boisson : cuid, managed {
name : String(50);
annee : String(4)@assert.format : '[0-9]';
type : String(15);
@Measures : {Unit : '%vol'}
degre : Decimal(4, 1);
@Measures : {Unit : unit, }
volume : Integer default 75;
unit : String(3)@assert.range enum {
L;
cL;
} default 'cL';
@Measures : {ISOCurrency : devise_code, }
prix : Decimal(6, 2);
devise : Currency;
};
entity Cepage @(assert.unique : {Cepage : [name]}) : cuid {
name : String(30)@assert.format : '[A-Z]';
description : String(400);
color : String(10)@assert.range enum {
Noir;
Blanc;
};
to_vins : Association to many Assemblage
on to_vins.cepage = $self;
to_superficies : Composition of many Superficie
on to_superficies.to_cepage = $self;
};
entity Superficie @(assert.unique : {Superficie : [
to_cepage,
annee
]}) : cuid {
to_cepage : Association to one Cepage;
annee : String(4)@assert.format : '[0-9]';
@Measures : {Unit : 'ha'}
superficie : Integer default 0;
};
entity Assemblage @(assert.unique : {Assemblage : [
cepage,
vin
]}) : cuid {
cepage : Association to Cepage;
vin : Association to Vin;
@Measures : {Unit : '%'}
pourcent : Integer @assert.range : [
0,
100
] default 0;
};
entity Vin : Boisson {
reference : String(50)@assert.format : '[0-9]{4}-.{3}-.*';
color : Association to VinColor;
igp : Boolean default false;
aoc : Boolean default false;
region : Association to Region;
@Measures : {Unit : '{i18n>anneeGarde}'} garde : Integer
@assert.range : [
1,
20
] default 1;
to_cepages : Composition of many Assemblage
on to_cepages.vin = $self;
inStockQty : Integer default 0;
orderQty : Integer default 0;
@Core.Computed
status : Association to RetentionStatus;
availability : Association to AvailabilityStatus;
};
@cds.autoexpose @readonly @cds.odata.valuelist
entity VinColor : CodeList {
key code : String(10)@assert.range enum {
Rouge;
![Rosé];
Vert;
Blanc;
};
};
@cds.autoexpose @readonly : true
entity BiereColor : CodeList {
key code : String @assert.range enum {
Rousse;
Blanche;
Blonde;
![Ambrée];
Stout;
Brune;
};
};
entity Biere : Boisson {
color : Association to BiereColor;
@Measures : {ISOCurrency : devise_code, }
prix : Decimal;
devise : Currency;
};
@cds.autoexpose @readonly
define view ColorCepage as
select from Cepage distinct {
key color as ID : String
};
@cds.autoexpose @readonly
define view TypeBoisson as
select from Vin distinct {
key type as ID : String
};
@cds.autoexpose @readonly : true
entity RetentionStatus : CodeList {
key code : String(1) enum {
ToGrowOld = 'A';
AtMaturity = 'B';
AtThePeak = 'C';
InDecline = 'D';
NotApplicable = 'E';
} default 'E';
criticality : Integer; // 1:red colour 2: yellow colour, 3: green colour, 0: unknown
};
@cds.autoexpose @readonly : true
entity AvailabilityStatus : CodeList {
key code : String(1) enum {
InStock = 'A';
SoldOut = 'B';
ToBeDelivered = 'C';
} default 'A';
criticality : Integer; // 1:red colour 2: yellow colour, 3: green colour, 0: unknown
};
entity Cave @(assert.unique : {Cave : [
vin,
createdBy
]}) : cuid, managed {
vin : Association to one Vin;
@Measures : {Unit : '{i18n>bottles}'}
quantity : Integer;
rating : Decimal(2, 1)@assert.range : [
0.0,
5.0
];
comment : String(250);
to_positions : Association to many Position
on to_positions.cave = $self;
};
@cds.autoexpose @readonly @cds.odata.valuelist
entity Region {
key subregion : String(25);
region : String(30);
country : Country;
};
type TechnicalBooleanFlag : Boolean @(
UI.Hidden,
Core.Computed
);
@Aggregation : {ApplySupported : {
$Type : 'Aggregation.ApplySupportedType',
PropertyRestrictions : true,
GroupableProperties : [
vin.name,
status_code,
quantity
],
AggregatableProperties : [
{
$Type : 'Aggregation.AggregatablePropertyType',
Property : vin.name,
},
{
$Type : 'Aggregation.AggregatablePropertyType',
Property : status_code,
},
{
$Type : 'Aggregation.AggregatablePropertyType',
Property : quantity,
},
],
}, }
//
//
entity LogOfDemand : cuid {
createdAt : DateTime @cds.on.insert : $now;
quantity : Integer;
vin : Association to one Vin;
@Measures : {ISOCurrency : currency_code, }
price : Decimal(6, 2);
@Measures : {ISOCurrency : currency_code, }
totalPrice : Decimal(6, 2);
currency : Currency;
status : Association to DemandStatus;
};
//
//
entity DemandStatus : CodeList {
key code : String(1) enum {
Completed = 'C';
Delayed = 'D';
Failed = 'F';
};
criticality : Integer; // 1:red colour 2: yellow colour, 3: green colour, 0: unknown
};
//
//
entity LogOfEvent : cuid {
createdAt : DateTime @cds.on.insert : $now;
name : String;
};
//
//
@cds.autoexpose
entity Position : cuid, managed {
positionX : Integer;
positionY : Integer;
cave : Association to Cave;
};