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 = themeDisplay.getScopeGroupId();
49          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID);
50          version = ParamUtil.getDouble(portletRequest, VERSION);
51          title = DAOParamUtil.getLike(portletRequest, TITLE);
52          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
53          content = DAOParamUtil.getLike(portletRequest, CONTENT);
54          type = DAOParamUtil.getString(portletRequest, TYPE);
55          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
56          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
57          status = ParamUtil.getString(portletRequest, STATUS);
58      }
59  
60      public void setGroupId(long groupId) {
61          this.groupId = groupId;
62      }
63  
64      public Double getVersionObj() {
65          if (version == 0) {
66              return null;
67          }
68          else {
69              return new Double(version);
70          }
71      }
72  
73      public void setType(String type) {
74          this.type = type;
75      }
76  
77      public void setStatus(String status) {
78          this.status = status;
79      }
80  
81      public Boolean getApprovedObj() {
82          if (status.equals("approved")) {
83              return Boolean.TRUE;
84          }
85          else if (status.equals("not-approved")) {
86              return Boolean.FALSE;
87          }
88          else if (status.equals("expired")) {
89              return Boolean.FALSE;
90          }
91          else if (status.equals("review")) {
92              return null;
93          }
94          else {
95              return null;
96          }
97      }
98  
99      public Boolean getExpiredObj() {
100         if (status.equals("approved")) {
101             return Boolean.FALSE;
102         }
103         else if (status.equals("not-approved")) {
104             return Boolean.FALSE;
105         }
106         else if (status.equals("expired")) {
107             return Boolean.TRUE;
108         }
109         else if (status.equals("review")) {
110             return Boolean.FALSE;
111         }
112         else {
113             return null;
114         }
115     }
116 
117     public Date getReviewDate() {
118         if (status.equals("review")) {
119             return new Date();
120         }
121         else {
122             return null;
123         }
124     }
125 
126 }