1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
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.util.PortalUtil;
20  
21  import java.util.Date;
22  
23  import javax.portlet.PortletRequest;
24  
25  /**
26   * <a href="ArticleSearchTerms.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class ArticleSearchTerms extends ArticleDisplayTerms {
31  
32      public ArticleSearchTerms(PortletRequest portletRequest) {
33          super(portletRequest);
34  
35          groupId = ParamUtil.getLong(
36              portletRequest, GROUP_ID,
37              PortalUtil.getScopeGroupId(portletRequest));
38          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID, false);
39          version = ParamUtil.getDouble(portletRequest, VERSION);
40          title = DAOParamUtil.getLike(portletRequest, TITLE);
41          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
42          content = DAOParamUtil.getLike(portletRequest, CONTENT);
43          type = DAOParamUtil.getString(portletRequest, TYPE);
44          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
45          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
46          status = ParamUtil.getString(portletRequest, STATUS);
47      }
48  
49      public void setGroupId(long groupId) {
50          this.groupId = groupId;
51      }
52  
53      public Double getVersionObj() {
54          if (version == 0) {
55              return null;
56          }
57          else {
58              return new Double(version);
59          }
60      }
61  
62      public void setType(String type) {
63          this.type = type;
64      }
65  
66      public void setStructureId(String structureId) {
67          this.structureId = structureId;
68      }
69  
70      public void setStatus(String status) {
71          this.status = status;
72      }
73  
74      public Boolean getApprovedObj() {
75          if (status.equals("approved")) {
76              return Boolean.TRUE;
77          }
78          else if (status.equals("not-approved")) {
79              return Boolean.FALSE;
80          }
81          else if (status.equals("expired")) {
82              return Boolean.FALSE;
83          }
84          else if (status.equals("review")) {
85              return null;
86          }
87          else {
88              return null;
89          }
90      }
91  
92      public Boolean getExpiredObj() {
93          if (status.equals("approved")) {
94              return Boolean.FALSE;
95          }
96          else if (status.equals("not-approved")) {
97              return Boolean.FALSE;
98          }
99          else if (status.equals("expired")) {
100             return Boolean.TRUE;
101         }
102         else if (status.equals("review")) {
103             return Boolean.FALSE;
104         }
105         else {
106             return null;
107         }
108     }
109 
110     public Date getReviewDate() {
111         if (status.equals("review")) {
112             return new Date();
113         }
114         else {
115             return null;
116         }
117     }
118 
119 }