Blame | Last modification | View Log | RSS feed
package in.shop2020.hotspot.dashbaord.server.handler;import in.shop2020.hotspot.dashbaord.shared.actions.AcceptOrderRequest;import in.shop2020.hotspot.dashbaord.shared.actions.AcceptOrderResponse;import in.shop2020.hotspot.dashbaord.shared.actions.Order;import in.shop2020.hotspot.dashbaord.shared.actions.OrderDetailsResponse;import in.shop2020.model.v1.order.Transaction;import in.shop2020.model.v1.order.TransactionStatus;import in.shop2020.model.v1.order.TransactionService.Client;import in.shop2020.thrift.clients.TransactionServiceClient;import net.customware.gwt.dispatch.server.ActionHandler;import net.customware.gwt.dispatch.server.ExecutionContext;import net.customware.gwt.dispatch.shared.ActionException;public class AcceptOrderhandler implements ActionHandler<AcceptOrderRequest, AcceptOrderResponse>{@Overridepublic AcceptOrderResponse execute(AcceptOrderRequest request,ExecutionContext context) throws ActionException {// TODO Auto-generated method stubtry{TransactionServiceClient client = new TransactionServiceClient();Client c = client.getClient();if(c.changeTransactionStatus(request.getOrder().getTransactionId(), TransactionStatus.SUBMITTED_FOR_PROCESSING, "Order accepted")){Transaction t = c.getTransaction(request.getOrder().getTransactionId());Order o = new Order(t.getCustomer_id(), t.getId(), t.getCreatedOn(), t.getExpectedDeliveryTime(), t.getTransactionStatus().toString(), t.getStatusDescription());return new AcceptOrderResponse(o, true, "Order Accepted sucessfully");}else{return new AcceptOrderResponse(request.getOrder(), false, "Unable to accept the order");}}catch(Exception e){System.out.println(e);}return null;}@Overridepublic Class<AcceptOrderRequest> getActionType() {// TODO Auto-generated method stubreturn AcceptOrderRequest.class;}@Overridepublic void rollback(AcceptOrderRequest arg0, AcceptOrderResponse arg1,ExecutionContext arg2) throws ActionException {// TODO Auto-generated method stub}}