1   /**
2    * Copyright (c) 2000-2008 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.util.PortalUtil;
28  
29  import java.util.Date;
30  
31  import javax.portlet.RenderRequest;
32  
33  /**
34   * <a href="ArticleSearchTerms.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class ArticleSearchTerms extends ArticleDisplayTerms {
40  
41      public ArticleSearchTerms(RenderRequest renderRequest) {
42          super(renderRequest);
43  
44          groupId = ParamUtil.getLong(
45              renderRequest, GROUP_ID,
46              PortalUtil.getPortletGroupId(renderRequest));
47          articleId = DAOParamUtil.getLike(renderRequest, ARTICLE_ID);
48          version = ParamUtil.getDouble(renderRequest, VERSION);
49          title = DAOParamUtil.getLike(renderRequest, TITLE);
50          description = DAOParamUtil.getLike(renderRequest, DESCRIPTION);
51          content = DAOParamUtil.getLike(renderRequest, CONTENT);
52          type = DAOParamUtil.getString(renderRequest, TYPE);
53          structureId = DAOParamUtil.getString(renderRequest, STRUCTURE_ID);
54          templateId = DAOParamUtil.getString(renderRequest, TEMPLATE_ID);
55          status = ParamUtil.getString(renderRequest, STATUS);
56      }
57  
58      public void setGroupId(long groupId) {
59          this.groupId = groupId;
60      }
61  
62      public Double getVersionObj() {
63          if (version == 0) {
64              return null;
65          }
66          else {
67              return new Double(version);
68          }
69      }
70  
71      public void setType(String type) {
72          this.type = type;
73      }
74  
75      public void setStatus(String status) {
76          this.status = status;
77      }
78  
79      public Boolean getApprovedObj() {
80          if (status.equals("approved")) {
81              return Boolean.TRUE;
82          }
83          else if (status.equals("not-approved")) {
84              return Boolean.FALSE;
85          }
86          else if (status.equals("expired")) {
87              return Boolean.FALSE;
88          }
89          else if (status.equals("review")) {
90              return null;
91          }
92          else {
93              return null;
94          }
95      }
96  
97      public Boolean getExpiredObj() {
98          if (status.equals("approved")) {
99              return Boolean.FALSE;
100         }
101         else if (status.equals("not-approved")) {
102             return Boolean.FALSE;
103         }
104         else if (status.equals("expired")) {
105             return Boolean.TRUE;
106         }
107         else if (status.equals("review")) {
108             return Boolean.FALSE;
109         }
110         else {
111             return null;
112         }
113     }
114 
115     public Date getReviewDate() {
116         if (status.equals("review")) {
117             return new Date();
118         }
119         else {
120             return null;
121         }
122     }
123 
124 }