|
|
@@ -8,10 +8,13 @@ import org.springframework.web.servlet.support.RequestContextUtils;
|
|
8
|
8
|
import se.citerus.dddsample.domain.model.cargo.Cargo;
|
|
9
|
9
|
import se.citerus.dddsample.domain.model.cargo.CargoRepository;
|
|
10
|
10
|
import se.citerus.dddsample.domain.model.cargo.TrackingId;
|
|
|
11
|
+import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
|
12
|
+import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
|
|
11
|
13
|
|
|
12
|
14
|
import javax.servlet.http.HttpServletRequest;
|
|
13
|
15
|
import javax.servlet.http.HttpServletResponse;
|
|
14
|
16
|
import java.util.HashMap;
|
|
|
17
|
+import java.util.List;
|
|
15
|
18
|
import java.util.Locale;
|
|
16
|
19
|
import java.util.Map;
|
|
17
|
20
|
|
|
|
@@ -33,6 +36,7 @@ import java.util.Map;
|
|
33
|
36
|
public final class CargoTrackingController extends SimpleFormController {
|
|
34
|
37
|
|
|
35
|
38
|
private CargoRepository cargoRepository;
|
|
|
39
|
+ private HandlingEventRepository handlingEventRepository;
|
|
36
|
40
|
|
|
37
|
41
|
public CargoTrackingController() {
|
|
38
|
42
|
setCommandClass(TrackCommand.class);
|
|
|
@@ -44,14 +48,16 @@ public final class CargoTrackingController extends SimpleFormController {
|
|
44
|
48
|
|
|
45
|
49
|
final TrackCommand trackCommand = (TrackCommand) command;
|
|
46
|
50
|
final String trackingIdString = trackCommand.getTrackingId();
|
|
47
|
|
-
|
|
48
|
|
- final Cargo cargo = cargoRepository.find(new TrackingId(trackingIdString));
|
|
49
|
51
|
|
|
50
|
|
- final Map<String, CargoTrackingViewAdapter> model = new HashMap();
|
|
|
52
|
+ final TrackingId trackingId = new TrackingId(trackingIdString);
|
|
|
53
|
+ final Cargo cargo = cargoRepository.find(trackingId);
|
|
|
54
|
+
|
|
|
55
|
+ final Map<String, CargoTrackingViewAdapter> model = new HashMap<String, CargoTrackingViewAdapter>();
|
|
51
|
56
|
if (cargo != null) {
|
|
52
|
57
|
final MessageSource messageSource = getApplicationContext();
|
|
53
|
58
|
final Locale locale = RequestContextUtils.getLocale(request);
|
|
54
|
|
- model.put("cargo", new CargoTrackingViewAdapter(cargo, messageSource, locale));
|
|
|
59
|
+ final List<HandlingEvent> handlingEvents = handlingEventRepository.findEventsForCargo(trackingId);
|
|
|
60
|
+ model.put("cargo", new CargoTrackingViewAdapter(cargo, messageSource, locale, handlingEvents));
|
|
55
|
61
|
} else {
|
|
56
|
62
|
errors.rejectValue("trackingId", "cargo.unknown_id", new Object[]{trackCommand.getTrackingId()}, "Unknown tracking id");
|
|
57
|
63
|
}
|
|
|
@@ -61,4 +67,9 @@ public final class CargoTrackingController extends SimpleFormController {
|
|
61
|
67
|
public void setCargoRepository(CargoRepository cargoRepository) {
|
|
62
|
68
|
this.cargoRepository = cargoRepository;
|
|
63
|
69
|
}
|
|
|
70
|
+
|
|
|
71
|
+ public void setHandlingEventRepository(HandlingEventRepository handlingEventRepository) {
|
|
|
72
|
+ this.handlingEventRepository = handlingEventRepository;
|
|
|
73
|
+ }
|
|
|
74
|
+
|
|
64
|
75
|
}
|