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

Removed from and to timestamps from routing service api, they are derived from the voyage instead.

peter_backlund 16 лет назад
Родитель
Сommit
7a28ceed3c

+ 4
- 20
dddsample/external/pathfinder-api/src/main/java/com/pathfinder/api/TransitEdge.java Просмотреть файл

@@ -1,7 +1,6 @@
1 1
 package com.pathfinder.api;
2 2
 
3 3
 import java.io.Serializable;
4
-import java.util.Date;
5 4
 
6 5
 /**
7 6
  * Represents an edge in a path through a graph,
@@ -12,28 +11,20 @@ public final class TransitEdge implements Serializable {
12 11
   private final String voyageNumber;
13 12
   private final String fromUnLocode;
14 13
   private final String toUnLocode;
15
-  private final Date fromDate;
16
-  private final Date toDate;
17 14
 
18 15
   /**
19 16
    * Constructor.
20 17
    *
21
-   * @param voyageNumber
22
-   * @param fromUnLocode
23
-   * @param toUnLocode
24
-   * @param fromDate
25
-   * @param toDate
18
+   * @param voyageNumber    voyage number
19
+   * @param fromUnLocode    UN Locode of start location
20
+   * @param toUnLocode      UN Locode of end location    
26 21
    */
27 22
   public TransitEdge(final String voyageNumber,
28 23
                      final String fromUnLocode,
29
-                     final String toUnLocode,
30
-                     final Date fromDate,
31
-                     final Date toDate) {
24
+                     final String toUnLocode) {
32 25
     this.voyageNumber = voyageNumber;
33 26
     this.fromUnLocode = fromUnLocode;
34 27
     this.toUnLocode = toUnLocode;
35
-    this.fromDate = fromDate;
36
-    this.toDate = toDate;
37 28
   }
38 29
 
39 30
   public String getVoyageNumber() {
@@ -48,11 +39,4 @@ public final class TransitEdge implements Serializable {
48 39
     return toUnLocode;
49 40
   }
50 41
 
51
-  public Date getFromDate() {
52
-    return fromDate;
53
-  }
54
-
55
-  public Date getToDate() {
56
-    return toDate;
57
-  }
58 42
 }

+ 3
- 3
dddsample/external/pathfinder/src/main/java/com/pathfinder/internal/GraphTraversalServiceImpl.java Просмотреть файл

@@ -41,7 +41,7 @@ public class GraphTraversalServiceImpl implements GraphTraversalService {
41 41
 
42 42
       transitEdges.add(new TransitEdge(
43 43
         dao.getVoyageNumber(originUnLocode, firstLegTo),
44
-        originUnLocode, firstLegTo, fromDate, toDate));
44
+        originUnLocode, firstLegTo));
45 45
 
46 46
       for (int j = 0; j < allVertices.size() - 1; j++) {
47 47
         final String curr = allVertices.get(j);
@@ -49,7 +49,7 @@ public class GraphTraversalServiceImpl implements GraphTraversalService {
49 49
         fromDate = nextDate(date);
50 50
         toDate = nextDate(fromDate);
51 51
         date = nextDate(toDate);
52
-        transitEdges.add(new TransitEdge(dao.getVoyageNumber(curr, next), curr, next, fromDate, toDate));
52
+        transitEdges.add(new TransitEdge(dao.getVoyageNumber(curr, next), curr, next));
53 53
       }
54 54
 
55 55
       final String lastLegFrom = allVertices.get(allVertices.size() - 1);
@@ -57,7 +57,7 @@ public class GraphTraversalServiceImpl implements GraphTraversalService {
57 57
       toDate = nextDate(fromDate);
58 58
       transitEdges.add(new TransitEdge(
59 59
         dao.getVoyageNumber(lastLegFrom, destinationUnLocode),
60
-        lastLegFrom, destinationUnLocode, fromDate, toDate));
60
+        lastLegFrom, destinationUnLocode));
61 61
 
62 62
       candidates.add(new TransitPath(transitEdges));
63 63
     }

+ 3
- 4
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingService.java Просмотреть файл

@@ -5,8 +5,8 @@ import com.pathfinder.api.TransitEdge;
5 5
 import com.pathfinder.api.TransitPath;
6 6
 import org.apache.commons.logging.Log;
7 7
 import org.apache.commons.logging.LogFactory;
8
-import org.springframework.stereotype.Service;
9 8
 import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Service;
10 10
 import se.citerus.dddsample.tracking.core.domain.model.cargo.Itinerary;
11 11
 import se.citerus.dddsample.tracking.core.domain.model.cargo.Leg;
12 12
 import se.citerus.dddsample.tracking.core.domain.model.cargo.RouteSpecification;
@@ -94,11 +94,10 @@ public class ExternalRoutingService implements RoutingService {
94 94
   }
95 95
 
96 96
   private Leg toLeg(final TransitEdge edge) {
97
-    return new Leg(
97
+    return Leg.deriveLeg(
98 98
       voyageRepository.find(new VoyageNumber(edge.getVoyageNumber())),
99 99
       locationRepository.find(new UnLocode(edge.getFromUnLocode())),
100
-      locationRepository.find(new UnLocode(edge.getToUnLocode())),
101
-      edge.getFromDate(), edge.getToDate()
100
+      locationRepository.find(new UnLocode(edge.getToUnLocode()))
102 101
     );
103 102
   }
104 103