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.theme.ThemeDisplay;
25  import com.liferay.portal.util.WebKeys;
26  
27  import java.util.Date;
28  
29  import javax.portlet.PortletRequest;
30  
31  /**
32   * <a href="ArticleSearchTerms.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class ArticleSearchTerms extends ArticleDisplayTerms {
38  
39      public ArticleSearchTerms(PortletRequest portletRequest) {
40          super(portletRequest);
41  
42          ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
43              WebKeys.THEME_DISPLAY);
44  
45          groupId = ParamUtil.getLong(
46              portletRequest, GROUP_ID, themeDisplay.getScopeGroupId());
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 }