Skip to content

Commit c8d1e2d

Browse files
committed
Minor cleanup of cds model
1 parent 5a88f3e commit c8d1e2d

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

index.cds

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,75 +4,75 @@ namespace sap.changelog;
44
/**
55
* Used in cds-plugin.js as template for tracked entities
66
*/
7-
aspect aspect @(
8-
UI.Facets: [{
9-
$Type : 'UI.ReferenceFacet',
10-
ID : 'ChangeHistoryFacet',
11-
Label : '{i18n>ChangeHistoryList}',
12-
Target: 'changes/@UI.PresentationVariant'
13-
}]
14-
) {
7+
aspect aspect @(UI.Facets: [{
8+
$Type : 'UI.ReferenceFacet',
9+
ID : 'ChangeHistoryFacet',
10+
Label : '{i18n>ChangeHistoryList}',
11+
Target: 'changes/@UI.PresentationVariant'
12+
}]) {
13+
// Essentially: Association to many Changes on changes.changeLog.entityKey = ID;
1514
changes : Association to many ChangeView on changes.entityKey = ID;
16-
key ID : UUID;
15+
key ID : UUID;
1716
}
1817

1918

20-
entity Changes : managed {
19+
// This is a helper view to flatten the assoc path to the entityKey
20+
view ChangeView as
21+
select from Changes {
22+
*,
23+
entityID as objectID, // no clue why we have to rename this?
24+
parentEntityID as parentObjectID, // no clue why we have to rename this?
25+
changeLog.entityKey as entityKey, // flattening assoc path -> this is the main reason for having this helper view
26+
}
27+
excluding {
28+
entityID,
29+
parentEntityID,
30+
};
2131

22-
key ID : UUID @UI.Hidden;
23-
keys : String @title: '{i18n>Changes.keys}';
24-
attribute : String @title: '{i18n>Changes.attribute}';
25-
valueChangedFrom : String @title: '{i18n>Changes.valueChangedFrom}';
26-
valueChangedTo : String @title: '{i18n>Changes.valueChangedTo}';
32+
/**
33+
* Top-level changes entity, e.g. UPDATE Incident by, at, ...
34+
*/
35+
entity ChangeLog : managed, cuid {
36+
serviceEntity : String @title: '{i18n>ChangeLog.serviceEntity}'; // definition name of target entity (on service level) - e.g. ProcessorsService.Incidents
37+
entity : String @title: '{i18n>ChangeLog.entity}'; // definition name of target entity (on db level) - e.g. sap.capire.incidents.Incidents
38+
entityKey : UUID @title: '{i18n>ChangeLog.entityKey}'; // primary key of target entity, e.g. Incidents.ID
39+
changes : Composition of many Changes
40+
on changes.changeLog = $self;
41+
}
2742

28-
// Business meaningful object id
29-
entityID : String @title: '{i18n>Changes.entityID}';
30-
entity : String @title: '{i18n>Changes.entity}';
31-
serviceEntity : String @title: '{i18n>Changes.serviceEntity}';
3243

33-
// Business meaningful parent object id
34-
parentEntityID : String @title: '{i18n>Changes.parentEntityID}';
35-
parentKey : UUID @title: '{i18n>Changes.parentKey}';
36-
serviceEntityPath : String @title: '{i18n>Changes.serviceEntityPath}';
44+
/**
45+
* Attribute-level Changes with simple capturing of one-level
46+
* composition trees in parent... elements.
47+
*/
48+
entity Changes : managed {
3749

38-
@title: '{i18n>Changes.modification}'
39-
modification : String enum {
40-
create = 'Create';
41-
update = 'Edit';
42-
delete = 'Delete';
43-
};
50+
key ID : UUID @UI.Hidden;
51+
keys : String @title: '{i18n>Changes.keys}';
52+
attribute : String @title: '{i18n>Changes.attribute}';
53+
valueChangedFrom : String @title: '{i18n>Changes.valueChangedFrom}';
54+
valueChangedTo : String @title: '{i18n>Changes.valueChangedTo}';
4455

45-
valueDataType : String @title: '{i18n>Changes.valueDataType}';
46-
changeLog : Association to ChangeLog @title: '{i18n>ChangeLog.ID}';
47-
}
56+
// Business meaningful object id
57+
entityID : String @title: '{i18n>Changes.entityID}';
58+
entity : String @title: '{i18n>Changes.entity}'; // similar to ChangeLog.entity, but could be nested entity in a composition tree
59+
serviceEntity : String @title: '{i18n>Changes.serviceEntity}'; // similar to ChangeLog.serviceEntity, but could be nested entity in a composition tree
4860

49-
// REVISIT: Get rid of that
50-
entity ChangeLog : managed, cuid {
51-
entity : String @title: '{i18n>ChangeLog.entity}';
52-
entityKey : UUID @title: '{i18n>ChangeLog.entityKey}';
53-
serviceEntity : String @title: '{i18n>ChangeLog.serviceEntity}';
54-
changes : Composition of many Changes on changes.changeLog = $self;
55-
}
61+
// Business meaningful parent object id
62+
parentEntityID : String @title: '{i18n>Changes.parentEntityID}';
63+
parentKey : UUID @title: '{i18n>Changes.parentKey}';
64+
serviceEntityPath : String @title: '{i18n>Changes.serviceEntityPath}';
5665

57-
// REVISIT: Get rid of that
58-
view ChangeView as
59-
select from Changes {
60-
ID as ID @UI.Hidden,
61-
attribute as attribute,
62-
entityID as objectID,
63-
entity as entity,
64-
serviceEntity as serviceEntity,
65-
parentEntityID as parentObjectID,
66-
parentKey as parentKey,
67-
valueChangedFrom as valueChangedFrom,
68-
valueChangedTo as valueChangedTo,
69-
modification as modification,
70-
createdBy as createdBy,
71-
createdAt as createdAt,
72-
changeLog.entityKey as entityKey,
73-
serviceEntityPath as serviceEntityPath @UI.Hidden,
74-
};
66+
@title: '{i18n>Changes.modification}'
67+
modification : String enum {
68+
create = 'Create';
69+
update = 'Edit';
70+
delete = 'Delete';
71+
};
7572

73+
valueDataType : String @title: '{i18n>Changes.valueDataType}';
74+
changeLog : Association to ChangeLog @title: '{i18n>ChangeLog.ID}';
75+
}
7676

7777
annotate ChangeView with @(UI: {
7878
PresentationVariant: {
@@ -88,15 +88,15 @@ annotate ChangeView with @(UI: {
8888
}],
8989
},
9090
LineItem : [
91-
{ Value: objectID },
92-
{ Value: entity },
93-
{ Value: parentObjectID },
94-
{ Value: attribute },
95-
{ Value: valueChangedTo },
96-
{ Value: valueChangedFrom },
97-
{ Value: createdBy },
98-
{ Value: createdAt },
99-
{ Value: modification }
91+
{Value: objectID},
92+
{Value: entity},
93+
{Value: parentObjectID},
94+
{Value: attribute},
95+
{Value: valueChangedTo},
96+
{Value: valueChangedFrom},
97+
{Value: createdBy},
98+
{Value: createdAt},
99+
{Value: modification}
100100
],
101101
DeleteHidden : true,
102102
});

0 commit comments

Comments
 (0)