001
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.ArrayList;
024 import java.util.Date;
025 import java.util.List;
026
027 import javax.portlet.PortletRequest;
028
029
032 public class ArticleDisplayTerms extends DisplayTerms {
033
034 public static final String ARTICLE_ID = "searchArticleId";
035
036 public static final String CONTENT = "content";
037
038 public static final String DESCRIPTION = "description";
039
040 public static final String DISPLAY_DATE_GT = "displayDateGT";
041
042 public static final String DISPLAY_DATE_LT = "displayDateLT";
043
044 public static final String FOLDER_ID = "folderId";
045
046 public static final String GROUP_ID = "groupId";
047
048 public static final String NAVIGATION = "navigation";
049
050 public static final String STATUS = "status";
051
052 public static final String STRUCTURE_ID = "structureId";
053
054 public static final String TEMPLATE_ID = "templateId";
055
056 public static final String TITLE = "title";
057
058 public static final String TYPE = "type";
059
060 public static final String VERSION = "version";
061
062 public ArticleDisplayTerms(PortletRequest portletRequest) {
063 super(portletRequest);
064
065 articleId = ParamUtil.getString(portletRequest, ARTICLE_ID);
066 content = ParamUtil.getString(portletRequest, CONTENT);
067 description = ParamUtil.getString(portletRequest, DESCRIPTION);
068 folderId = ParamUtil.getLong(portletRequest, FOLDER_ID);
069 navigation = ParamUtil.getString(portletRequest, NAVIGATION);
070 status = ParamUtil.getString(portletRequest, STATUS);
071 structureId = ParamUtil.getString(portletRequest, STRUCTURE_ID);
072 templateId = ParamUtil.getString(portletRequest, TEMPLATE_ID);
073 title = ParamUtil.getString(portletRequest, TITLE);
074 type = ParamUtil.getString(portletRequest, TYPE);
075 version = ParamUtil.getDouble(portletRequest, VERSION);
076
077 groupId = setGroupId(portletRequest);
078 }
079
080 public String getArticleId() {
081 return articleId;
082 }
083
084 public String getContent() {
085 return content;
086 }
087
088 public String getDescription() {
089 return description;
090 }
091
092 public Date getDisplayDateGT() {
093 return displayDateGT;
094 }
095
096 public Date getDisplayDateLT() {
097 return displayDateLT;
098 }
099
100 public long getFolderId() {
101 return folderId;
102 }
103
104 public List<Long> getFolderIds() {
105 if (folderIds != null) {
106 return folderIds;
107 }
108
109 List<Long> folderIds = new ArrayList<Long>();
110
111 folderIds.add(folderId);
112
113 return folderIds;
114 }
115
116 public long getGroupId() {
117 return groupId;
118 }
119
120 public String getNavigation() {
121 return navigation;
122 }
123
124 public String getStatus() {
125 return status;
126 }
127
128 public String getStructureId() {
129 return structureId;
130 }
131
132 public String getTemplateId() {
133 return templateId;
134 }
135
136 public String getTitle() {
137 return title;
138 }
139
140 public String getType() {
141 return type;
142 }
143
144 public double getVersion() {
145 return version;
146 }
147
148 public String getVersionString() {
149 if (version != 0) {
150 return String.valueOf(version);
151 }
152 else {
153 return StringPool.BLANK;
154 }
155 }
156
157 public boolean isNavigationRecent() {
158 if (navigation.equals("recent")) {
159 return true;
160 }
161
162 return false;
163 }
164
165 public void setDisplayDateGT(Date displayDateGT) {
166 this.displayDateGT = displayDateGT;
167 }
168
169 public void setDisplayDateLT(Date displayDateLT) {
170 this.displayDateLT = displayDateLT;
171 }
172
173 public void setFolderIds(List<Long> folderIds) {
174 this.folderIds = folderIds;
175 }
176
177 public long setGroupId(PortletRequest portletRequest) {
178 groupId = ParamUtil.getLong(portletRequest, GROUP_ID);
179
180 if (groupId != 0) {
181 return groupId;
182 }
183
184 ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
185 WebKeys.THEME_DISPLAY);
186
187 return themeDisplay.getScopeGroupId();
188 }
189
190 public void setStatus(String status) {
191 this.status = status;
192 }
193
194 protected String articleId;
195 protected String content;
196 protected String description;
197 protected Date displayDateGT;
198 protected Date displayDateLT;
199 protected long folderId;
200 protected List<Long> folderIds;
201 protected long groupId;
202 protected String navigation;
203 protected String status;
204 protected String structureId;
205 protected String templateId;
206 protected String title;
207 protected String type;
208 protected double version;
209
210 }