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

More explicit flow in notify() for misrouted and unloaded-at-destination cases

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

+ 13
- 5
dddsample/src/main/java/se/citerus/dddsample/domain/service/TrackingServiceImpl.java Просмотреть файл

@@ -31,17 +31,25 @@ public class TrackingServiceImpl implements TrackingService {
31 31
       return;
32 32
     }
33 33
 
34
-    // TODO: more elaborate notifications, such as email to affected customer
35 34
     if (cargo.isMisdirected()) {
36
-      logger.info("Cargo " + trackingId + " has been misdirected. " +
37
-        "Last event was " + cargo.deliveryHistory().lastEvent());
35
+      handleMisdirectedCargo(cargo);
38 36
     }
39 37
     if (cargo.isUnloadedAtDestination()) {
40
-      logger.info("Cargo " + trackingId + " has been unloaded " +
41
-        "at its final destination " + cargo.destination());
38
+      notifyCustomerOfAvailability(cargo);
42 39
     }
43 40
   }
44 41
 
42
+  private void notifyCustomerOfAvailability(Cargo cargo) {
43
+    // TODO: more elaborate notifications
44
+    logger.info("Cargo " + cargo.trackingId() + " has been unloaded " +
45
+      "at its final destination " + cargo.destination());
46
+  }
47
+
48
+  private void handleMisdirectedCargo(Cargo cargo) {
49
+    logger.info("Cargo " + cargo.trackingId() + " has been misdirected. " +
50
+      "Last event was " + cargo.deliveryHistory().lastEvent());
51
+  }
52
+
45 53
   public void setCargoRepository(CargoRepository cargoRepository) {
46 54
     this.cargoRepository = cargoRepository;
47 55
   }