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

Removed the no longer method deleteItinerary()

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

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

@@ -1,7 +1,6 @@
1 1
 package se.citerus.dddsample.repository;
2 2
 
3 3
 import se.citerus.dddsample.domain.Cargo;
4
-import se.citerus.dddsample.domain.Itinerary;
5 4
 import se.citerus.dddsample.domain.TrackingId;
6 5
 
7 6
 import java.util.List;
@@ -35,10 +34,4 @@ public interface CargoRepository {
35 34
    */
36 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,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
   }