Explorar el Código

Moved transaction demarcation from ExternalRoutingServiceImpl into pathfinder application, improved documentation.

peter_backlund hace 17 años
padre
commit
0e7ce21cf3

+ 1
- 8
dddsample/src/main/java/com/partner/pathfinder/api/package.html Ver fichero

@@ -1,14 +1,7 @@
1 1
 <html>
2 2
 <body>
3 3
 <p>
4
-  This is the routing team context, which is separate from "our" application and context.
5
-  Our domain model with cargo, itinerary, handling event etc does not exist here.
6
-  The routing service implementation works against the API exposed by
7
-  this context.
8
-</p>
9
-<p>
10
-  It is not related to the core application at all, and is only part of this source tree for
11
-  developer convenience.
4
+  Public API for the pathfinder application.
12 5
 </p>
13 6
 </body>
14 7
 </html>

+ 2
- 0
dddsample/src/main/java/com/partner/pathfinder/internal/GraphTraversalServiceImpl.java Ver fichero

@@ -3,6 +3,7 @@ package com.partner.pathfinder.internal;
3 3
 import com.partner.pathfinder.api.GraphTraversalService;
4 4
 import com.partner.pathfinder.api.TransitEdge;
5 5
 import com.partner.pathfinder.api.TransitPath;
6
+import org.springframework.transaction.annotation.Transactional;
6 7
 
7 8
 import java.util.*;
8 9
 
@@ -16,6 +17,7 @@ public class GraphTraversalServiceImpl implements GraphTraversalService {
16 17
     this.random = new Random();
17 18
   }
18 19
 
20
+  @Transactional(readOnly = true)
19 21
   public List<TransitPath> findShortestPath(String originUnLocode, String destinationUnLocode) {
20 22
     List<String> allVertices = dao.listLocations();
21 23
     allVertices.remove(originUnLocode);

+ 1
- 1
dddsample/src/main/java/com/partner/pathfinder/internal/package.html Ver fichero

@@ -1,7 +1,7 @@
1 1
 <html>
2 2
 <body>
3 3
 <p>
4
-  Internal parts of the routing team application.
4
+  Internal parts of the pathfinder application.
5 5
 </p>
6 6
 </body>
7 7
 </html>

+ 14
- 0
dddsample/src/main/java/com/partner/pathfinder/package.html Ver fichero

@@ -0,0 +1,14 @@
1
+<html>
2
+<body>
3
+<p>
4
+  This is the pathfinder application context, which is separate from "our" application and context.
5
+  Our domain model with cargo, itinerary, handling event etc does not exist here.
6
+  The routing domain service implementation works against the API exposed by
7
+  this context.
8
+</p>
9
+<p>
10
+  It is not related to the core application at all, and is only part of this source tree for
11
+  developer convenience.
12
+</p>
13
+</body>
14
+</html>

+ 4
- 2
dddsample/src/main/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingService.java Ver fichero

@@ -3,7 +3,6 @@ package se.citerus.dddsample.infrastructure.routing;
3 3
 import com.partner.pathfinder.api.GraphTraversalService;
4 4
 import com.partner.pathfinder.api.TransitEdge;
5 5
 import com.partner.pathfinder.api.TransitPath;
6
-import org.springframework.transaction.annotation.Transactional;
7 6
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
8 7
 import se.citerus.dddsample.domain.model.cargo.Leg;
9 8
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
@@ -30,11 +29,12 @@ public class ExternalRoutingService implements RoutingService {
30 29
   private LocationRepository locationRepository;
31 30
   private VoyageRepository voyageRepository;
32 31
 
33
-  @Transactional(readOnly = true)
34 32
   public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
35 33
     final Location origin = routeSpecification.origin();
36 34
     final Location destination = routeSpecification.destination();
37 35
 
36
+    // TODO send arrival deadline too
37
+
38 38
     final List<TransitPath> transitPaths = graphTraversalService.findShortestPath(
39 39
       origin.unLocode().idString(),
40 40
       destination.unLocode().idString()
@@ -47,6 +47,8 @@ public class ExternalRoutingService implements RoutingService {
47 47
       // Use the specification to safe-guard against invalid itineraries
48 48
       if (routeSpecification.isSatisfiedBy(itinerary)) {
49 49
         itineraries.add(itinerary);
50
+      } else {
51
+        // TODO log warning/error? Fail?
50 52
       }
51 53
     }
52 54
 

+ 3
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java Ver fichero

@@ -43,6 +43,8 @@ public class ExternalRoutingServiceTest extends TestCase {
43 43
     externalRoutingService.setGraphTraversalService(graphTraversalService);
44 44
   }
45 45
 
46
+  // TODO this test belongs in com.partner.pathfinder
47
+
46 48
   public void testCalculatePossibleRoutes() {
47 49
     TrackingId trackingId = new TrackingId("ABC");
48 50
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, new Date());
@@ -54,7 +56,7 @@ public class ExternalRoutingServiceTest extends TestCase {
54 56
 
55 57
     List<Itinerary> candidates = externalRoutingService.fetchRoutesForSpecification(routeSpecification);
56 58
     assertNotNull(candidates);
57
-    
59
+
58 60
     for (Itinerary itinerary : candidates) {
59 61
       List<Leg> legs = itinerary.legs();
60 62
       assertNotNull(legs);