Explorar el Código

Restructured the routing team code slightly

peter_backlund hace 18 años
padre
commit
c0197c1d42

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/application/routing/ExternalRoutingService.java Ver fichero

@@ -34,7 +34,7 @@ public class ExternalRoutingService implements RoutingService {
34 34
     final Location origin = routeSpecification.origin();
35 35
     final Location destination = routeSpecification.destination();
36 36
 
37
-    final List<TransitPath> transitPaths = graphTraversalService.performHeavyCalculations(
37
+    final List<TransitPath> transitPaths = graphTraversalService.findShortestPath(
38 38
       origin.unLocode().idString(),
39 39
       destination.unLocode().idString()
40 40
     );

+ 0
- 43
dddsample/src/main/java/se/citerus/routingteam/GraphDAO.java Ver fichero

@@ -1,43 +0,0 @@
1
-package se.citerus.routingteam;
2
-
3
-import org.springframework.jdbc.core.JdbcTemplate;
4
-import org.springframework.jdbc.core.RowCallbackHandler;
5
-
6
-import javax.sql.DataSource;
7
-import java.sql.ResultSet;
8
-import java.sql.SQLException;
9
-import java.util.ArrayList;
10
-import java.util.List;
11
-
12
-public class GraphDAO {
13
-
14
-  private final JdbcTemplate jt;
15
-
16
-  public GraphDAO(DataSource dataSource) {
17
-    jt = new JdbcTemplate(dataSource);
18
-  }
19
-
20
-  public List<String> listLocations() {
21
-    final List<String> result = new ArrayList();
22
-
23
-    jt.query("select unlocode from location", new RowCallbackHandler() {
24
-      public void processRow(ResultSet resultSet) throws SQLException {
25
-        result.add(resultSet.getString("unlocode"));
26
-      }
27
-    });
28
-
29
-    return result;
30
-  }
31
-
32
-  public void storeCarrierMovementId(String cmId, String from, String to) {
33
-    final String locationSql = "select id from location where unlocode = ?";
34
-
35
-    final Long fromId = jt.queryForLong(locationSql, new Object[]{ from });
36
-    final Long toId = jt.queryForLong(locationSql, new Object[]{ to });
37
-
38
-    final Object[] params = {cmId, fromId, toId};
39
-    jt.update(
40
-      "insert into CarrierMovement (carrier_movement_id,from_id,to_id) " +
41
-      "values (?,?,?)", params);
42
-  }
43
-}

+ 1
- 1
dddsample/src/main/java/se/citerus/routingteam/GraphTraversalService.java Ver fichero

@@ -9,6 +9,6 @@ import java.util.List;
9 9
  */
10 10
 public interface GraphTraversalService {
11 11
 
12
-  List<TransitPath> performHeavyCalculations(String originUnLocode, String destinationUnLocode);
12
+  List<TransitPath> findShortestPath(String originUnLocode, String destinationUnLocode);
13 13
 
14 14
 }

+ 1
- 1
dddsample/src/main/java/se/citerus/routingteam/internal/GraphTraversalServiceImpl.java Ver fichero

@@ -16,7 +16,7 @@ public class GraphTraversalServiceImpl implements GraphTraversalService {
16 16
     this.random = new Random();
17 17
   }
18 18
 
19
-  public List<TransitPath> performHeavyCalculations(String originUnLocode, String destinationUnLocode) {
19
+  public List<TransitPath> findShortestPath(String originUnLocode, String destinationUnLocode) {
20 20
     List<String> allVertices = dao.listLocations();
21 21
     allVertices.remove(originUnLocode);
22 22
     allVertices.remove(destinationUnLocode);

dddsample/src/main/resources/context-routing.xml → dddsample/src/main/resources/context-routingteam.xml Ver fichero


+ 1
- 1
dddsample/src/main/webapp/WEB-INF/web.xml Ver fichero

@@ -28,7 +28,7 @@
28 28
       classpath:context-messaging-jms.xml
29 29
 
30 30
       classpath:context-service.xml
31
-      classpath:context-routing.xml
31
+      classpath:context-routingteam.xml
32 32
       classpath:context-remote.xml
33 33
       classpath:context-web.xml
34 34
     </param-value>