|
|
@@ -1,7 +1,6 @@
|
|
1
|
1
|
package se.citerus.dddsample.interfaces.booking.facade;
|
|
2
|
2
|
|
|
3
|
3
|
import org.apache.log4j.Logger;
|
|
4
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
5
|
4
|
import se.citerus.dddsample.application.BookingService;
|
|
6
|
5
|
import se.citerus.dddsample.domain.model.cargo.Cargo;
|
|
7
|
6
|
import se.citerus.dddsample.domain.model.cargo.CargoRepository;
|
|
|
@@ -20,6 +19,7 @@ import se.citerus.dddsample.interfaces.booking.facade.dto.assembler.LocationDTOA
|
|
20
|
19
|
|
|
21
|
20
|
import java.rmi.RemoteException;
|
|
22
|
21
|
import java.util.ArrayList;
|
|
|
22
|
+import java.util.Date;
|
|
23
|
23
|
import java.util.List;
|
|
24
|
24
|
|
|
25
|
25
|
|
|
|
@@ -38,27 +38,25 @@ public class BookingServiceFacadeImpl implements BookingServiceFacade {
|
|
38
|
38
|
private VoyageRepository voyageRepository;
|
|
39
|
39
|
private final Logger logger = Logger.getLogger(BookingServiceFacadeImpl.class);
|
|
40
|
40
|
|
|
41
|
|
- @Transactional(readOnly = true)
|
|
42
|
41
|
public List<LocationDTO> listShippingLocations() {
|
|
43
|
42
|
final List<Location> allLocations = locationRepository.findAll();
|
|
44
|
43
|
final LocationDTOAssembler assembler = new LocationDTOAssembler();
|
|
45
|
44
|
return assembler.toDTOList(allLocations);
|
|
46
|
45
|
}
|
|
47
|
46
|
|
|
48
|
|
- @Transactional(readOnly = false)
|
|
49
|
47
|
public String bookNewCargo(String origin, String destination) {
|
|
50
|
|
- TrackingId trackingId = bookingService.bookNewCargo(new UnLocode(origin), new UnLocode(destination));
|
|
|
48
|
+ // TODO push date to parameter
|
|
|
49
|
+ Date arrivalDeadline = new Date();
|
|
|
50
|
+ TrackingId trackingId = bookingService.bookNewCargo(new UnLocode(origin), new UnLocode(destination), arrivalDeadline);
|
|
51
|
51
|
return trackingId.idString();
|
|
52
|
52
|
}
|
|
53
|
53
|
|
|
54
|
|
- @Transactional(readOnly = true)
|
|
55
|
54
|
public CargoRoutingDTO loadCargoForRouting(String trackingId) {
|
|
56
|
55
|
final Cargo cargo = cargoRepository.find(new TrackingId(trackingId));
|
|
57
|
56
|
final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
|
|
58
|
57
|
return assembler.toDTO(cargo);
|
|
59
|
58
|
}
|
|
60
|
59
|
|
|
61
|
|
- @Transactional(readOnly = false)
|
|
62
|
60
|
public void assignCargoToRoute(String trackingId, ItineraryCandidateDTO itineraryCandidateDTO) {
|
|
63
|
61
|
final Itinerary itinerary = new ItineraryCandidateDTOAssembler().fromDTO(itineraryCandidateDTO, voyageRepository, locationRepository);
|
|
64
|
62
|
|
|
|
@@ -73,7 +71,6 @@ public class BookingServiceFacadeImpl implements BookingServiceFacade {
|
|
73
|
71
|
logger.info("Assigned cargo " + trackingId + " to new route");
|
|
74
|
72
|
}
|
|
75
|
73
|
|
|
76
|
|
- @Transactional(readOnly = true)
|
|
77
|
74
|
public List<CargoRoutingDTO> listAllCargos() {
|
|
78
|
75
|
final List<Cargo> cargoList = cargoRepository.findAll();
|
|
79
|
76
|
final List<CargoRoutingDTO> dtoList = new ArrayList<CargoRoutingDTO>(cargoList.size());
|
|
|
@@ -84,7 +81,6 @@ public class BookingServiceFacadeImpl implements BookingServiceFacade {
|
|
84
|
81
|
return dtoList;
|
|
85
|
82
|
}
|
|
86
|
83
|
|
|
87
|
|
- @Transactional(readOnly = true)
|
|
88
|
84
|
public List<ItineraryCandidateDTO> requestPossibleRoutesForCargo(String trackingId) throws RemoteException {
|
|
89
|
85
|
final List<Itinerary> itineraries = bookingService.requestPossibleRoutesForCargo(new TrackingId(trackingId));
|
|
90
|
86
|
|