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.search;
16  
17  import com.liferay.portal.kernel.dao.search.SearchContainer;
18  import com.liferay.portlet.shopping.model.ShoppingCoupon;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  import javax.portlet.PortletRequest;
24  import javax.portlet.PortletURL;
25  
26  /**
27   * <a href="CouponSearch.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class CouponSearch extends SearchContainer<ShoppingCoupon> {
32  
33      static List<String> headerNames = new ArrayList<String>();
34  
35      static {
36          headerNames.add("code");
37          headerNames.add("description");
38          headerNames.add("start-date");
39          headerNames.add("expiration-date");
40          headerNames.add("discount-type");
41      }
42  
43      public static final String EMPTY_RESULTS_MESSAGE =
44          "no-coupons-were-found";
45  
46      public CouponSearch(PortletRequest portletRequest, PortletURL iteratorURL) {
47          super(
48              portletRequest, new CouponDisplayTerms(portletRequest),
49              new CouponSearchTerms(portletRequest), DEFAULT_CUR_PARAM,
50              DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
51  
52          CouponDisplayTerms displayTerms =
53              (CouponDisplayTerms)getDisplayTerms();
54  
55          iteratorURL.setParameter(
56              CouponDisplayTerms.CODE, displayTerms.getCode());
57          iteratorURL.setParameter(
58              CouponDisplayTerms.DISCOUNT_TYPE, displayTerms.getDiscountType());
59          iteratorURL.setParameter(
60              CouponDisplayTerms.ACTIVE, String.valueOf(displayTerms.isActive()));
61      }
62  
63  }