|
16 | 16 | import java.util.function.Supplier; |
17 | 17 | import java.util.stream.Stream; |
18 | 18 |
|
| 19 | +import org.springframework.core.env.Environment; |
19 | 20 | import org.springframework.stereotype.Component; |
20 | 21 |
|
21 | 22 | import com.sap.cds.Result; |
|
28 | 29 | import com.sap.cds.services.ErrorStatuses; |
29 | 30 | import com.sap.cds.services.EventContext; |
30 | 31 | import com.sap.cds.services.ServiceException; |
| 32 | +import com.sap.cds.services.cds.CdsReadEventContext; |
31 | 33 | import com.sap.cds.services.cds.CdsUpdateEventContext; |
32 | 34 | import com.sap.cds.services.cds.CqnService; |
33 | 35 | import com.sap.cds.services.draft.DraftCancelEventContext; |
|
46 | 48 | import cds.gen.adminservice.BooksAddToOrderContext; |
47 | 49 | import cds.gen.adminservice.BooksCovers; |
48 | 50 | import cds.gen.adminservice.Books_; |
| 51 | +import cds.gen.adminservice.Info; |
| 52 | +import cds.gen.adminservice.Info_; |
49 | 53 | import cds.gen.adminservice.OrderItems; |
50 | 54 | import cds.gen.adminservice.OrderItems_; |
51 | 55 | import cds.gen.adminservice.Orders; |
|
64 | 68 | class AdminServiceHandler implements EventHandler { |
65 | 69 |
|
66 | 70 | private final AdminService.Draft adminService; |
67 | | - |
68 | 71 | private final PersistenceService db; |
69 | | - |
70 | 72 | private final Messages messages; |
71 | | - |
72 | 73 | private final CqnAnalyzer analyzer; |
| 74 | + private final Environment env; |
73 | 75 |
|
74 | | - AdminServiceHandler(AdminService.Draft adminService, PersistenceService db, Messages messages, CdsModel model) { |
| 76 | + AdminServiceHandler(AdminService.Draft adminService, PersistenceService db, Messages messages, CdsModel model, Environment env) { |
75 | 77 | this.adminService = adminService; |
76 | 78 | this.db = db; |
77 | 79 | this.messages = messages; |
| 80 | + this.env = env; |
78 | 81 |
|
79 | 82 | // model is a tenant-dependant model proxy |
80 | 83 | this.analyzer = CqnAnalyzer.create(model); |
@@ -301,6 +304,13 @@ public void restoreCoversUpId(CqnStructuredTypeRef ref, BooksCovers cover) { |
301 | 304 | cover.setUpId((String) analyzer.analyze(ref).rootKeys().get(Books.ID)); |
302 | 305 | } |
303 | 306 |
|
| 307 | + @On(event = CqnService.EVENT_READ, entity = Info_.CDS_NAME) |
| 308 | + public Info readInfo(CdsReadEventContext context) { |
| 309 | + Info info = Info.create(); |
| 310 | + info.setHideTreeTable(!env.matchesProfiles("cloud")); |
| 311 | + return info; |
| 312 | + } |
| 313 | + |
304 | 314 | private Supplier<ServiceException> notFound(String message) { |
305 | 315 | return () -> new ServiceException(ErrorStatuses.NOT_FOUND, message); |
306 | 316 | } |
|
0 commit comments