|
|
@@ -33,9 +33,16 @@ public class CargoRepositoryHibernate extends HibernateRepository implements Car
|
|
33
|
33
|
it might be cumbersome to map the relation between cargo and handling event,
|
|
34
|
34
|
since we want to be able to insert handling events regardless of locking status on cargo.
|
|
35
|
35
|
|
|
|
36
|
+
|
|
36
|
37
|
If this extra database call were a problem, you might want to use a different model.
|
|
37
|
38
|
For example, you could calculate the effect/status of the cargo and store it separate from the
|
|
38
|
39
|
handling events. */
|
|
|
40
|
+
|
|
|
41
|
+ /*
|
|
|
42
|
+ TODO:
|
|
|
43
|
+ the decision whether or not to include the delivery history when loading cargo
|
|
|
44
|
+ seems to belong in the service layer, which defines use cases.
|
|
|
45
|
+ */
|
|
39
|
46
|
DeliveryHistory deliveryHistory = new DeliveryHistory(handlingEventRepository.findEventsForCargo(tid));
|
|
40
|
47
|
cargo.setDeliveryHistory(deliveryHistory);
|
|
41
|
48
|
|
|
|
@@ -55,23 +62,12 @@ public class CargoRepositoryHibernate extends HibernateRepository implements Car
|
|
55
|
62
|
}
|
|
56
|
63
|
|
|
57
|
64
|
public TrackingId nextTrackingId() {
|
|
58
|
|
- // TODO:
|
|
59
|
|
- // Could be an opportunity to maybe illustrate how to handle pessimistic locking
|
|
60
|
|
- // and aggregate boundaries, and maybe problems with a distributed application
|
|
61
|
|
- // sharing a database. For now it's simply random though.
|
|
62
|
|
- String random = UUID.randomUUID().toString().toUpperCase();
|
|
|
65
|
+ final String random = UUID.randomUUID().toString().toUpperCase();
|
|
63
|
66
|
return new TrackingId(
|
|
64
|
67
|
random.substring(0, random.indexOf("-"))
|
|
65
|
68
|
);
|
|
66
|
69
|
}
|
|
67
|
70
|
|
|
68
|
|
- public void deleteItinerary(Itinerary itinerary) {
|
|
69
|
|
- // Itinerary should be mapped to cascade deletes to all its legs
|
|
70
|
|
- if (itinerary != null) {
|
|
71
|
|
- getSession().delete(itinerary);
|
|
72
|
|
- }
|
|
73
|
|
- }
|
|
74
|
|
-
|
|
75
|
71
|
public List<Cargo> findAll() {
|
|
76
|
72
|
return getSession().createQuery("from Cargo").list();
|
|
77
|
73
|
}
|