1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.journal.search;
24  
25  import com.liferay.portal.kernel.dao.search.DAOParamUtil;
26  import com.liferay.portal.kernel.util.ParamUtil;
27  import com.liferay.portal.theme.ThemeDisplay;
28  import com.liferay.portal.util.WebKeys;
29  
30  import java.util.Date;
31  
32  import javax.portlet.PortletRequest;
33  
34  /**
35   * <a href="ArticleSearchTerms.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Brian Wing Shun Chan
38   *
39   */
40  public class ArticleSearchTerms extends ArticleDisplayTerms {
41  
42      public ArticleSearchTerms(PortletRequest portletRequest) {
43          super(portletRequest);
44  
45          ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
46              WebKeys.THEME_DISPLAY);
47  
48          groupId = ParamUtil.getLong(
49              portletRequest, GROUP_ID, themeDisplay.getScopeGroupId());
50          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID);
51          version = ParamUtil.getDouble(portletRequest, VERSION);
52          title = DAOParamUtil.getLike(portletRequest, TITLE);
53          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
54          content = DAOParamUtil.getLike(portletRequest, CONTENT);
55          type = DAOParamUtil.getString(portletRequest, TYPE);
56          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
57          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
58          status = ParamUtil.getString(portletRequest, STATUS);
59      }
60  
61      public void setGroupId(long groupId) {
62          this.groupId = groupId;
63      }
64  
65      public Double getVersionObj() {
66          if (version == 0) {
67              return null;
68          }
69          else {
70              return new Double(version);
71          }
72      }
73  
74      public void setType(String type) {
75          this.type = type;
76      }
77  
78      public void setStructureId(String structureId) {
79          this.structureId = structureId;
80      }
81  
82      public void setStatus(String status) {
83          this.status = status;
84      }
85  
86      public Boolean getApprovedObj() {
87          if (status.equals("approved")) {
88              return Boolean.TRUE;
89          }
90          else if (status.equals("not-approved")) {
91              return Boolean.FALSE;
92          }
93          else if (status.equals("expired")) {
94              return Boolean.FALSE;
95          }
96          else if (status.equals("review")) {
97              return null;
98          }
99          else {
100             return null;
101         }
102     }
103 
104     public Boolean getExpiredObj() {
105         if (status.equals("approved")) {
106             return Boolean.FALSE;
107         }
108         else if (status.equals("not-approved")) {
109             return Boolean.FALSE;
110         }
111         else if (status.equals("expired")) {
112             return Boolean.TRUE;
113         }
114         else if (status.equals("review")) {
115             return Boolean.FALSE;
116         }
117         else {
118             return null;
119         }
120     }
121 
122     public Date getReviewDate() {
123         if (status.equals("review")) {
124             return new Date();
125         }
126         else {
127             return null;
128         }
129     }
130 
131 }