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.util.PortalUtil;
28  
29  import java.util.Date;
30  
31  import javax.portlet.PortletRequest;
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(PortletRequest portletRequest) {
42          super(portletRequest);
43  
44          groupId = ParamUtil.getLong(
45              portletRequest, GROUP_ID,
46              PortalUtil.getScopeGroupId(portletRequest));
47          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID);
48          version = ParamUtil.getDouble(portletRequest, VERSION);
49          title = DAOParamUtil.getLike(portletRequest, TITLE);
50          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
51          content = DAOParamUtil.getLike(portletRequest, CONTENT);
52          type = DAOParamUtil.getString(portletRequest, TYPE);
53          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
54          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
55          status = ParamUtil.getString(portletRequest, 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 setStructureId(String structureId) {
76          this.structureId = structureId;
77      }
78  
79      public void setStatus(String status) {
80          this.status = status;
81      }
82  
83      public Boolean getApprovedObj() {
84          if (status.equals("approved")) {
85              return Boolean.TRUE;
86          }
87          else if (status.equals("not-approved")) {
88              return Boolean.FALSE;
89          }
90          else if (status.equals("expired")) {
91              return Boolean.FALSE;
92          }
93          else if (status.equals("review")) {
94              return null;
95          }
96          else {
97              return null;
98          }
99      }
100 
101     public Boolean getExpiredObj() {
102         if (status.equals("approved")) {
103             return Boolean.FALSE;
104         }
105         else if (status.equals("not-approved")) {
106             return Boolean.FALSE;
107         }
108         else if (status.equals("expired")) {
109             return Boolean.TRUE;
110         }
111         else if (status.equals("review")) {
112             return Boolean.FALSE;
113         }
114         else {
115             return null;
116         }
117     }
118 
119     public Date getReviewDate() {
120         if (status.equals("review")) {
121             return new Date();
122         }
123         else {
124             return null;
125         }
126     }
127 
128 }