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