Package com.alibaba.sample.petstore.dal.dataobject

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


        assertProductItemList(productItemDao.getItemListByProductId("FI-SW-01"), "EST-1", "EST-2");
    }

    @Test
    public void getItemById() {
        ProductItem item = productItemDao.getItemById("EST-1");

        assertEquals("EST-1", item.getProductItemId());
        assertEquals("FI-SW-01", item.getProductId());
        assertEquals(new BigDecimal("16.50"), item.getListPrice());
        assertEquals(new BigDecimal("10.00"), item.getUnitCost());
        assertEquals(1, item.getSupplierId());
        assertEquals("P", item.getStatus());
        assertEquals("Large", item.getAttribute1());
    }
View Full Code Here


    public List<ProductItem> getAllProductItems(String productId) {
        return productItemDao.getItemListByProductId(productId);
    }

    public ProductItem getProductItem(String itemId) {
        ProductItem item = productItemDao.getItemById(itemId);

        if (item == null) {
            return null;
        }

        Product product = productDao.getProductById(item.getProductId());
        Category category = categoryDao.getCategoryById(product.getCategoryId());

        product.setCategory(category);
        item.setProduct(product);

        return item;
    }
View Full Code Here

        }

        // 依次按catId, productId, productItemId排序
        Collections.sort(cartItems, new Comparator<CartItem>() {
            public int compare(CartItem cartItem1, CartItem cartItem2) {
                ProductItem item1 = cartItem1.getProductItem();
                ProductItem item2 = cartItem2.getProductItem();

                if (item1 == null || item2 == null) {
                    return 0;
                }

                int compare = item1.getProduct().getCategory().getCategoryId()
                                   .compareTo(item2.getProduct().getCategory().getCategoryId());

                if (compare != 0) {
                    return compare;
                }

                compare = item1.getProduct().getProductId().compareTo(item2.getProduct().getProductId());

                if (compare != 0) {
                    return compare;
                }

                return item1.getProductItemId().compareTo(item2.getProductItemId());
            }
        });

        return cart;
    }
View Full Code Here

        return getSqlMapClientTemplate().queryForList("getItemListByProduct", productId);
    }

    public ProductItem getItemById(String itemId) {
        Integer i = (Integer) getSqlMapClientTemplate().queryForObject("getInventoryQuantity", itemId);
        ProductItem item = (ProductItem) getSqlMapClientTemplate().queryForObject("getItem", itemId);

        if (item != null && i != null) {
            item.setQuantity(i.intValue());
        }

        return item;
    }
View Full Code Here

    @Test
    public void getProductItem() {
        assertNull(storeManager.getProductItem("nonexist"));

        ProductItem item = storeManager.getProductItem("EST-1");
        assertEquals("EST-1", item.getProductItemId());

        Product prod = item.getProduct();
        assertEquals("FI-SW-01", prod.getProductId());
        assertEquals("Angelfish", prod.getName());

        Category cat = prod.getCategory();
        assertEquals("FISH", cat.getCategoryId());
View Full Code Here

TOP

Related Classes of com.alibaba.sample.petstore.dal.dataobject.ProductItem

Copyright © 2018 www.massapicom. 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.