Skip to content

Commit 6b1c4d3

Browse files
authored
New Changelog schema
2 parents cc6b140 + c0de3b4 commit 6b1c4d3

File tree

1 file changed

+17
-48
lines changed

1 file changed

+17
-48
lines changed

index.cds

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,91 +12,60 @@ aspect aspect @(
1212
Target: 'changes/@UI.PresentationVariant'
1313
}]
1414
) {
15-
changes : Association to many ChangeView on changes.entityKey = ID;
15+
changes : Association to many ChangeLog on changes.entityKey = ID;
1616
key ID : UUID;
1717
}
1818

1919

20-
entity Changes : managed {
21-
22-
key ID : UUID @UI.Hidden;
20+
type Changes : {
21+
// TODO: Which of these is the Business meaningful object id?
22+
entityKey : String @title: '{i18n>Changes.entityID}';
2323
keys : String @title: '{i18n>Changes.keys}';
2424
attribute : String @title: '{i18n>Changes.attribute}';
2525
valueChangedFrom : String @title: '{i18n>Changes.valueChangedFrom}';
2626
valueChangedTo : String @title: '{i18n>Changes.valueChangedTo}';
27-
28-
// Business meaningful object id
29-
entityID : String @title: '{i18n>Changes.entityID}';
30-
entity : String @title: '{i18n>Changes.entity}';
27+
entityName : String @title: '{i18n>Changes.entity}';
3128
serviceEntity : String @title: '{i18n>Changes.serviceEntity}';
3229

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}';
37-
3830
@title: '{i18n>Changes.modification}'
3931
modification : String enum {
4032
create = 'Create';
4133
update = 'Edit';
4234
delete = 'Delete';
4335
};
44-
45-
valueDataType : String @title: '{i18n>Changes.valueDataType}';
46-
changeLog : Association to ChangeLog @title: '{i18n>ChangeLog.ID}';
4736
}
4837

49-
// REVISIT: Get rid of that
38+
//TODO: Move Business meaingful key to ChangeLog Table
39+
@cds.autoexpose
5040
entity ChangeLog : managed, cuid {
5141
entity : String @title: '{i18n>ChangeLog.entity}';
5242
entityKey : UUID @title: '{i18n>ChangeLog.entityKey}';
5343
serviceEntity : String @title: '{i18n>ChangeLog.serviceEntity}';
54-
changes : Composition of many Changes on changes.changeLog = $self;
44+
@cds.api.ignore
45+
changes : many Changes;
46+
changeslist: Composition of many changeslist;
5547
}
5648

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-
};
75-
49+
@cds.persistence.skip
50+
entity changeslist: Changes {};
7651

77-
annotate ChangeView with @(UI: {
52+
annotate ChangeLog with @(UI: {
7853
PresentationVariant: {
7954
Visualizations: ['@UI.LineItem'],
8055
RequestAtLeast: [
81-
parentKey,
82-
serviceEntity,
83-
serviceEntityPath
56+
entityKey,
57+
entity
8458
],
8559
SortOrder : [{
8660
Property : createdAt,
8761
Descending: true
8862
}],
8963
},
9064
LineItem : [
91-
{ Value: objectID },
65+
{ Value: entityKey },
9266
{ Value: entity },
93-
{ Value: parentObjectID },
94-
{ Value: attribute },
95-
{ Value: valueChangedTo },
96-
{ Value: valueChangedFrom },
9767
{ Value: createdBy },
98-
{ Value: createdAt },
99-
{ Value: modification }
68+
{ Value: createdAt }
10069
],
10170
DeleteHidden : true,
10271
});

0 commit comments

Comments
 (0)