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