Rev 3381 | Blame | Last modification | View Log | RSS feed
package in.shop2020.support.controllers;import in.shop2020.thrift.clients.WarehouseClient;import in.shop2020.warehouse.POStatus;import in.shop2020.warehouse.Purchase;import in.shop2020.warehouse.PurchaseOrder;import in.shop2020.warehouse.WarehouseService.Client;import in.shop2020.warehouse.WarehouseServiceException;import java.util.List;import javax.servlet.ServletContext;import org.apache.struts2.util.ServletContextAware;import org.apache.thrift.TException;import org.apache.thrift.transport.TTransportException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class PurchaseOrderController implements ServletContextAware{private static Logger logger = LoggerFactory.getLogger(PurchaseOrderController.class);private ServletContext context;private String id;private List<PurchaseOrder> purchaseOrders;private PurchaseOrder purchaseOrder;private List<Purchase> purchases;public String index(){//Get a list of all the open purchase orderstry {WarehouseClient warehouseClient = new WarehouseClient();Client client = warehouseClient.getClient();purchaseOrders = client.getAllPurchaseOrders(POStatus.READY);purchaseOrders.addAll(client.getAllPurchaseOrders(POStatus.PARTIALLY_FULFILLED));} catch (TTransportException e) {logger.error("Unable to get the list of all purchase orders.", e);} catch (WarehouseServiceException e) {logger.error("Error while getting the list of all purchase orders.", e);} catch (TException e) {logger.error("Error while communicating to the warehouse server.", e);}return "index";}public String show(){//Get a list of all the open purchase orderstry {WarehouseClient warehouseClient = new WarehouseClient();Client client = warehouseClient.getClient();purchaseOrder = client.getPurchaseOrder(Long.parseLong(id));purchases = client.getAllPurchases(purchaseOrder.getId(), true);} catch (TTransportException e) {logger.error("Unable to get the list of all purchases.", e);} catch (WarehouseServiceException e) {logger.error("Error while getting the list of all purchases.", e);} catch (TException e) {logger.error("Error while communicating to the warehouse server.", e);}return "show";}public void setId(String id){this.id = id;}public List<PurchaseOrder> getPurchaseOrders(){return purchaseOrders;}public PurchaseOrder getPurchaseOrder(){return purchaseOrder;}public List<Purchase> getPurchases(){return purchases;}@Overridepublic void setServletContext(ServletContext context) {this.context = context;}public String getServletContextPath() {return context.getContextPath();}}