001    /**
002     * Copyright (c) 2000-2010 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.journal.search;
016    
017    import com.liferay.portal.kernel.dao.search.DAOParamUtil;
018    import com.liferay.portal.kernel.util.ParamUtil;
019    import com.liferay.portal.kernel.workflow.WorkflowConstants;
020    import com.liferay.portal.theme.ThemeDisplay;
021    import com.liferay.portal.util.WebKeys;
022    
023    import java.util.Date;
024    
025    import javax.portlet.PortletRequest;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class ArticleSearchTerms extends ArticleDisplayTerms {
031    
032            public ArticleSearchTerms(PortletRequest portletRequest) {
033                    super(portletRequest);
034    
035                    ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
036                            WebKeys.THEME_DISPLAY);
037    
038                    articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID, false);
039                    content = DAOParamUtil.getLike(portletRequest, CONTENT);
040                    description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
041                    groupId = ParamUtil.getLong(
042                            portletRequest, GROUP_ID, themeDisplay.getScopeGroupId());
043                    status = ParamUtil.getString(portletRequest, STATUS);
044                    structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
045                    templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
046                    title = DAOParamUtil.getLike(portletRequest, TITLE);
047                    type = DAOParamUtil.getString(portletRequest, TYPE);
048                    version = ParamUtil.getDouble(portletRequest, VERSION);
049            }
050    
051            public Date getReviewDate() {
052                    if (status.equals("review")) {
053                            return new Date();
054                    }
055                    else {
056                            return null;
057                    }
058            }
059    
060            public int getStatusCode() {
061                    if (status.equals("approved")) {
062                            return WorkflowConstants.STATUS_APPROVED;
063                    }
064                    else if (status.equals("draft")) {
065                            return WorkflowConstants.STATUS_DRAFT;
066                    }
067                    else if (status.equals("expired")) {
068                            return WorkflowConstants.STATUS_EXPIRED;
069                    }
070                    else if (status.equals("pending")) {
071                            return WorkflowConstants.STATUS_PENDING;
072                    }
073                    else {
074                            return WorkflowConstants.STATUS_ANY;
075                    }
076            }
077    
078            public Double getVersionObj() {
079                    if (version == 0) {
080                            return null;
081                    }
082                    else {
083                            return new Double(version);
084                    }
085            }
086    
087            public void setArticleId(String articleId) {
088                    this.articleId = articleId;
089            }
090    
091            public void setGroupId(long groupId) {
092                    this.groupId = groupId;
093            }
094    
095            public void setStatus(String status) {
096                    this.status = status;
097            }
098    
099            public void setStructureId(String structureId) {
100                    this.structureId = structureId;
101            }
102    
103            public void setType(String type) {
104                    this.type = type;
105            }
106    
107            public void setVersion(double version) {
108                    this.version = version;
109            }
110    
111    }