Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package in.shop2020.hotspot.dashbaord.server.handler;

import java.util.Date;
import java.util.List;

import in.shop2020.hotspot.dashbaord.shared.actions.Order;
import in.shop2020.hotspot.dashbaord.shared.actions.OrderDetailsRequest;
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 OrderDetailsHandler implements ActionHandler<OrderDetailsRequest, OrderDetailsResponse>{

        @Override
        public OrderDetailsResponse execute(OrderDetailsRequest request,
                        ExecutionContext context) throws ActionException {
                // TODO Auto-generated method stub
                try{
                        TransactionServiceClient client = new TransactionServiceClient();
                        Client c = client.getClient();
                        Transaction t = c.getTransaction(request.getOrderId());
                        
                        Order o = new Order(t.getCustomer_id(), t.getId(), t.getCreatedOn(), t.getExpectedDeliveryTime(), t.getTransactionStatus().toString(), t.getStatusDescription()); 
                        return new OrderDetailsResponse(o);
                }catch(Exception e){
                        System.out.println(e);
                }
                return new OrderDetailsResponse(null);
        }

        @Override
        public Class<OrderDetailsRequest> getActionType() {
                // TODO Auto-generated method stub
                return OrderDetailsRequest.class;
        }

        @Override
        public void rollback(OrderDetailsRequest arg0, OrderDetailsResponse arg1,
                        ExecutionContext arg2) throws ActionException {
                // TODO Auto-generated method stub
                
        }
}