1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.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  
30  import com.liferay.portlet.wiki.model.WikiPage;
31  import com.liferay.portlet.wiki.model.WikiPageSoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="WikiPageModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>WikiPage</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.wiki.service.model.WikiPage
59   * @see com.liferay.portlet.wiki.service.model.WikiPageModel
60   * @see com.liferay.portlet.wiki.service.model.impl.WikiPageImpl
61   *
62   */
63  public class WikiPageModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "WikiPage";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "uuid_", new Integer(Types.VARCHAR) },
67              
68  
69              { "pageId", new Integer(Types.BIGINT) },
70              
71  
72              { "resourcePrimKey", new Integer(Types.BIGINT) },
73              
74  
75              { "companyId", new Integer(Types.BIGINT) },
76              
77  
78              { "userId", new Integer(Types.BIGINT) },
79              
80  
81              { "userName", new Integer(Types.VARCHAR) },
82              
83  
84              { "createDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "modifiedDate", new Integer(Types.TIMESTAMP) },
88              
89  
90              { "nodeId", new Integer(Types.BIGINT) },
91              
92  
93              { "title", new Integer(Types.VARCHAR) },
94              
95  
96              { "version", new Integer(Types.DOUBLE) },
97              
98  
99              { "content", new Integer(Types.CLOB) },
100             
101 
102             { "summary", new Integer(Types.VARCHAR) },
103             
104 
105             { "format", new Integer(Types.VARCHAR) },
106             
107 
108             { "head", new Integer(Types.BOOLEAN) },
109             
110 
111             { "parentTitle", new Integer(Types.VARCHAR) },
112             
113 
114             { "redirectTitle", new Integer(Types.VARCHAR) }
115         };
116     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,modifiedDate DATE null,nodeId LONG,title VARCHAR(75) null,version DOUBLE,content TEXT null,summary STRING null,format VARCHAR(75) null,head BOOLEAN,parentTitle VARCHAR(75) null,redirectTitle VARCHAR(75) null)";
117     public static final String TABLE_SQL_DROP = "drop table WikiPage";
118     public static final String DATA_SOURCE = "liferayDataSource";
119     public static final String SESSION_FACTORY = "liferaySessionFactory";
120     public static final String TX_MANAGER = "liferayTransactionManager";
121     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
122                 "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPage"),
123             true);
124 
125     public static WikiPage toModel(WikiPageSoap soapModel) {
126         WikiPage model = new WikiPageImpl();
127 
128         model.setUuid(soapModel.getUuid());
129         model.setPageId(soapModel.getPageId());
130         model.setResourcePrimKey(soapModel.getResourcePrimKey());
131         model.setCompanyId(soapModel.getCompanyId());
132         model.setUserId(soapModel.getUserId());
133         model.setUserName(soapModel.getUserName());
134         model.setCreateDate(soapModel.getCreateDate());
135         model.setModifiedDate(soapModel.getModifiedDate());
136         model.setNodeId(soapModel.getNodeId());
137         model.setTitle(soapModel.getTitle());
138         model.setVersion(soapModel.getVersion());
139         model.setContent(soapModel.getContent());
140         model.setSummary(soapModel.getSummary());
141         model.setFormat(soapModel.getFormat());
142         model.setHead(soapModel.getHead());
143         model.setParentTitle(soapModel.getParentTitle());
144         model.setRedirectTitle(soapModel.getRedirectTitle());
145 
146         return model;
147     }
148 
149     public static List<WikiPage> toModels(WikiPageSoap[] soapModels) {
150         List<WikiPage> models = new ArrayList<WikiPage>(soapModels.length);
151 
152         for (WikiPageSoap soapModel : soapModels) {
153             models.add(toModel(soapModel));
154         }
155 
156         return models;
157     }
158 
159     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
160                 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPage"));
161 
162     public WikiPageModelImpl() {
163     }
164 
165     public long getPrimaryKey() {
166         return _pageId;
167     }
168 
169     public void setPrimaryKey(long pk) {
170         setPageId(pk);
171     }
172 
173     public Serializable getPrimaryKeyObj() {
174         return new Long(_pageId);
175     }
176 
177     public String getUuid() {
178         return GetterUtil.getString(_uuid);
179     }
180 
181     public void setUuid(String uuid) {
182         if ((uuid != null) && (uuid != _uuid)) {
183             _uuid = uuid;
184         }
185     }
186 
187     public long getPageId() {
188         return _pageId;
189     }
190 
191     public void setPageId(long pageId) {
192         if (pageId != _pageId) {
193             _pageId = pageId;
194         }
195     }
196 
197     public long getResourcePrimKey() {
198         return _resourcePrimKey;
199     }
200 
201     public void setResourcePrimKey(long resourcePrimKey) {
202         if (resourcePrimKey != _resourcePrimKey) {
203             _resourcePrimKey = resourcePrimKey;
204         }
205     }
206 
207     public long getCompanyId() {
208         return _companyId;
209     }
210 
211     public void setCompanyId(long companyId) {
212         if (companyId != _companyId) {
213             _companyId = companyId;
214         }
215     }
216 
217     public long getUserId() {
218         return _userId;
219     }
220 
221     public void setUserId(long userId) {
222         if (userId != _userId) {
223             _userId = userId;
224         }
225     }
226 
227     public String getUserName() {
228         return GetterUtil.getString(_userName);
229     }
230 
231     public void setUserName(String userName) {
232         if (((userName == null) && (_userName != null)) ||
233                 ((userName != null) && (_userName == null)) ||
234                 ((userName != null) && (_userName != null) &&
235                 !userName.equals(_userName))) {
236             _userName = userName;
237         }
238     }
239 
240     public Date getCreateDate() {
241         return _createDate;
242     }
243 
244     public void setCreateDate(Date createDate) {
245         if (((createDate == null) && (_createDate != null)) ||
246                 ((createDate != null) && (_createDate == null)) ||
247                 ((createDate != null) && (_createDate != null) &&
248                 !createDate.equals(_createDate))) {
249             _createDate = createDate;
250         }
251     }
252 
253     public Date getModifiedDate() {
254         return _modifiedDate;
255     }
256 
257     public void setModifiedDate(Date modifiedDate) {
258         if (((modifiedDate == null) && (_modifiedDate != null)) ||
259                 ((modifiedDate != null) && (_modifiedDate == null)) ||
260                 ((modifiedDate != null) && (_modifiedDate != null) &&
261                 !modifiedDate.equals(_modifiedDate))) {
262             _modifiedDate = modifiedDate;
263         }
264     }
265 
266     public long getNodeId() {
267         return _nodeId;
268     }
269 
270     public void setNodeId(long nodeId) {
271         if (nodeId != _nodeId) {
272             _nodeId = nodeId;
273         }
274     }
275 
276     public String getTitle() {
277         return GetterUtil.getString(_title);
278     }
279 
280     public void setTitle(String title) {
281         if (((title == null) && (_title != null)) ||
282                 ((title != null) && (_title == null)) ||
283                 ((title != null) && (_title != null) && !title.equals(_title))) {
284             _title = title;
285         }
286     }
287 
288     public double getVersion() {
289         return _version;
290     }
291 
292     public void setVersion(double version) {
293         if (version != _version) {
294             _version = version;
295         }
296     }
297 
298     public String getContent() {
299         return GetterUtil.getString(_content);
300     }
301 
302     public void setContent(String content) {
303         if (((content == null) && (_content != null)) ||
304                 ((content != null) && (_content == null)) ||
305                 ((content != null) && (_content != null) &&
306                 !content.equals(_content))) {
307             _content = content;
308         }
309     }
310 
311     public String getSummary() {
312         return GetterUtil.getString(_summary);
313     }
314 
315     public void setSummary(String summary) {
316         if (((summary == null) && (_summary != null)) ||
317                 ((summary != null) && (_summary == null)) ||
318                 ((summary != null) && (_summary != null) &&
319                 !summary.equals(_summary))) {
320             _summary = summary;
321         }
322     }
323 
324     public String getFormat() {
325         return GetterUtil.getString(_format);
326     }
327 
328     public void setFormat(String format) {
329         if (((format == null) && (_format != null)) ||
330                 ((format != null) && (_format == null)) ||
331                 ((format != null) && (_format != null) &&
332                 !format.equals(_format))) {
333             _format = format;
334         }
335     }
336 
337     public boolean getHead() {
338         return _head;
339     }
340 
341     public boolean isHead() {
342         return _head;
343     }
344 
345     public void setHead(boolean head) {
346         if (head != _head) {
347             _head = head;
348         }
349     }
350 
351     public String getParentTitle() {
352         return GetterUtil.getString(_parentTitle);
353     }
354 
355     public void setParentTitle(String parentTitle) {
356         if (((parentTitle == null) && (_parentTitle != null)) ||
357                 ((parentTitle != null) && (_parentTitle == null)) ||
358                 ((parentTitle != null) && (_parentTitle != null) &&
359                 !parentTitle.equals(_parentTitle))) {
360             _parentTitle = parentTitle;
361         }
362     }
363 
364     public String getRedirectTitle() {
365         return GetterUtil.getString(_redirectTitle);
366     }
367 
368     public void setRedirectTitle(String redirectTitle) {
369         if (((redirectTitle == null) && (_redirectTitle != null)) ||
370                 ((redirectTitle != null) && (_redirectTitle == null)) ||
371                 ((redirectTitle != null) && (_redirectTitle != null) &&
372                 !redirectTitle.equals(_redirectTitle))) {
373             _redirectTitle = redirectTitle;
374         }
375     }
376 
377     public WikiPage toEscapedModel() {
378         if (isEscapedModel()) {
379             return (WikiPage)this;
380         }
381         else {
382             WikiPage model = new WikiPageImpl();
383 
384             model.setEscapedModel(true);
385 
386             model.setUuid(HtmlUtil.escape(getUuid()));
387             model.setPageId(getPageId());
388             model.setResourcePrimKey(getResourcePrimKey());
389             model.setCompanyId(getCompanyId());
390             model.setUserId(getUserId());
391             model.setUserName(HtmlUtil.escape(getUserName()));
392             model.setCreateDate(getCreateDate());
393             model.setModifiedDate(getModifiedDate());
394             model.setNodeId(getNodeId());
395             model.setTitle(HtmlUtil.escape(getTitle()));
396             model.setVersion(getVersion());
397             model.setContent(HtmlUtil.escape(getContent()));
398             model.setSummary(HtmlUtil.escape(getSummary()));
399             model.setFormat(HtmlUtil.escape(getFormat()));
400             model.setHead(getHead());
401             model.setParentTitle(HtmlUtil.escape(getParentTitle()));
402             model.setRedirectTitle(HtmlUtil.escape(getRedirectTitle()));
403 
404             model = (WikiPage)Proxy.newProxyInstance(WikiPage.class.getClassLoader(),
405                     new Class[] { WikiPage.class },
406                     new ReadOnlyBeanHandler(model));
407 
408             return model;
409         }
410     }
411 
412     public Object clone() {
413         WikiPageImpl clone = new WikiPageImpl();
414 
415         clone.setUuid(getUuid());
416         clone.setPageId(getPageId());
417         clone.setResourcePrimKey(getResourcePrimKey());
418         clone.setCompanyId(getCompanyId());
419         clone.setUserId(getUserId());
420         clone.setUserName(getUserName());
421         clone.setCreateDate(getCreateDate());
422         clone.setModifiedDate(getModifiedDate());
423         clone.setNodeId(getNodeId());
424         clone.setTitle(getTitle());
425         clone.setVersion(getVersion());
426         clone.setContent(getContent());
427         clone.setSummary(getSummary());
428         clone.setFormat(getFormat());
429         clone.setHead(getHead());
430         clone.setParentTitle(getParentTitle());
431         clone.setRedirectTitle(getRedirectTitle());
432 
433         return clone;
434     }
435 
436     public int compareTo(Object obj) {
437         if (obj == null) {
438             return -1;
439         }
440 
441         WikiPageImpl wikiPage = (WikiPageImpl)obj;
442 
443         int value = 0;
444 
445         if (getNodeId() < wikiPage.getNodeId()) {
446             value = -1;
447         }
448         else if (getNodeId() > wikiPage.getNodeId()) {
449             value = 1;
450         }
451         else {
452             value = 0;
453         }
454 
455         if (value != 0) {
456             return value;
457         }
458 
459         value = getTitle().toLowerCase()
460                     .compareTo(wikiPage.getTitle().toLowerCase());
461 
462         if (value != 0) {
463             return value;
464         }
465 
466         if (getVersion() < wikiPage.getVersion()) {
467             value = -1;
468         }
469         else if (getVersion() > wikiPage.getVersion()) {
470             value = 1;
471         }
472         else {
473             value = 0;
474         }
475 
476         if (value != 0) {
477             return value;
478         }
479 
480         return 0;
481     }
482 
483     public boolean equals(Object obj) {
484         if (obj == null) {
485             return false;
486         }
487 
488         WikiPageImpl wikiPage = null;
489 
490         try {
491             wikiPage = (WikiPageImpl)obj;
492         }
493         catch (ClassCastException cce) {
494             return false;
495         }
496 
497         long pk = wikiPage.getPrimaryKey();
498 
499         if (getPrimaryKey() == pk) {
500             return true;
501         }
502         else {
503             return false;
504         }
505     }
506 
507     public int hashCode() {
508         return (int)getPrimaryKey();
509     }
510 
511     private String _uuid;
512     private long _pageId;
513     private long _resourcePrimKey;
514     private long _companyId;
515     private long _userId;
516     private String _userName;
517     private Date _createDate;
518     private Date _modifiedDate;
519     private long _nodeId;
520     private String _title;
521     private double _version;
522     private String _content;
523     private String _summary;
524     private String _format;
525     private boolean _head;
526     private String _parentTitle;
527     private String _redirectTitle;
528 }