Skip to content

Commit d88cced

Browse files
clean-up, fix
1 parent 736fa33 commit d88cced

File tree

6 files changed

+16
-22
lines changed

6 files changed

+16
-22
lines changed

app/admin/fiori-service.cds

Lines changed: 2 additions & 2 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: {

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ aspect Hierarchy {
44
virtual LimitedDescendantCount : Integer64;
55
virtual DistanceFromRoot : Integer64;
66
virtual DrillState : String;
7-
virtual Matched : Boolean;
8-
virtual MatchedDescendantCount : Integer64;
7+
virtual Matched : Boolean; // not used
8+
virtual MatchedDescendantCount : Integer64; // not used
99
virtual LimitedRank : Integer64;
1010
}
1111

srv/admin-service.cds

Lines changed: 2 additions & 6 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,10 @@ service AdminService @(requires: 'admin') {
2624
entity GenreHierarchy as projection on my.Genres
2725
excluding {children} order by siblingRank
2826
actions {
29-
// Experimental UI feature, see:
30-
// https://github.com/SAP/odata-vocabularies/blob/main/vocabularies/Hierarchy.md#template_changenextsiblingaction-experimental
31-
action moveSibling(NextSibling : NextSibling);
27+
// HierarchySiblingActionHandler.java
28+
action moveSibling(NextSibling : NextSibling); // to be implemented in custom handler
3229
};
3330

34-
extend my.Contents with Hierarchy;
3531
entity ContentsHierarchy as projection on my.Contents;
3632

3733
@cds.persistence.skip

srv/src/main/java/my/bookshop/handlers/AdminServiceHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.sap.cds.services.ErrorStatuses;
3030
import com.sap.cds.services.EventContext;
3131
import com.sap.cds.services.ServiceException;
32-
import com.sap.cds.services.cds.CdsReadEventContext;
3332
import com.sap.cds.services.cds.CdsUpdateEventContext;
3433
import com.sap.cds.services.cds.CqnService;
3534
import com.sap.cds.services.draft.DraftCancelEventContext;
@@ -307,7 +306,7 @@ public void restoreCoversUpId(CqnStructuredTypeRef ref, BooksCovers cover) {
307306
@On(event = CqnService.EVENT_READ, entity = Info_.CDS_NAME)
308307
public Info readInfo() {
309308
Info info = Info.create();
310-
info.setHideTreeTable(!env.matchesProfiles("cloud"));
309+
info.setHideTreeTable(!env.matchesProfiles("hybrid"));
311310
return info;
312311
}
313312

srv/src/main/java/my/bookshop/handlers/HierarchySiblingActionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* Example of a custom handler for nextSiblingAction
2828
*/
29-
@Profile("cloud")
29+
@Profile("hybrid")
3030
public class HierarchySiblingActionHandler implements EventHandler {
3131

3232
private final PersistenceService db;

0 commit comments

Comments
 (0)