瀏覽代碼

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

peter_backlund 17 年之前
父節點
當前提交
e6a0b00a80

+ 2
- 1
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/facade/BookingServiceFacade.java 查看文件

6
 
6
 
7
 import java.rmi.Remote;
7
 import java.rmi.Remote;
8
 import java.rmi.RemoteException;
8
 import java.rmi.RemoteException;
9
+import java.util.Date;
9
 import java.util.List;
10
 import java.util.List;
10
 
11
 
11
 /**
12
 /**
14
  */
15
  */
15
 public interface BookingServiceFacade extends Remote {
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
   CargoRoutingDTO loadCargoForRouting(String trackingId) throws RemoteException;
20
   CargoRoutingDTO loadCargoForRouting(String trackingId) throws RemoteException;
20
 
21
 

+ 6
- 5
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/facade/internal/BookingServiceFacadeImpl.java 查看文件

29
  * service and for keeping the OR-mapper unit-of-work open during DTO assembly,
29
  * service and for keeping the OR-mapper unit-of-work open during DTO assembly,
30
  * analogous to the view rendering for web interfaces.
30
  * analogous to the view rendering for web interfaces.
31
  *
31
  *
32
- * See context-remote.xml.  
33
  */
32
  */
34
 public class BookingServiceFacadeImpl implements BookingServiceFacade {
33
 public class BookingServiceFacadeImpl implements BookingServiceFacade {
35
 
34
 
45
     return assembler.toDTOList(allLocations);
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
     return trackingId.idString();
53
     return trackingId.idString();
53
   }
54
   }
54
 
55
 

+ 3
- 6
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/web/CargoAdminController.java 查看文件

9
 
9
 
10
 import javax.servlet.http.HttpServletRequest;
10
 import javax.servlet.http.HttpServletRequest;
11
 import javax.servlet.http.HttpServletResponse;
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
  * Handles cargo booking and routing. Operates against a dedicated remoting service facade,
15
  * Handles cargo booking and routing. Operates against a dedicated remoting service facade,
46
 
43
 
47
   public void register(final HttpServletRequest request, final HttpServletResponse response,
44
   public void register(final HttpServletRequest request, final HttpServletResponse response,
48
                        final RegistrationCommand command) throws Exception {
45
                        final RegistrationCommand command) throws Exception {
49
-
46
+    // TODO get date from command    
50
     final String trackingId = bookingServiceFacade.bookNewCargo(
47
     final String trackingId = bookingServiceFacade.bookNewCargo(
51
-      command.getOriginUnlocode(), command.getDestinationUnlocode()
48
+      command.getOriginUnlocode(), command.getDestinationUnlocode(), new Date()
52
     );
49
     );
53
     response.sendRedirect("show.html?trackingId=" + trackingId);
50
     response.sendRedirect("show.html?trackingId=" + trackingId);
54
   }
51
   }

+ 8
- 0
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/web/RegistrationCommand.java 查看文件

7
 
7
 
8
   private String originUnlocode;
8
   private String originUnlocode;
9
   private String destinationUnlocode;
9
   private String destinationUnlocode;
10
+  private String arrivalDeadline;
10
 
11
 
11
   public String getOriginUnlocode() {
12
   public String getOriginUnlocode() {
12
     return originUnlocode;
13
     return originUnlocode;
24
     this.destinationUnlocode = destinationUnlocode;
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
 }