|
23 | 23 | import com.sap.cds.ql.Update; |
24 | 24 | import com.sap.cds.ql.Upsert; |
25 | 25 | import com.sap.cds.ql.cqn.CqnAnalyzer; |
| 26 | +import com.sap.cds.ql.cqn.CqnStructuredTypeRef; |
26 | 27 | import com.sap.cds.reflect.CdsModel; |
27 | 28 | import com.sap.cds.services.ErrorStatuses; |
28 | 29 | import com.sap.cds.services.EventContext; |
|
43 | 44 | import cds.gen.adminservice.AdminService_; |
44 | 45 | import cds.gen.adminservice.Books; |
45 | 46 | import cds.gen.adminservice.BooksAddToOrderContext; |
| 47 | +import cds.gen.adminservice.BooksCovers; |
46 | 48 | import cds.gen.adminservice.Books_; |
47 | 49 | import cds.gen.adminservice.OrderItems; |
48 | 50 | import cds.gen.adminservice.OrderItems_; |
@@ -293,6 +295,12 @@ public void addBooksViaCsv(CdsUpdateEventContext context, Upload upload) { |
293 | 295 | context.setResult(Arrays.asList(upload)); |
294 | 296 | } |
295 | 297 |
|
| 298 | + @Before(event = {CqnService.EVENT_CREATE, CqnService.EVENT_UPDATE, DraftService.EVENT_DRAFT_NEW, DraftService.EVENT_DRAFT_PATCH}) |
| 299 | + public void restoreCoversUpId(CqnStructuredTypeRef ref, BooksCovers cover) { |
| 300 | + // restore up__ID, which is not provided via OData due to containment |
| 301 | + cover.setUpId((String) analyzer.analyze(ref).rootKeys().get(Books.ID)); |
| 302 | + } |
| 303 | + |
296 | 304 | private Supplier<ServiceException> notFound(String message) { |
297 | 305 | return () -> new ServiceException(ErrorStatuses.NOT_FOUND, message); |
298 | 306 | } |
|
0 commit comments