Parcourir la source

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

peter_backlund il y a 18 ans
Parent
révision
4e4eaf1600

+ 13
- 5
dddsample/src/main/java/se/citerus/dddsample/domain/service/TrackingServiceImpl.java Voir le fichier

31
       return;
31
       return;
32
     }
32
     }
33
 
33
 
34
-    // TODO: more elaborate notifications, such as email to affected customer
35
     if (cargo.isMisdirected()) {
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
     if (cargo.isUnloadedAtDestination()) {
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
   public void setCargoRepository(CargoRepository cargoRepository) {
53
   public void setCargoRepository(CargoRepository cargoRepository) {
46
     this.cargoRepository = cargoRepository;
54
     this.cargoRepository = cargoRepository;
47
   }
55
   }