Просмотр исходного кода

Removed the no longer method deleteItinerary()

peter_backlund 18 лет назад
Родитель
Сommit
a808a0d84b

+ 0
- 7
dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepository.java Просмотреть файл

1
 package se.citerus.dddsample.repository;
1
 package se.citerus.dddsample.repository;
2
 
2
 
3
 import se.citerus.dddsample.domain.Cargo;
3
 import se.citerus.dddsample.domain.Cargo;
4
-import se.citerus.dddsample.domain.Itinerary;
5
 import se.citerus.dddsample.domain.TrackingId;
4
 import se.citerus.dddsample.domain.TrackingId;
6
 
5
 
7
 import java.util.List;
6
 import java.util.List;
35
    */
34
    */
36
   TrackingId nextTrackingId();
35
   TrackingId nextTrackingId();
37
 
36
 
38
-  /**
39
-   * Deletes an itinerary.
40
-   *
41
-   * @param itinerary itinerary to delete
42
-   */
43
-  void deleteItinerary(Itinerary itinerary);
44
 }
37
 }

+ 8
- 12
dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepositoryHibernate.java Просмотреть файл

33
         it might be cumbersome to map the relation between cargo and handling event,
33
         it might be cumbersome to map the relation between cargo and handling event,
34
         since we want to be able to insert handling events regardless of locking status on cargo.
34
         since we want to be able to insert handling events regardless of locking status on cargo.
35
 
35
 
36
+
36
         If this extra database call were a problem, you might want to use a different model.
37
         If this extra database call were a problem, you might want to use a different model.
37
         For example, you could calculate the effect/status of the cargo and store it separate from the
38
         For example, you could calculate the effect/status of the cargo and store it separate from the
38
         handling events. */
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
     DeliveryHistory deliveryHistory = new DeliveryHistory(handlingEventRepository.findEventsForCargo(tid));
46
     DeliveryHistory deliveryHistory = new DeliveryHistory(handlingEventRepository.findEventsForCargo(tid));
40
     cargo.setDeliveryHistory(deliveryHistory);
47
     cargo.setDeliveryHistory(deliveryHistory);
41
 
48
 
55
   }
62
   }
56
 
63
 
57
   public TrackingId nextTrackingId() {
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
     return new TrackingId(
66
     return new TrackingId(
64
       random.substring(0, random.indexOf("-"))
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
   public List<Cargo> findAll() {
71
   public List<Cargo> findAll() {
76
     return getSession().createQuery("from Cargo").list();
72
     return getSession().createQuery("from Cargo").list();
77
   }
73
   }