Blame | Last modification | View Log | RSS feed
package in.shop2020.hotspot.dashbaord.server.handler;import java.util.ArrayList;import java.util.Date;import java.util.List;import in.shop2020.hotspot.dashbaord.shared.actions.Order;import in.shop2020.hotspot.dashbaord.shared.actions.OrderRequest;import in.shop2020.hotspot.dashbaord.shared.actions.OrderResponse;import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;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 OrderHandler implements ActionHandler<OrderRequest, OrderResponse>{private OrderType type;@Overridepublic OrderResponse execute(OrderRequest request, ExecutionContext context)throws ActionException {type = request.getType();OrderResponse or = new OrderResponse(type, getInitTransactions());return or;}@Overridepublic Class<OrderRequest> getActionType() {// TODO Auto-generated method stubreturn OrderRequest.class;}@Overridepublic void rollback(OrderRequest arg0, OrderResponse arg1,ExecutionContext arg2) throws ActionException {// TODO Auto-generated method stub}private List<Order> getInitTransactions(){List<Order> orders = new ArrayList<Order>();try{TransactionServiceClient client = new TransactionServiceClient();Client c = client.getClient();List<Transaction> txns = c.getAllTransactions(TransactionStatus.INIT, 0L, new Date().getTime());for (Transaction t: txns){Order o = new Order(t.getCustomer_id(), t.getId(), t.getCreatedOn(), t.getExpectedDeliveryTime(), t.getTransactionStatus().toString(), t.getStatusDescription());orders.add(o);}}catch(Exception e){System.out.println(e);}return orders;}}