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.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  public class ArticleSearchTerms extends ArticleDisplayTerms {
39  
40      public ArticleSearchTerms(PortletRequest portletRequest) {
41          super(portletRequest);
42  
43          groupId = ParamUtil.getLong(
44              portletRequest, GROUP_ID,
45              PortalUtil.getScopeGroupId(portletRequest));
46          articleId = DAOParamUtil.getLike(portletRequest, ARTICLE_ID);
47          version = ParamUtil.getDouble(portletRequest, VERSION);
48          title = DAOParamUtil.getLike(portletRequest, TITLE);
49          description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
50          content = DAOParamUtil.getLike(portletRequest, CONTENT);
51          type = DAOParamUtil.getString(portletRequest, TYPE);
52          structureId = DAOParamUtil.getString(portletRequest, STRUCTURE_ID);
53          templateId = DAOParamUtil.getString(portletRequest, TEMPLATE_ID);
54          status = ParamUtil.getString(portletRequest, STATUS);
55      }
56  
57      public void setGroupId(long groupId) {
58          this.groupId = groupId;
59      }
60  
61      public Double getVersionObj() {
62          if (version == 0) {
63              return null;
64          }
65          else {
66              return new Double(version);
67          }
68      }
69  
70      public void setType(String type) {
71          this.type = type;
72      }
73  
74      public void setStructureId(String structureId) {
75          this.structureId = structureId;
76      }
77  
78      public void setStatus(String status) {
79          this.status = status;
80      }
81  
82      public Boolean getApprovedObj() {
83          if (status.equals("approved")) {
84              return Boolean.TRUE;
85          }
86          else if (status.equals("not-approved")) {
87              return Boolean.FALSE;
88          }
89          else if (status.equals("expired")) {
90              return Boolean.FALSE;
91          }
92          else if (status.equals("review")) {
93              return null;
94          }
95          else {
96              return null;
97          }
98      }
99  
100     public Boolean getExpiredObj() {
101         if (status.equals("approved")) {
102             return Boolean.FALSE;
103         }
104         else if (status.equals("not-approved")) {
105             return Boolean.FALSE;
106         }
107         else if (status.equals("expired")) {
108             return Boolean.TRUE;
109         }
110         else if (status.equals("review")) {
111             return Boolean.FALSE;
112         }
113         else {
114             return null;
115         }
116     }
117 
118     public Date getReviewDate() {
119         if (status.equals("review")) {
120             return new Date();
121         }
122         else {
123             return null;
124         }
125     }
126 
127 }