001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.search;
016    
017    import com.liferay.portal.kernel.dao.search.DisplayTerms;
018    import com.liferay.portal.kernel.util.ParamUtil;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.theme.ThemeDisplay;
021    import com.liferay.portal.util.WebKeys;
022    
023    import java.util.Date;
024    
025    import javax.portlet.PortletRequest;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class ArticleDisplayTerms extends DisplayTerms {
031    
032            public static final String ARTICLE_ID = "searchArticleId";
033    
034            public static final String CONTENT = "content";
035    
036            public static final String DESCRIPTION = "description";
037    
038            public static final String DISPLAY_DATE_GT = "displayDateGT";
039    
040            public static final String DISPLAY_DATE_LT = "displayDateLT";
041    
042            public static final String GROUP_ID = "groupId";
043    
044            public static final String STATUS = "status";
045    
046            public static final String STRUCTURE_ID = "structureId";
047    
048            public static final String TEMPLATE_ID = "templateId";
049    
050            public static final String TITLE = "title";
051    
052            public static final String TYPE = "type";
053    
054            public static final String VERSION = "version";
055    
056            public ArticleDisplayTerms(PortletRequest portletRequest) {
057                    super(portletRequest);
058    
059                    ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
060                            WebKeys.THEME_DISPLAY);
061    
062                    articleId = ParamUtil.getString(portletRequest, ARTICLE_ID);
063                    content = ParamUtil.getString(portletRequest, CONTENT);
064                    description = ParamUtil.getString(portletRequest, DESCRIPTION);
065                    groupId = ParamUtil.getLong(
066                            portletRequest, GROUP_ID, themeDisplay.getScopeGroupId());
067                    status = ParamUtil.getString(portletRequest, STATUS);
068                    structureId = ParamUtil.getString(portletRequest, STRUCTURE_ID);
069                    templateId = ParamUtil.getString(portletRequest, TEMPLATE_ID);
070                    title = ParamUtil.getString(portletRequest, TITLE);
071                    type = ParamUtil.getString(portletRequest, TYPE);
072                    version = ParamUtil.getDouble(portletRequest, VERSION);
073            }
074    
075            public String getArticleId() {
076                    return articleId;
077            }
078    
079            public String getContent() {
080                    return content;
081            }
082    
083            public String getDescription() {
084                    return description;
085            }
086    
087            public Date getDisplayDateGT() {
088                    return displayDateGT;
089            }
090    
091            public Date getDisplayDateLT() {
092                    return displayDateLT;
093            }
094    
095            public long getGroupId() {
096                    return groupId;
097            }
098    
099            public String getStatus() {
100                    return status;
101            }
102    
103            public String getStructureId() {
104                    return structureId;
105            }
106    
107            public String getTemplateId() {
108                    return templateId;
109            }
110    
111            public String getTitle() {
112                    return title;
113            }
114    
115            public String getType() {
116                    return type;
117            }
118    
119            public double getVersion() {
120                    return version;
121            }
122    
123            public String getVersionString() {
124                    if (version != 0) {
125                            return String.valueOf(version);
126                    }
127                    else {
128                            return StringPool.BLANK;
129                    }
130            }
131    
132            public void setDisplayDateGT(Date displayDateGT) {
133                    this.displayDateGT = displayDateGT;
134            }
135    
136            public void setDisplayDateLT(Date displayDateLT) {
137                    this.displayDateLT = displayDateLT;
138            }
139    
140            public void setStatus(String status) {
141                    this.status = status;
142            }
143    
144            protected String articleId;
145            protected String content;
146            protected String description;
147            protected Date displayDateGT;
148            protected Date displayDateLT;
149            protected long groupId;
150            protected String status;
151            protected String structureId;
152            protected String templateId;
153            protected String title;
154            protected String type;
155            protected double version;
156    
157    }