1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.journal.search;
21  
22  import com.liferay.portal.kernel.dao.search.DAOParamUtil;
23  import com.liferay.portal.kernel.util.ParamUtil;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import java.util.Date;
27  
28  import javax.portlet.PortletRequest;
29  
30  /**
31   * <a href="ArticleSearchTerms.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   *
35   */
36  public class ArticleSearchTerms extends ArticleDisplayTerms {
37  
38      public ArticleSearchTerms(PortletRequest portletRequest) {
39          super(portletRequest);
40  
41          groupId = ParamUtil.getLong(
42              portletRequest, GROUP_ID,
43              PortalUtil.getScopeGroupId(portletRequest));
44          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID);
45          version = ParamUtil.getDouble(portletRequest, VERSION);
46          title = DAOParamUtil.getLike(portletRequest, TITLE);
47          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
48          content = DAOParamUtil.getLike(portletRequest, CONTENT);
49          type = DAOParamUtil.getString(portletRequest, TYPE);
50          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
51          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
52          status = ParamUtil.getString(portletRequest, STATUS);
53      }
54  
55      public void setGroupId(long groupId) {
56          this.groupId = groupId;
57      }
58  
59      public Double getVersionObj() {
60          if (version == 0) {
61              return null;
62          }
63          else {
64              return new Double(version);
65          }
66      }
67  
68      public void setType(String type) {
69          this.type = type;
70      }
71  
72      public void setStructureId(String structureId) {
73          this.structureId = structureId;
74      }
75  
76      public void setStatus(String status) {
77          this.status = status;
78      }
79  
80      public Boolean getApprovedObj() {
81          if (status.equals("approved")) {
82              return Boolean.TRUE;
83          }
84          else if (status.equals("not-approved")) {
85              return Boolean.FALSE;
86          }
87          else if (status.equals("expired")) {
88              return Boolean.FALSE;
89          }
90          else if (status.equals("review")) {
91              return null;
92          }
93          else {
94              return null;
95          }
96      }
97  
98      public Boolean getExpiredObj() {
99          if (status.equals("approved")) {
100             return Boolean.FALSE;
101         }
102         else if (status.equals("not-approved")) {
103             return Boolean.FALSE;
104         }
105         else if (status.equals("expired")) {
106             return Boolean.TRUE;
107         }
108         else if (status.equals("review")) {
109             return Boolean.FALSE;
110         }
111         else {
112             return null;
113         }
114     }
115 
116     public Date getReviewDate() {
117         if (status.equals("review")) {
118             return new Date();
119         }
120         else {
121             return null;
122         }
123     }
124 
125 }