September 2019
Intermediate to advanced
668 pages
15h 59m
English
Now, we can implement the composite create and delete methods!
The composite's create method will split up the aggregate product object into discrete objects for product, recommendation, and review and call the corresponding create methods in the integration layer:
@Overridepublic void createCompositeProduct(ProductAggregate body) { try { Product product = new Product(body.getProductId(), body.getName(), body.getWeight(), null); integration.createProduct(product); if (body.getRecommendations() != null) { body.getRecommendations().forEach(r -> { Recommendation recommendation = new Recommendation(body.getProductId(), r.getRecommendationId(), r.getAuthor(), r.getRate(), r.getContent(), null