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