1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.journal.search;
16  
17  import com.liferay.portal.kernel.dao.search.DAOParamUtil;
18  import com.liferay.portal.kernel.util.ParamUtil;
19  import com.liferay.portal.kernel.workflow.WorkflowConstants;
20  import com.liferay.portal.theme.ThemeDisplay;
21  import com.liferay.portal.util.WebKeys;
22  
23  import java.util.Date;
24  
25  import javax.portlet.PortletRequest;
26  
27  /**
28   * <a href="ArticleSearchTerms.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class ArticleSearchTerms extends ArticleDisplayTerms {
33  
34      public ArticleSearchTerms(PortletRequest portletRequest) {
35          super(portletRequest);
36  
37          ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
38              WebKeys.THEME_DISPLAY);
39  
40          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID, false);
41          content = DAOParamUtil.getLike(portletRequest, CONTENT);
42          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
43          groupId = ParamUtil.getLong(
44              portletRequest, GROUP_ID, themeDisplay.getScopeGroupId());
45          status = ParamUtil.getString(portletRequest, STATUS);
46          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
47          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
48          title = DAOParamUtil.getLike(portletRequest, TITLE);
49          type = DAOParamUtil.getString(portletRequest, TYPE);
50          version = ParamUtil.getDouble(portletRequest, VERSION);
51      }
52  
53      public Date getReviewDate() {
54          if (status.equals("review")) {
55              return new Date();
56          }
57          else {
58              return null;
59          }
60      }
61  
62      public int getStatusCode() {
63          if (status.equals("approved")) {
64              return WorkflowConstants.STATUS_APPROVED;
65          }
66          else if (status.equals("draft")) {
67              return WorkflowConstants.STATUS_DRAFT;
68          }
69          else if (status.equals("expired")) {
70              return WorkflowConstants.STATUS_EXPIRED;
71          }
72          else if (status.equals("pending")) {
73              return WorkflowConstants.STATUS_PENDING;
74          }
75          else {
76              return WorkflowConstants.STATUS_ANY;
77          }
78      }
79  
80      public Double getVersionObj() {
81          if (version == 0) {
82              return null;
83          }
84          else {
85              return new Double(version);
86          }
87      }
88  
89      public void setArticleId(String articleId) {
90          this.articleId = articleId;
91      }
92  
93      public void setGroupId(long groupId) {
94          this.groupId = groupId;
95      }
96  
97      public void setStatus(String status) {
98          this.status = status;
99      }
100 
101     public void setStructureId(String structureId) {
102         this.structureId = structureId;
103     }
104 
105     public void setType(String type) {
106         this.type = type;
107     }
108 
109     public void setVersion(double version) {
110         this.version = version;
111     }
112 
113 }