1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.shopping.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portlet.shopping.model.ShoppingItem;
20  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
21  import com.liferay.portlet.shopping.model.impl.ShoppingItemPriceImpl;
22  import com.liferay.portlet.shopping.service.base.ShoppingItemPriceLocalServiceBaseImpl;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * <a href="ShoppingItemPriceLocalServiceImpl.java.html"><b><i>View Source</i>
29   * </b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class ShoppingItemPriceLocalServiceImpl
34      extends ShoppingItemPriceLocalServiceBaseImpl {
35  
36      public List<ShoppingItemPrice> getItemPrices(long itemId)
37          throws PortalException, SystemException {
38  
39          ShoppingItem item = shoppingItemPersistence.findByPrimaryKey(itemId);
40  
41          List<ShoppingItemPrice> itemPrices =
42              shoppingItemPricePersistence.findByItemId(itemId);
43  
44          if (itemPrices.isEmpty()) {
45              itemPrices = new ArrayList<ShoppingItemPrice>();
46  
47              ShoppingItemPrice itemPrice = shoppingItemPricePersistence.create(
48                  0);
49  
50              itemPrice.setItemId(itemId);
51              itemPrice.setMinQuantity(item.getMinQuantity());
52              itemPrice.setMaxQuantity(item.getMaxQuantity());
53              itemPrice.setPrice(item.getPrice());
54              itemPrice.setDiscount(item.getDiscount());
55              itemPrice.setTaxable(item.isTaxable());
56              itemPrice.setShipping(item.getShipping());
57              itemPrice.setUseShippingFormula(item.isUseShippingFormula());
58              itemPrice.setStatus(ShoppingItemPriceImpl.STATUS_ACTIVE_DEFAULT);
59  
60              itemPrices.add(itemPrice);
61          }
62  
63          return itemPrices;
64      }
65  
66  }