Skip to content

Commit 4ef3a3c

Browse files
committed
expand handler
1 parent 1ce8ee1 commit 4ef3a3c

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

app/admin/fiori-service.cds

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ annotate AdminService.GenreHierarchy with @UI: {
104104
LineItem : [{
105105
$Type: 'UI.DataField',
106106
Value: name,
107-
}]
107+
Label : 'Genre'
108+
}],
108109
};
109110

110111
annotate AdminService.ContentsHierarchy with @UI: {
@@ -123,8 +124,8 @@ annotate AdminService.ContentsHierarchy with @UI: {
123124
}],
124125
HeaderInfo : {
125126
$Type : 'UI.HeaderInfoType',
126-
TypeName : 'Organization Level',
127-
TypeNamePlural: 'Organization Levels',
127+
TypeName : 'Contents Level',
128+
TypeNamePlural: 'Contents Levels',
128129
Title : {
129130
$Type: 'UI.DataField',
130131
Value: name,

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package my.bookshop.handlers;
2-
32
import java.util.List;
43

54
import org.springframework.context.annotation.Profile;
@@ -21,10 +20,12 @@
2120
import cds.gen.adminservice.GenreHierarchy_;
2221

2322

23+
2424
@Component
2525
@ServiceName(AdminService_.CDS_NAME)
2626
/**
2727
* For testing purposes of modifying requests for hierarchies
28+
* Remove when generic solution for $apply and $expand is available
2829
*/
2930
@Profile("hybrid")
3031
public class HierarchyExpandHandler implements EventHandler {
@@ -37,12 +38,15 @@ void removeExpand(CdsReadEventContext event) {
3738
}
3839
if (trafos.get(0) instanceof CqnAncestorsTransformation) {
3940
CqnSelect original = event.getCqn();
40-
CqnSelect copy = CQL.copy(original, new Modifier() {
41-
public List<CqnSelectListItem> items(List<CqnSelectListItem> items) {
42-
return items.stream().filter(i -> !i.isExpand()).toList();
43-
}
44-
});
41+
Boolean isExpand = original.items().stream().filter(CqnSelectListItem::isExpand).findAny().isPresent();
42+
if (isExpand) {
43+
CqnSelect copy = CQL.copy(original, new Modifier() {
44+
public List<CqnSelectListItem> items(List<CqnSelectListItem> items) {
45+
return items.stream().filter(i -> !i.isExpand()).toList();
46+
}
47+
});
4548
event.setCqn(copy);
49+
}
4650
}
4751
event.proceed();
4852
}

0 commit comments

Comments
 (0)