Skip to content

Commit 3533b20

Browse files
Clean up Hierarchies (#471)
Minor clean up after Fiori Demo
1 parent ccfec6c commit 3533b20

File tree

6 files changed

+11
-26
lines changed

6 files changed

+11
-26
lines changed

app/admin/fiori-service.cds

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ annotate AdminService.GenreHierarchy with {
9797
ID @UI.Hidden;
9898
};
9999

100-
@Hierarchy.RecursiveHierarchyActions #GenreHierarchy: {
100+
annotate AdminService.GenreHierarchy with @Hierarchy.RecursiveHierarchyActions #GenreHierarchy: {
101101
$Type : 'Hierarchy.RecursiveHierarchyActionsType',
102102
// any name can be the action name with namespace/no bound action name
103103
ChangeNextSiblingAction: 'AdminService.moveSibling',
104-
}
104+
};
105105

106106
annotate AdminService.GenreHierarchy with @UI: {
107107
PresentationVariant #VH: {
@@ -210,8 +210,6 @@ annotate AdminService.ContentsHierarchy with @Hierarchy.RecursiveHierarchy#Conte
210210
LimitedDescendantCount: LimitedDescendantCount,
211211
DistanceFromRoot: DistanceFromRoot,
212212
DrillState: DrillState,
213-
Matched: Matched,
214-
MatchedDescendantCount: MatchedDescendantCount,
215213
LimitedRank: LimitedRank
216214
};
217215

app/browse-genres/fiori-service.cds

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ annotate CatalogService.GenreHierarchy with @Hierarchy.RecursiveHierarchy#GenreH
1616
LimitedDescendantCount: LimitedDescendantCount,
1717
DistanceFromRoot: DistanceFromRoot,
1818
DrillState: DrillState,
19-
Matched: Matched,
20-
MatchedDescendantCount: MatchedDescendantCount,
2119
LimitedRank: LimitedRank
2220
};

app/genres/fiori-service.cds

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ annotate AdminService.GenreHierarchy with @Aggregation.RecursiveHierarchy#GenreH
1717
LimitedDescendantCount: LimitedDescendantCount,
1818
DistanceFromRoot: DistanceFromRoot,
1919
DrillState: DrillState,
20-
Matched: Matched,
21-
MatchedDescendantCount: MatchedDescendantCount,
2220
LimitedRank: LimitedRank
2321
};

db/books.cds

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
namespace my.bookshop;
22

3-
using {
4-
Currency,
5-
sap,
6-
managed,
7-
cuid
8-
} from '@sap/cds/common';
3+
using {Currency, sap, managed, cuid} from '@sap/cds/common';
94
using my.bookshop.Reviews from './reviews';
105
using my.bookshop.TechnicalBooleanFlag from './common';
6+
using {my.common.Hierarchy as Hierarchy} from './hierarchy';
117

128
@fiori.draft.enabled
139
entity Books : cuid, managed {
@@ -50,17 +46,20 @@ annotate Authors with
5046
/**
5147
* Hierarchically organized Code List for Genres
5248
*/
53-
entity Genres : sap.common.CodeList {
49+
entity Genres : sap.common.CodeList, Hierarchy {
5450
key ID : UUID;
55-
siblingRank : Integer;
51+
// move siblings
52+
siblingRank : Integer;
5653
parent : Association to Genres;
54+
// for cascade delete
5755
children : Composition of many Genres on children.parent = $self;
5856
}
5957

58+
6059
/**
6160
* Hierarchically organized entity for Contents
6261
*/
63-
entity Contents {
62+
entity Contents: Hierarchy {
6463
key ID : UUID;
6564
name : String;
6665
page : Integer;
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ aspect Hierarchy {
44
virtual LimitedDescendantCount : Integer64;
55
virtual DistanceFromRoot : Integer64;
66
virtual DrillState : String;
7-
virtual Matched : Boolean;
8-
virtual MatchedDescendantCount : Integer64;
97
virtual LimitedRank : Integer64;
108
}
119

@@ -14,16 +12,12 @@ annotate Hierarchy with @Capabilities.FilterRestrictions.NonFilterableProperties
1412
'LimitedDescendantCount',
1513
'DistanceFromRoot',
1614
'DrillState',
17-
'Matched',
18-
'MatchedDescendantCount',
1915
'LimitedRank'
2016
];
2117

2218
annotate Hierarchy with @Capabilities.SortRestrictions.NonSortableProperties: [
2319
'LimitedDescendantCount',
2420
'DistanceFromRoot',
2521
'DrillState',
26-
'Matched',
27-
'MatchedDescendantCount',
2822
'LimitedRank'
2923
];

srv/admin-service.cds

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using {sap.common.Languages as CommonLanguages, cuid} from '@sap/cds/common';
22
using {my.bookshop as my} from '../db/index';
33
using {sap.changelog as changelog} from 'com.sap.cds/change-tracking';
4-
using {my.common.Hierarchy as Hierarchy} from './hierarchy';
54
using {sap.attachments.Attachments} from 'com.sap.cds/cds-feature-attachments';
65

76
extend my.Orders with changelog.changeTracked;
8-
extend my.Genres with Hierarchy;
97

108
@path: 'admin'
119
@odata.apply.transformations
@@ -26,12 +24,12 @@ service AdminService @(requires: 'admin') {
2624
entity GenreHierarchy as projection on my.Genres
2725
excluding {children} order by siblingRank
2826
actions {
27+
// Custom Handler -> HierarchySiblingActionHandler.java
2928
// Experimental UI feature, see:
3029
// https://github.com/SAP/odata-vocabularies/blob/main/vocabularies/Hierarchy.md#template_changenextsiblingaction-experimental
3130
action moveSibling(NextSibling : NextSibling);
3231
};
3332

34-
extend my.Contents with Hierarchy;
3533
entity ContentsHierarchy as projection on my.Contents;
3634

3735
@cds.persistence.skip

0 commit comments

Comments
 (0)