diff --git a/app/genres/fiori-service.cds b/app/genres/fiori-service.cds
index d195d935..77b132a5 100644
--- a/app/genres/fiori-service.cds
+++ b/app/genres/fiori-service.cds
@@ -7,8 +7,8 @@ using AdminService from '../../srv/admin-service';
annotate AdminService.GenreHierarchy with @Aggregation.RecursiveHierarchy#GenreHierarchy: {
$Type: 'Aggregation.RecursiveHierarchyType',
- NodeProperty: node_id, // identifies a node
- ParentNavigationProperty: parent // navigates to a node's parent
+ NodeProperty: ID, // identifies a node
+ ParentNavigationProperty: parnt // navigates to a node's parent
};
annotate AdminService.GenreHierarchy with @Hierarchy.RecursiveHierarchy#GenreHierarchy: {
diff --git a/db/books.cds b/db/books.cds
index a4d8ba44..67f9fd88 100644
--- a/db/books.cds
+++ b/db/books.cds
@@ -47,9 +47,9 @@ annotate Authors with
*/
entity Genres {
key ID : Integer;
- node : Integer not null;
- parent_node : Integer default 0;
name : localized String(255);
descr : localized String(1000);
- parent : Association to one Genres on parent.node = parent_node;
+ parnt : Association to Genres;
+ children : Composition of many Genres
+ on children.parnt = $self;
}
diff --git a/db/data/my.bookshop-Genres.csv b/db/data/my.bookshop-Genres.csv
index 044b2b47..f498be2d 100644
--- a/db/data/my.bookshop-Genres.csv
+++ b/db/data/my.bookshop-Genres.csv
@@ -1,16 +1,16 @@
-ID;parent_node;name;node
-10;;Fiction;10
-11;10;Drama;11
-12;10;Poetry;12
-13;10;Fantasy;13
-14;10;Science Fiction;14
-15;10;Romance;15
-16;10;Mystery;16
-17;10;Thriller;17
-18;10;Dystopia;18
-19;10;Fairy Tale;19
-20;;Non-Fiction;20
-21;20;Biography;21
-22;21;Autobiography;22
-23;20;Essay;23
-24;20;Speech;24
\ No newline at end of file
+ID;parnt_ID;name
+10;;Fiction
+11;10;Drama
+12;10;Poetry
+13;10;Fantasy
+14;10;Science Fiction
+15;10;Romance
+16;10;Mystery
+17;10;Thriller
+18;10;Dystopia
+19;10;Fairy Tale
+20;;Non-Fiction
+21;20;Biography
+22;21;Autobiography
+23;20;Essay
+24;20;Speech
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 98a241b6..9dac44cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,11 +23,11 @@
21
- 3.4.0
+ 3.5.0
5.13.0
3.5.3
3.8.4
- 8.4.1
+ 8.5.0
diff --git a/srv/admin-service.cds b/srv/admin-service.cds
index 7709ebd0..32fb80e8 100644
--- a/srv/admin-service.cds
+++ b/srv/admin-service.cds
@@ -16,11 +16,7 @@ service AdminService @(requires : 'admin') {
entity Orders as select from my.Orders;
extend my.Genres with Hierarchy;
- entity GenreHierarchy as projection on my.Genres {
- node as node_id,
- parent_node as parent_id,
- *
- } excluding { node, parent_node }
+ entity GenreHierarchy as projection on my.Genres;
@cds.persistence.skip
entity Upload @odata.singleton {
diff --git a/srv/src/main/java/my/bookshop/handlers/HierarchyHandler.java b/srv/src/main/java/my/bookshop/handlers/HierarchyHandler.java
index 6780d8d3..d9ea0fa4 100644
--- a/srv/src/main/java/my/bookshop/handlers/HierarchyHandler.java
+++ b/srv/src/main/java/my/bookshop/handlers/HierarchyHandler.java
@@ -39,6 +39,8 @@
import cds.gen.adminservice.GenreHierarchy;
import cds.gen.adminservice.GenreHierarchy_;
+import static cds.gen.adminservice.AdminService_.GENRE_HIERARCHY;
+
@Component
@Profile("default")
@ServiceName(AdminService_.CDS_NAME)
@@ -47,8 +49,8 @@ public class HierarchyHandler implements EventHandler {
private final PersistenceService db;
HierarchyHandler(PersistenceService db) {
- this.db = db;
- }
+ this.db = db;
+ }
@Before(event = CqnService.EVENT_READ, entity = GenreHierarchy_.CDS_NAME)
public void readGenreHierarchy(CdsReadEventContext event) {
@@ -58,12 +60,12 @@ public void readGenreHierarchy(CdsReadEventContext event) {
if (trafos.size() < 1) {
return;
}
-
+
if (getTopLevels(trafos) instanceof CqnTopLevelsTransformation topLevels) {
result = topLevels(topLevels, CQL.TRUE);
} else if (trafos.get(0) instanceof CqnDescendantsTransformation descendants) {
result = handleDescendants(descendants);
- } else if (trafos.get(0) instanceof CqnAncestorsTransformation ancestors) {
+ } else if (trafos.get(0) instanceof CqnAncestorsTransformation ancestors) {
if (trafos.size() == 2 && trafos.get(1) instanceof CqnTopLevelsTransformation topLevels) {
result = handleAncestors(ancestors, topLevels);
} else if (trafos.size() == 3 && trafos.get(2) instanceof CqnTopLevelsTransformation topLevels) {
@@ -77,7 +79,8 @@ public void readGenreHierarchy(CdsReadEventContext event) {
private CqnTopLevelsTransformation getTopLevels(List trafos) {
if (trafos.get(0) instanceof CqnTopLevelsTransformation topLevels) {
return topLevels;
- } else if (trafos.size() == 2 && trafos.get(0) instanceof CqnOrderByTransformation && trafos.get(1) instanceof CqnTopLevelsTransformation topLevels) {
+ } else if (trafos.size() == 2 && trafos.get(0) instanceof CqnOrderByTransformation
+ && trafos.get(1) instanceof CqnTopLevelsTransformation topLevels) {
return topLevels;
}
return null;
@@ -92,16 +95,17 @@ private void setResult(CdsReadEventContext event, List result) {
}
private void addDrillState(List ghs) {
- List ids = ghs.stream().map(gh -> gh.getNodeId()).toList();
- Set parents = ghs.stream().map(gh -> gh.getParentId()).filter(p -> p != 0).collect(Collectors.toSet());
- CqnSelect q = Select.from(AdminService_.GENRE_HIERARCHY, gh -> gh.parent()).columns(gh -> gh.node_id())
- .where(gh -> gh.node_id().in(ids));
+ List ids = ghs.stream().map(gh -> gh.getId()).toList();
+ Set parents = ghs.stream().map(gh -> gh.getParntId()).filter(p -> p != null)
+ .collect(Collectors.toSet());
+ CqnSelect q = Select.from(GENRE_HIERARCHY).columns(gh -> gh.parnt_ID().as("id"))
+ .where(gh -> gh.parnt_ID().in(ids));
Set