@@ -4,75 +4,75 @@ namespace sap.changelog;
4
4
/**
5
5
* Used in cds-plugin.js as template for tracked entities
6
6
*/
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;
15
14
changes : Association to many ChangeView on changes .entityKey = ID ;
16
- key ID : UUID ;
15
+ key ID : UUID ;
17
16
}
18
17
19
18
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
+ };
21
31
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
+ }
27
42
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} ' ;
32
43
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 {
37
49
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} ' ;
44
55
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
48
60
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} ' ;
56
65
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
+ };
75
72
73
+ valueDataType : String @ title : ' {i18n>Changes.valueDataType} ' ;
74
+ changeLog : Association to ChangeLog @ title : ' {i18n>ChangeLog.ID} ' ;
75
+ }
76
76
77
77
annotate ChangeView with @ (UI : {
78
78
PresentationVariant : {
@@ -88,15 +88,15 @@ annotate ChangeView with @(UI: {
88
88
}],
89
89
},
90
90
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 }
100
100
],
101
101
DeleteHidden : true ,
102
102
});
0 commit comments