001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.search;
016    
017    import com.liferay.portal.kernel.dao.search.DAOParamUtil;
018    import com.liferay.portlet.shopping.model.ShoppingOrderConstants;
019    
020    import javax.portlet.PortletRequest;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class OrderSearchTerms extends OrderDisplayTerms {
026    
027            public OrderSearchTerms(PortletRequest portletRequest) {
028                    super(portletRequest);
029    
030                    emailAddress = DAOParamUtil.getLike(portletRequest, EMAIL_ADDRESS);
031                    firstName = DAOParamUtil.getLike(portletRequest, FIRST_NAME);
032                    lastName = DAOParamUtil.getLike(portletRequest, LAST_NAME);
033                    number = DAOParamUtil.getLike(portletRequest, NUMBER);
034                    status = DAOParamUtil.getString(portletRequest, STATUS);
035            }
036    
037            @Override
038            public String getStatus() {
039                    if (status == null) {
040                            return null;
041                    }
042                    else if (status.equals(ShoppingOrderConstants.STATUSES[0])) {
043                            return ShoppingOrderConstants.STATUS_CHECKOUT;
044                    }
045                    else if (status.equals(ShoppingOrderConstants.STATUSES[1])) {
046                            return ShoppingOrderConstants.STATUS_COMPLETED;
047                    }
048                    else if (status.equals(ShoppingOrderConstants.STATUSES[2])) {
049                            return ShoppingOrderConstants.STATUS_DENIED;
050                    }
051                    else if (status.equals(ShoppingOrderConstants.STATUSES[3])) {
052                            return ShoppingOrderConstants.STATUS_PENDING;
053                    }
054                    else if (status.equals(ShoppingOrderConstants.STATUSES[4])) {
055                            return ShoppingOrderConstants.STATUS_REFUNDED;
056                    }
057                    else {
058                            return null;
059                    }
060            }
061    
062    }