|
|
@@ -22,7 +22,9 @@ public class HandlingEventFactory {
|
|
22
|
22
|
private final VoyageRepository voyageRepository;
|
|
23
|
23
|
private final LocationRepository locationRepository;
|
|
24
|
24
|
|
|
25
|
|
- public HandlingEventFactory(CargoRepository cargoRepository, VoyageRepository voyageRepository, LocationRepository locationRepository) {
|
|
|
25
|
+ public HandlingEventFactory(final CargoRepository cargoRepository,
|
|
|
26
|
+ final VoyageRepository voyageRepository,
|
|
|
27
|
+ final LocationRepository locationRepository) {
|
|
26
|
28
|
this.cargoRepository = cargoRepository;
|
|
27
|
29
|
this.voyageRepository = voyageRepository;
|
|
28
|
30
|
this.locationRepository = locationRepository;
|
|
|
@@ -34,26 +36,24 @@ public class HandlingEventFactory {
|
|
34
|
36
|
* @param voyageNumber voyage number
|
|
35
|
37
|
* @param unlocode United Nations Location Code for the location of the event
|
|
36
|
38
|
* @param type type of event
|
|
|
39
|
+ * @param registrationTime time when this event was received by the system
|
|
37
|
40
|
* @throws UnknownVoyageException
|
|
38
|
41
|
* if there's not carrier movement with this id
|
|
39
|
42
|
* @throws UnknownCargoException if there's no cargo with this tracking id
|
|
40
|
43
|
* @throws UnknownLocationException if there's no location with this UN Locode
|
|
41
|
44
|
* @return A handling event.
|
|
42
|
45
|
*/
|
|
43
|
|
- public HandlingEvent createHandlingEvent(Date completionTime, TrackingId trackingId, VoyageNumber voyageNumber, UnLocode unlocode, HandlingEvent.Type type)
|
|
|
46
|
+ public HandlingEvent createHandlingEvent(Date registrationTime, Date completionTime, TrackingId trackingId, VoyageNumber voyageNumber, UnLocode unlocode, HandlingEvent.Type type)
|
|
44
|
47
|
throws CannotCreateHandlingEventException {
|
|
45
|
48
|
|
|
46
|
49
|
// Voyage number may be null for certain event types
|
|
47
|
|
- Validate.noNullElements(new Object[]{completionTime, trackingId, unlocode, type});
|
|
|
50
|
+ Validate.noNullElements(new Object[]
|
|
|
51
|
+ {registrationTime, completionTime, trackingId, unlocode, type}
|
|
|
52
|
+ );
|
|
48
|
53
|
|
|
49
|
54
|
final Cargo cargo = findCargo(trackingId);
|
|
50
|
55
|
final Voyage voyage = findVoyage(voyageNumber);
|
|
51
|
56
|
final Location location = findLocation(unlocode);
|
|
52
|
|
-
|
|
53
|
|
- if (location == null) throw new UnknownLocationException(unlocode);
|
|
54
|
|
-
|
|
55
|
|
- // TODO parameterize
|
|
56
|
|
- final Date registrationTime = new Date();
|
|
57
|
57
|
|
|
58
|
58
|
if (voyage == null) {
|
|
59
|
59
|
return new HandlingEvent(cargo, completionTime, registrationTime, type, location);
|