Examples of DisplayStock


Examples of com.swinarta.sunflower.server.model.DisplayStock

     
      Integer storeId = (Integer) request.getData().get("storeId");
     
      Stock s = coreManager.getStock(productId, storeId);
     
      DisplayStock dstock = null;
     
      if(s != null){
        dstock = mapper.map(s, DisplayStock.class);
        dstock.setProductId(s.getProduct().getId());
      }
     
      SgwtRestFetchResponseBase ret = new SgwtRestFetchResponseBase(dstock);
         
      return ret;
   
    }else if(request.getOperationType() == OPERATION_TYPE.ADD){
     
      Float current = RequestUtil.getFloat(request.getData().get("current"));
      Integer max = (Integer) request.getData().get("max");
      Integer min = (Integer) request.getData().get("min");
      Integer order = (Integer) request.getData().get("defaultOrder");
      Integer storeId = (Integer) request.getData().get("storeId");
     
      Product product = coreManager.get(Product.class, productId);
     
      Stock s = new Stock();
      s.setCurrent(current);
      s.setDefaultOrder(order);
      s.setMax(max);
      s.setMin(min);
      s.setLastUpdateReason(StockUpdateReason.WEB);
      s.setProduct(product);
      s.setStoreId(storeId);
     
      Stock retStock;
      DisplayStock dstock = null;
      try {
        retStock = coreManager.save(Stock.class, s);
        dstock = mapper.map(retStock, DisplayStock.class);
        dstock.setProductId(retStock.getProduct().getId());
       
      } catch (Exception e) {
        SgwtRestErrorResponse resp = new SgwtRestErrorResponse(SgwtRestResponseBase.RESPONSE_FAILURE);
        resp.addError("exception", e.getMessage());
        return resp;
      }
     
      SgwtRestFetchResponseBase ret = new SgwtRestFetchResponseBase(dstock);
     
      return ret;
    }else if(request.getOperationType() == OPERATION_TYPE.UPDATE){

      Float current = RequestUtil.getFloat(request.getData().get("current"));
      Integer max = (Integer) request.getData().get("max");
      Integer min = (Integer) request.getData().get("min");
      Integer order = (Integer) request.getData().get("defaultOrder");
      Integer storeId = (Integer) request.getData().get("storeId");

      Stock s = coreManager.getStock(productId, storeId);
      s.setCurrent(current);
      s.setDefaultOrder(order);
      s.setMax(max);
      s.setMin(min);
      s.setLastUpdateReason(StockUpdateReason.WEB);
     
      Stock retStock;
      DisplayStock dstock = null;
      try {
        retStock = coreManager.save(Stock.class, s);
        dstock = mapper.map(retStock, DisplayStock.class);
        dstock.setProductId(retStock.getProduct().getId());       
      } catch (Exception e) {
        SgwtRestErrorResponse resp = new SgwtRestErrorResponse(SgwtRestResponseBase.RESPONSE_FAILURE);
        resp.addError("exception", e.getMessage());
        return resp;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.