浏览代码

Hackish way of making the delivery not being misdrected after a reroute. Makes tests pass, but needs refactoring.

peter_backlund 17 年前
父节点
当前提交
0ebf2e0dca
共有 1 个文件被更改,包括 19 次插入1 次删除
  1. 19
    1
      dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Delivery.java

+ 19
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Delivery.java 查看文件

@@ -48,7 +48,10 @@ public class Delivery implements ValueObject<Delivery> {
48 48
   Delivery updateOnRouting(RouteSpecification routeSpecification, Itinerary itinerary) {
49 49
     Validate.notNull(routeSpecification, "Route specification is required");
50 50
 
51
-    return new Delivery(this.lastEvent, itinerary, routeSpecification);
51
+    Delivery delivery = new Delivery(this.lastEvent, itinerary, routeSpecification);
52
+    delivery.misdirected = false;
53
+    delivery.nextExpectedActivity = delivery.calculateNextExpectedActivity(routeSpecification, itinerary);
54
+    return delivery;
52 55
   }
53 56
 
54 57
   /**
@@ -223,6 +226,21 @@ public class Delivery implements ValueObject<Delivery> {
223 226
   }
224 227
 
225 228
   private HandlingActivity calculateNextExpectedActivity(RouteSpecification routeSpecification, Itinerary itinerary) {
229
+    /*
230
+      Capture:
231
+
232
+      Cargo is misdirected but has been rerouted. Next expected acivity should be to load according to first leg
233
+      of new itinerary.
234
+
235
+      and
236
+
237
+      even if a cargo is misdirected, we expect it to be unloaded at next stop.
238
+      
239
+     */
240
+    if (misdirected && ROUTED.equals(routingStatus)) {
241
+
242
+    }
243
+
226 244
     if (!onTrack()) return NO_ACTIVITY;
227 245
 
228 246
     if (lastEvent == null) return new HandlingActivity(HandlingEvent.Type.RECEIVE, routeSpecification.origin());