Examples of Cart


Examples of client.ws.milanas.helpers.beans.Cart

     */
    public boolean addItem(String offerId, int quantity) throws SOAPEnvelopeCreationException
    {
        ArrayList<CartItem> items = new ArrayList<CartItem>();
        CartItem item = null;
        Cart auxCart = null;
        HashMap<String, String> parameters = new HashMap<String, String>();
        SOAPMessage message, response = null;
        DOMCartHandler dch = null;
        Document doc = null;
       
        if(quantity <= 0)
        {
            return true;
        }
       
        item = new CartItem();
        item.setOfferId(offerId);
        item.setQuantity(quantity);
        items.add(item);
       
        if(cart != null)
        {
            parameters.put("CartId", cart.getCartId());
            parameters.put("HMAC", cart.getCartHmac());
            message = SOAPEnvelopeCreator.createAmazonCartSOAPEnvelope("CartAdd", parameters, items, properties);
            try
            {
                response = connection.call(message, properties.getProperty("endpoint"));
                dch = new DOMCartHandler();
                doc = response.getSOAPBody().extractContentAsDocument();
                auxCart = dch.getCart(doc);
                cart.setItems(auxCart.getItems());
                cart.setTotal(auxCart.getTotal());
                cart.setUrl(auxCart.getUrl());
                if(dch.isItemAdded(doc))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(SOAPException se){return false;}
        }
        else
        {
            parameters.put("AssociateTag", properties.getProperty("AssociateTag"));
            message = SOAPEnvelopeCreator.createAmazonCartSOAPEnvelope("CartCreate", parameters, items, properties);
            try
            {
               
                response = connection.call(message, properties.getProperty("endpoint"));              
                dch = new DOMCartHandler();
                doc = response.getSOAPBody().extractContentAsDocument();
                if(dch.isItemAdded(doc))
                {
                    cart = new Cart(dch.getCartId(doc), dch.getCartHmac(doc));
                    auxCart = dch.getCart(doc);
                    cart.setItems(auxCart.getItems());
                    cart.setTotal(auxCart.getTotal());
                    cart.setUrl(auxCart.getUrl());
                    return true;
                }
                else
                {
                    return false;
View Full Code Here

Examples of com.alibaba.sample.petstore.dal.dataobject.Cart

        assertEquals("FISH", cat.getCategoryId());
    }

    @Test
    public void getCartItems() {
        Cart cart = new Cart();

        cart.setQuantity("EST-1", 10);
        cart.setQuantity("EST-2", 100);

        storeManager.getCartItems(cart);

        assertProductItem(cart, 0, "EST-1", 10);
        assertProductItem(cart, 1, "EST-2", 100);

        assertEquals(165 + 1650, cart.getTotal().intValue());
    }
View Full Code Here

Examples of com.alibaba.sample.petstore.dal.dataobject.Cart

public class ViewCart {
    @Autowired
    private StoreManager storeManager;

    public void execute(HttpSession session, Context context) throws Exception {
        Cart cart = (Cart) session.getAttribute(PETSTORE_CART_KEY);

        if (cart == null) {
            cart = new Cart();
        }

        cart = storeManager.getCartItems(cart);

        context.put("cart", cart);
View Full Code Here

Examples of com.alibaba.sample.petstore.dal.dataobject.Cart

public class CartAction {
    @Autowired
    private StoreManager storeManager;

    public void doAddItem(HttpSession session, @Param("itemId") String itemId, Context context) throws Exception {
        Cart cart = (Cart) session.getAttribute(PETSTORE_CART_KEY);

        if (cart == null) {
            cart = new Cart();
        }

        cart.addCartItem(itemId);

        session.setAttribute(PETSTORE_CART_KEY, cart);

        context.put("itemAdded", Boolean.TRUE);
    }
View Full Code Here

Examples of com.alibaba.sample.petstore.dal.dataobject.Cart

        context.put("itemAdded", Boolean.TRUE);
    }

    public void doRemoveItem(HttpSession session, @Param("itemId") String itemId, Context context)
            throws WebxException {
        Cart cart = (Cart) session.getAttribute(PETSTORE_CART_KEY);

        if (cart == null) {
            cart = new Cart();
        }

        cart.removeCartItem(itemId);

        session.setAttribute(PETSTORE_CART_KEY, cart);
    }
View Full Code Here

Examples of com.alibaba.sample.petstore.dal.dataobject.Cart

        session.setAttribute(PETSTORE_CART_KEY, cart);
    }

    public void doUpdate(HttpSession session, @FormGroups("cartItem") Group[] groups, Context context)
            throws WebxException {
        Cart cart = (Cart) session.getAttribute(PETSTORE_CART_KEY);

        if (cart == null) {
            return;
        }

        cart = storeManager.getCartItems(cart);

        for (Group group : groups) {
            String itemId = group.getInstanceKey();
            int quantity = group.getField("quantity").getIntegerValue();
            int stockQuantity = cart.getCartItem(itemId).getProductItem().getQuantity();

            if (quantity > stockQuantity) {
                Map<String, Object> params = createHashMap();
                params.put("stockQuantity", new Integer(stockQuantity));

                group.getField("quantity").setMessage("outOfStock", params);
            } else {
                cart.setQuantity(itemId, quantity);
            }
        }

        session.setAttribute(PETSTORE_CART_KEY, cart);
    }
View Full Code Here

Examples of com.ateam.webstore.model.Cart

*/
public class CartDAO extends GenericDAOImpl<Cart, Serializable> {

  public Cart getByCustomer(Serializable customer) {
   
    Cart cart = null;
   
    try {
      Query query = getPersistenceManager().newQuery(getPersistentClass(), "customer == :customer");
      query.setUnique(true);
      cart = (Cart) query.execute(customer);
View Full Code Here

Examples of com.buschmais.jqassistant.test.javaee6.backend.cart.model.api.model.Cart

  public List<Cart> getPersonList() {
    return cartService.getPersons();
  }

  public String onCreate() {
    this.cart = new Cart();
    this.conversation.begin();
    return "/edit";
  }
View Full Code Here

Examples of com.buschmais.jqassistant.test.javaee6.backend.cart.persistence.api.model.Cart

    public List<Cart> getPersonList() {
        return cartService.getPersons();
    }

    public String onCreate() {
        this.cart = new Cart();
        this.conversation.begin();
        return "/edit";
    }
View Full Code Here

Examples of com.example.bookstore.domain.Cart

  }

  @Bean
  @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
  public Cart cart() {
    return new Cart();
  }
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.