1
22
23 package com.liferay.portlet.wiki.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.impl.BaseModelImpl;
29 import com.liferay.portal.util.PropsUtil;
30
31 import com.liferay.portlet.wiki.model.WikiPage;
32 import com.liferay.portlet.wiki.model.WikiPageSoap;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.Date;
42 import java.util.List;
43
44
64 public class WikiPageModelImpl extends BaseModelImpl {
65 public static final String TABLE_NAME = "WikiPage";
66 public static final Object[][] TABLE_COLUMNS = {
67 { "uuid_", new Integer(Types.VARCHAR) },
68
69
70 { "pageId", new Integer(Types.BIGINT) },
71
72
73 { "resourcePrimKey", new Integer(Types.BIGINT) },
74
75
76 { "companyId", new Integer(Types.BIGINT) },
77
78
79 { "userId", new Integer(Types.BIGINT) },
80
81
82 { "userName", new Integer(Types.VARCHAR) },
83
84
85 { "createDate", new Integer(Types.TIMESTAMP) },
86
87
88 { "nodeId", new Integer(Types.BIGINT) },
89
90
91 { "title", new Integer(Types.VARCHAR) },
92
93
94 { "version", new Integer(Types.DOUBLE) },
95
96
97 { "content", new Integer(Types.CLOB) },
98
99
100 { "format", new Integer(Types.VARCHAR) },
101
102
103 { "head", new Integer(Types.BOOLEAN) },
104
105
106 { "parentTitle", new Integer(Types.VARCHAR) },
107
108
109 { "redirectTitle", new Integer(Types.VARCHAR) }
110 };
111 public static final String TABLE_SQL_CREATE = "create table WikiPage (uuid_ VARCHAR(75) null,pageId LONG not null primary key,resourcePrimKey LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,nodeId LONG,title VARCHAR(75) null,version DOUBLE,content TEXT null,format VARCHAR(75) null,head BOOLEAN,parentTitle VARCHAR(75) null,redirectTitle VARCHAR(75) null)";
112 public static final String TABLE_SQL_DROP = "drop table WikiPage";
113 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
114 "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPage"),
115 true);
116
117 public static WikiPage toModel(WikiPageSoap soapModel) {
118 WikiPage model = new WikiPageImpl();
119
120 model.setUuid(soapModel.getUuid());
121 model.setPageId(soapModel.getPageId());
122 model.setResourcePrimKey(soapModel.getResourcePrimKey());
123 model.setCompanyId(soapModel.getCompanyId());
124 model.setUserId(soapModel.getUserId());
125 model.setUserName(soapModel.getUserName());
126 model.setCreateDate(soapModel.getCreateDate());
127 model.setNodeId(soapModel.getNodeId());
128 model.setTitle(soapModel.getTitle());
129 model.setVersion(soapModel.getVersion());
130 model.setContent(soapModel.getContent());
131 model.setFormat(soapModel.getFormat());
132 model.setHead(soapModel.getHead());
133 model.setParentTitle(soapModel.getParentTitle());
134 model.setRedirectTitle(soapModel.getRedirectTitle());
135
136 return model;
137 }
138
139 public static List<WikiPage> toModels(WikiPageSoap[] soapModels) {
140 List<WikiPage> models = new ArrayList<WikiPage>(soapModels.length);
141
142 for (WikiPageSoap soapModel : soapModels) {
143 models.add(toModel(soapModel));
144 }
145
146 return models;
147 }
148
149 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
150 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPage"));
151
152 public WikiPageModelImpl() {
153 }
154
155 public long getPrimaryKey() {
156 return _pageId;
157 }
158
159 public void setPrimaryKey(long pk) {
160 setPageId(pk);
161 }
162
163 public Serializable getPrimaryKeyObj() {
164 return new Long(_pageId);
165 }
166
167 public String getUuid() {
168 return GetterUtil.getString(_uuid);
169 }
170
171 public void setUuid(String uuid) {
172 if ((uuid != null) && (uuid != _uuid)) {
173 _uuid = uuid;
174 }
175 }
176
177 public long getPageId() {
178 return _pageId;
179 }
180
181 public void setPageId(long pageId) {
182 if (pageId != _pageId) {
183 _pageId = pageId;
184 }
185 }
186
187 public long getResourcePrimKey() {
188 return _resourcePrimKey;
189 }
190
191 public void setResourcePrimKey(long resourcePrimKey) {
192 if (resourcePrimKey != _resourcePrimKey) {
193 _resourcePrimKey = resourcePrimKey;
194 }
195 }
196
197 public long getCompanyId() {
198 return _companyId;
199 }
200
201 public void setCompanyId(long companyId) {
202 if (companyId != _companyId) {
203 _companyId = companyId;
204 }
205 }
206
207 public long getUserId() {
208 return _userId;
209 }
210
211 public void setUserId(long userId) {
212 if (userId != _userId) {
213 _userId = userId;
214 }
215 }
216
217 public String getUserName() {
218 return GetterUtil.getString(_userName);
219 }
220
221 public void setUserName(String userName) {
222 if (((userName == null) && (_userName != null)) ||
223 ((userName != null) && (_userName == null)) ||
224 ((userName != null) && (_userName != null) &&
225 !userName.equals(_userName))) {
226 _userName = userName;
227 }
228 }
229
230 public Date getCreateDate() {
231 return _createDate;
232 }
233
234 public void setCreateDate(Date createDate) {
235 if (((createDate == null) && (_createDate != null)) ||
236 ((createDate != null) && (_createDate == null)) ||
237 ((createDate != null) && (_createDate != null) &&
238 !createDate.equals(_createDate))) {
239 _createDate = createDate;
240 }
241 }
242
243 public long getNodeId() {
244 return _nodeId;
245 }
246
247 public void setNodeId(long nodeId) {
248 if (nodeId != _nodeId) {
249 _nodeId = nodeId;
250 }
251 }
252
253 public String getTitle() {
254 return GetterUtil.getString(_title);
255 }
256
257 public void setTitle(String title) {
258 if (((title == null) && (_title != null)) ||
259 ((title != null) && (_title == null)) ||
260 ((title != null) && (_title != null) && !title.equals(_title))) {
261 _title = title;
262 }
263 }
264
265 public double getVersion() {
266 return _version;
267 }
268
269 public void setVersion(double version) {
270 if (version != _version) {
271 _version = version;
272 }
273 }
274
275 public String getContent() {
276 return GetterUtil.getString(_content);
277 }
278
279 public void setContent(String content) {
280 if (((content == null) && (_content != null)) ||
281 ((content != null) && (_content == null)) ||
282 ((content != null) && (_content != null) &&
283 !content.equals(_content))) {
284 _content = content;
285 }
286 }
287
288 public String getFormat() {
289 return GetterUtil.getString(_format);
290 }
291
292 public void setFormat(String format) {
293 if (((format == null) && (_format != null)) ||
294 ((format != null) && (_format == null)) ||
295 ((format != null) && (_format != null) &&
296 !format.equals(_format))) {
297 _format = format;
298 }
299 }
300
301 public boolean getHead() {
302 return _head;
303 }
304
305 public boolean isHead() {
306 return _head;
307 }
308
309 public void setHead(boolean head) {
310 if (head != _head) {
311 _head = head;
312 }
313 }
314
315 public String getParentTitle() {
316 return GetterUtil.getString(_parentTitle);
317 }
318
319 public void setParentTitle(String parentTitle) {
320 if (((parentTitle == null) && (_parentTitle != null)) ||
321 ((parentTitle != null) && (_parentTitle == null)) ||
322 ((parentTitle != null) && (_parentTitle != null) &&
323 !parentTitle.equals(_parentTitle))) {
324 _parentTitle = parentTitle;
325 }
326 }
327
328 public String getRedirectTitle() {
329 return GetterUtil.getString(_redirectTitle);
330 }
331
332 public void setRedirectTitle(String redirectTitle) {
333 if (((redirectTitle == null) && (_redirectTitle != null)) ||
334 ((redirectTitle != null) && (_redirectTitle == null)) ||
335 ((redirectTitle != null) && (_redirectTitle != null) &&
336 !redirectTitle.equals(_redirectTitle))) {
337 _redirectTitle = redirectTitle;
338 }
339 }
340
341 public WikiPage toEscapedModel() {
342 if (isEscapedModel()) {
343 return (WikiPage)this;
344 }
345 else {
346 WikiPage model = new WikiPageImpl();
347
348 model.setEscapedModel(true);
349
350 model.setUuid(HtmlUtil.escape(getUuid()));
351 model.setPageId(getPageId());
352 model.setResourcePrimKey(getResourcePrimKey());
353 model.setCompanyId(getCompanyId());
354 model.setUserId(getUserId());
355 model.setUserName(HtmlUtil.escape(getUserName()));
356 model.setCreateDate(getCreateDate());
357 model.setNodeId(getNodeId());
358 model.setTitle(HtmlUtil.escape(getTitle()));
359 model.setVersion(getVersion());
360 model.setContent(HtmlUtil.escape(getContent()));
361 model.setFormat(HtmlUtil.escape(getFormat()));
362 model.setHead(getHead());
363 model.setParentTitle(HtmlUtil.escape(getParentTitle()));
364 model.setRedirectTitle(HtmlUtil.escape(getRedirectTitle()));
365
366 model = (WikiPage)Proxy.newProxyInstance(WikiPage.class.getClassLoader(),
367 new Class[] { WikiPage.class },
368 new ReadOnlyBeanHandler(model));
369
370 return model;
371 }
372 }
373
374 public Object clone() {
375 WikiPageImpl clone = new WikiPageImpl();
376
377 clone.setUuid(getUuid());
378 clone.setPageId(getPageId());
379 clone.setResourcePrimKey(getResourcePrimKey());
380 clone.setCompanyId(getCompanyId());
381 clone.setUserId(getUserId());
382 clone.setUserName(getUserName());
383 clone.setCreateDate(getCreateDate());
384 clone.setNodeId(getNodeId());
385 clone.setTitle(getTitle());
386 clone.setVersion(getVersion());
387 clone.setContent(getContent());
388 clone.setFormat(getFormat());
389 clone.setHead(getHead());
390 clone.setParentTitle(getParentTitle());
391 clone.setRedirectTitle(getRedirectTitle());
392
393 return clone;
394 }
395
396 public int compareTo(Object obj) {
397 if (obj == null) {
398 return -1;
399 }
400
401 WikiPageImpl wikiPage = (WikiPageImpl)obj;
402
403 int value = 0;
404
405 if (getNodeId() < wikiPage.getNodeId()) {
406 value = -1;
407 }
408 else if (getNodeId() > wikiPage.getNodeId()) {
409 value = 1;
410 }
411 else {
412 value = 0;
413 }
414
415 if (value != 0) {
416 return value;
417 }
418
419 value = getTitle().toLowerCase()
420 .compareTo(wikiPage.getTitle().toLowerCase());
421
422 if (value != 0) {
423 return value;
424 }
425
426 if (getVersion() < wikiPage.getVersion()) {
427 value = -1;
428 }
429 else if (getVersion() > wikiPage.getVersion()) {
430 value = 1;
431 }
432 else {
433 value = 0;
434 }
435
436 if (value != 0) {
437 return value;
438 }
439
440 return 0;
441 }
442
443 public boolean equals(Object obj) {
444 if (obj == null) {
445 return false;
446 }
447
448 WikiPageImpl wikiPage = null;
449
450 try {
451 wikiPage = (WikiPageImpl)obj;
452 }
453 catch (ClassCastException cce) {
454 return false;
455 }
456
457 long pk = wikiPage.getPrimaryKey();
458
459 if (getPrimaryKey() == pk) {
460 return true;
461 }
462 else {
463 return false;
464 }
465 }
466
467 public int hashCode() {
468 return (int)getPrimaryKey();
469 }
470
471 private String _uuid;
472 private long _pageId;
473 private long _resourcePrimKey;
474 private long _companyId;
475 private long _userId;
476 private String _userName;
477 private Date _createDate;
478 private long _nodeId;
479 private String _title;
480 private double _version;
481 private String _content;
482 private String _format;
483 private boolean _head;
484 private String _parentTitle;
485 private String _redirectTitle;
486 }