Parcourir la source

Getting dates for Legs from TransitEdge.

peter_backlund il y a 17 ans
Parent
révision
88e248c3c4

+ 14
- 7
dddsample/src/main/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingService.java Voir le fichier

@@ -15,8 +15,9 @@ import se.citerus.dddsample.domain.model.location.LocationRepository;
15 15
 import se.citerus.dddsample.domain.model.location.UnLocode;
16 16
 import se.citerus.dddsample.domain.service.RoutingService;
17 17
 
18
+import java.rmi.RemoteException;
18 19
 import java.util.ArrayList;
19
-import java.util.Date;
20
+import java.util.Collections;
20 21
 import java.util.List;
21 22
 import java.util.Properties;
22 23
 
@@ -43,15 +44,21 @@ public class ExternalRoutingService implements RoutingService {
43 44
     final Properties limitations = new Properties();
44 45
     limitations.setProperty("DEADLINE", routeSpecification.arrivalDeadline().toString());
45 46
 
46
-    final List<TransitPath> transitPaths = graphTraversalService.findShortestPath(
47
+    final List<TransitPath> transitPaths;
48
+    try {
49
+      transitPaths = graphTraversalService.findShortestPath(
47 50
       origin.unLocode().idString(),
48 51
       destination.unLocode().idString(),
49 52
       limitations
50 53
     );
51
-    
54
+    } catch (RemoteException e) {
55
+      log.error(e, e);
56
+      return Collections.EMPTY_LIST;
57
+    }
58
+
52 59
     /*
53
-      The returned result is then translated back into our domain model.
54
-     */
60
+     The returned result is then translated back into our domain model.
61
+    */
55 62
     final List<Itinerary> itineraries = new ArrayList<Itinerary>();
56 63
 
57 64
     for (TransitPath transitPath : transitPaths) {
@@ -77,10 +84,10 @@ public class ExternalRoutingService implements RoutingService {
77 84
 
78 85
   private Leg toLeg(TransitEdge edge) {
79 86
     return new Leg(
80
-      voyageRepository.find(new VoyageNumber(edge.getCarrierMovementId())),
87
+      voyageRepository.find(new VoyageNumber(edge.getVoyageNumber())),
81 88
       locationRepository.find(new UnLocode(edge.getFromUnLocode())),
82 89
       locationRepository.find(new UnLocode(edge.getToUnLocode())),
83
-      new Date(), new Date()  // TODO better dates
90
+      edge.getFromDate(), edge.getToDate()
84 91
     );
85 92
   }
86 93