Explorar el Código

Arrival deadline date is now passed as parameter into booking facade (not read from request parameter yet though).

peter_backlund hace 17 años
padre
commit
e6a0b00a80

+ 2
- 1
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/facade/BookingServiceFacade.java Ver fichero

@@ -6,6 +6,7 @@ import se.citerus.dddsample.interfaces.booking.facade.dto.LocationDTO;
6 6
 
7 7
 import java.rmi.Remote;
8 8
 import java.rmi.RemoteException;
9
+import java.util.Date;
9 10
 import java.util.List;
10 11
 
11 12
 /**
@@ -14,7 +15,7 @@ import java.util.List;
14 15
  */
15 16
 public interface BookingServiceFacade extends Remote {
16 17
 
17
-  String bookNewCargo(String origin, String destination) throws RemoteException;
18
+  String bookNewCargo(String origin, String destination, Date arrivalDeadline) throws RemoteException;
18 19
 
19 20
   CargoRoutingDTO loadCargoForRouting(String trackingId) throws RemoteException;
20 21
 

+ 6
- 5
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/facade/internal/BookingServiceFacadeImpl.java Ver fichero

@@ -29,7 +29,6 @@ import java.util.List;
29 29
  * service and for keeping the OR-mapper unit-of-work open during DTO assembly,
30 30
  * analogous to the view rendering for web interfaces.
31 31
  *
32
- * See context-remote.xml.  
33 32
  */
34 33
 public class BookingServiceFacadeImpl implements BookingServiceFacade {
35 34
 
@@ -45,10 +44,12 @@ public class BookingServiceFacadeImpl implements BookingServiceFacade {
45 44
     return assembler.toDTOList(allLocations);
46 45
   }
47 46
 
48
-  public String bookNewCargo(String origin, String destination) {
49
-    // TODO push date to parameter
50
-    Date arrivalDeadline = new Date();
51
-    TrackingId trackingId = bookingService.bookNewCargo(new UnLocode(origin), new UnLocode(destination), arrivalDeadline);
47
+  public String bookNewCargo(String origin, String destination, Date arrivalDeadline) {
48
+    TrackingId trackingId = bookingService.bookNewCargo(
49
+      new UnLocode(origin), 
50
+      new UnLocode(destination),
51
+      arrivalDeadline
52
+    );
52 53
     return trackingId.idString();
53 54
   }
54 55
 

+ 3
- 6
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/web/CargoAdminController.java Ver fichero

@@ -9,10 +9,7 @@ import se.citerus.dddsample.interfaces.booking.facade.dto.LocationDTO;
9 9
 
10 10
 import javax.servlet.http.HttpServletRequest;
11 11
 import javax.servlet.http.HttpServletResponse;
12
-import java.util.ArrayList;
13
-import java.util.HashMap;
14
-import java.util.List;
15
-import java.util.Map;
12
+import java.util.*;
16 13
 
17 14
 /**
18 15
  * Handles cargo booking and routing. Operates against a dedicated remoting service facade,
@@ -46,9 +43,9 @@ public final class CargoAdminController extends MultiActionController {
46 43
 
47 44
   public void register(final HttpServletRequest request, final HttpServletResponse response,
48 45
                        final RegistrationCommand command) throws Exception {
49
-
46
+    // TODO get date from command    
50 47
     final String trackingId = bookingServiceFacade.bookNewCargo(
51
-      command.getOriginUnlocode(), command.getDestinationUnlocode()
48
+      command.getOriginUnlocode(), command.getDestinationUnlocode(), new Date()
52 49
     );
53 50
     response.sendRedirect("show.html?trackingId=" + trackingId);
54 51
   }

+ 8
- 0
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/web/RegistrationCommand.java Ver fichero

@@ -7,6 +7,7 @@ public final class RegistrationCommand {
7 7
 
8 8
   private String originUnlocode;
9 9
   private String destinationUnlocode;
10
+  private String arrivalDeadline;
10 11
 
11 12
   public String getOriginUnlocode() {
12 13
     return originUnlocode;
@@ -24,4 +25,11 @@ public final class RegistrationCommand {
24 25
     this.destinationUnlocode = destinationUnlocode;
25 26
   }
26 27
 
28
+  public String getArrivalDeadline() {
29
+    return arrivalDeadline;
30
+  }
31
+
32
+  public void setArrivalDeadline(String arrivalDeadline) {
33
+    this.arrivalDeadline = arrivalDeadline;
34
+  }
27 35
 }