1 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2
3 import se.citerus.dddsample.domain.model.cargo.Cargo;
4 import se.citerus.dddsample.domain.model.cargo.Leg;
5 import se.citerus.dddsample.domain.model.cargo.RoutingStatus;
6 import se.citerus.dddsample.interfaces.booking.facade.dto.CargoRoutingDTO;
7
8
9
10
11 public class CargoRoutingDTOAssembler {
12
13
14
15
16
17
18 public CargoRoutingDTO toDTO(final Cargo cargo) {
19 final CargoRoutingDTO dto = new CargoRoutingDTO(
20 cargo.trackingId().idString(),
21 cargo.origin().unLocode().idString(),
22 cargo.routeSpecification().destination().unLocode().idString(),
23 cargo.routeSpecification().arrivalDeadline(),
24 cargo.delivery().routingStatus().sameValueAs(RoutingStatus.MISROUTED));
25 for (Leg leg : cargo.itinerary().legs()) {
26 dto.addLeg(
27 leg.voyage().voyageNumber().idString(),
28 leg.loadLocation().unLocode().idString(),
29 leg.unloadLocation().unLocode().idString(),
30 leg.loadTime(),
31 leg.unloadTime());
32 }
33 return dto;
34 }
35
36 }