1919 */
2020package org .spine3 .examples .aggregate ;
2121
22- import com .google .protobuf .Message ;
2322import org .spine3 .base .Command ;
2423import org .spine3 .base .CommandContext ;
2524import org .spine3 .base .Commands ;
3534 *
3635 * @author Mikhail Melnik
3736 */
38- class Requests {
37+ /*package*/ class Requests {
3938
4039 public static Command createOrder (UserId userId , OrderId orderId ) {
41- final CreateOrder command = CreateOrder .newBuilder ()
40+ final CreateOrder msg = CreateOrder .newBuilder ()
4241 .setOrderId (orderId )
4342 .build ();
44- final Command request = newCommand (userId , command );
45- return request ;
43+ final CommandContext context = Commands .createContext (userId , ZoneOffset .getDefaultInstance ());
44+ final Command cmd = Commands .create (msg , context );
45+ return cmd ;
4646 }
4747
4848 public static Command addOrderLine (UserId userId , OrderId orderId ) {
@@ -60,39 +60,24 @@ public static Command addOrderLine(UserId userId, OrderId orderId) {
6060 .setQuantity (quantity )
6161 .setTotal (totalPrice )
6262 .build ();
63- final AddOrderLine command = AddOrderLine .newBuilder ()
63+ final AddOrderLine msg = AddOrderLine .newBuilder ()
6464 .setOrderId (orderId )
6565 .setOrderLine (orderLine ).build ();
66- final Command result = newCommand (userId , command );
67- return result ;
66+ final CommandContext context = Commands .createContext (userId , ZoneOffset .getDefaultInstance ());
67+ final Command cmd = Commands .create (msg , context );
68+ return cmd ;
6869 }
6970
7071 public static Command payForOrder (UserId userId , OrderId orderId ) {
7172 final BillingInfo billingInfo = BillingInfo .newBuilder ().setInfo ("Payment info is here." ).build ();
72- final PayForOrder command = PayForOrder .newBuilder ()
73+ final PayForOrder msg = PayForOrder .newBuilder ()
7374 .setOrderId (orderId )
7475 .setBillingInfo (billingInfo )
7576 .build ();
76- final Command result = newCommand (userId , command );
77- return result ;
77+ final CommandContext context = Commands .createContext (userId , ZoneOffset .getDefaultInstance ());
78+ final Command cmd = Commands .create (msg , context );
79+ return cmd ;
7880 }
7981
80- //TODO:2016-01-14:alexander.yevsyukov: Use real utility method.
81- public static Command newCommand (UserId userId , Message command ) {
82- final CommandContext context = createCommandContext (userId );
83- final Command request = Commands .create (command , context );
84- return request ;
85- }
86-
87- //TODO:2016-01-14:alexander.yevsyukov: Use real method, which obtains TimeZone.
88- public static CommandContext createCommandContext (UserId userId ) {
89- final CommandContext .Builder context = CommandContext .newBuilder ()
90- .setCommandId (Commands .generateId ())
91- .setActor (userId )
92- .setZoneOffset (ZoneOffset .getDefaultInstance ());
93- return context .build ();
94- }
95-
96- private Requests () {
97- }
82+ private Requests () {}
9883}
0 commit comments