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.model.WikiPage
59   * @see com.liferay.portlet.wiki.model.WikiPageModel
60   * @see com.liferay.portlet.wiki.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              { "minorEdit", new Integer(Types.BOOLEAN) },
100             
101 
102             { "content", new Integer(Types.CLOB) },
103             
104 
105             { "summary", new Integer(Types.VARCHAR) },
106             
107 
108             { "format", new Integer(Types.VARCHAR) },
109             
110 
111             { "head", new Integer(Types.BOOLEAN) },
112             
113 
114             { "parentTitle", new Integer(Types.VARCHAR) },
115             
116 
117             { "redirectTitle", new Integer(Types.VARCHAR) }
118         };
119     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,minorEdit BOOLEAN,content TEXT null,summary STRING null,format VARCHAR(75) null,head BOOLEAN,parentTitle VARCHAR(75) null,redirectTitle VARCHAR(75) null)";
120     public static final String TABLE_SQL_DROP = "drop table WikiPage";
121     public static final String DATA_SOURCE = "liferayDataSource";
122     public static final String SESSION_FACTORY = "liferaySessionFactory";
123     public static final String TX_MANAGER = "liferayTransactionManager";
124     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
125                 "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPage"),
126             true);
127 
128     public static WikiPage toModel(WikiPageSoap soapModel) {
129         WikiPage model = new WikiPageImpl();
130 
131         model.setUuid(soapModel.getUuid());
132         model.setPageId(soapModel.getPageId());
133         model.setResourcePrimKey(soapModel.getResourcePrimKey());
134         model.setCompanyId(soapModel.getCompanyId());
135         model.setUserId(soapModel.getUserId());
136         model.setUserName(soapModel.getUserName());
137         model.setCreateDate(soapModel.getCreateDate());
138         model.setModifiedDate(soapModel.getModifiedDate());
139         model.setNodeId(soapModel.getNodeId());
140         model.setTitle(soapModel.getTitle());
141         model.setVersion(soapModel.getVersion());
142         model.setMinorEdit(soapModel.getMinorEdit());
143         model.setContent(soapModel.getContent());
144         model.setSummary(soapModel.getSummary());
145         model.setFormat(soapModel.getFormat());
146         model.setHead(soapModel.getHead());
147         model.setParentTitle(soapModel.getParentTitle());
148         model.setRedirectTitle(soapModel.getRedirectTitle());
149 
150         return model;
151     }
152 
153     public static List<WikiPage> toModels(WikiPageSoap[] soapModels) {
154         List<WikiPage> models = new ArrayList<WikiPage>(soapModels.length);
155 
156         for (WikiPageSoap soapModel : soapModels) {
157             models.add(toModel(soapModel));
158         }
159 
160         return models;
161     }
162 
163     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
164                 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPage"));
165 
166     public WikiPageModelImpl() {
167     }
168 
169     public long getPrimaryKey() {
170         return _pageId;
171     }
172 
173     public void setPrimaryKey(long pk) {
174         setPageId(pk);
175     }
176 
177     public Serializable getPrimaryKeyObj() {
178         return new Long(_pageId);
179     }
180 
181     public String getUuid() {
182         return GetterUtil.getString(_uuid);
183     }
184 
185     public void setUuid(String uuid) {
186         if ((uuid != null) && (uuid != _uuid)) {
187             _uuid = uuid;
188         }
189     }
190 
191     public long getPageId() {
192         return _pageId;
193     }
194 
195     public void setPageId(long pageId) {
196         if (pageId != _pageId) {
197             _pageId = pageId;
198         }
199     }
200 
201     public long getResourcePrimKey() {
202         return _resourcePrimKey;
203     }
204 
205     public void setResourcePrimKey(long resourcePrimKey) {
206         if (resourcePrimKey != _resourcePrimKey) {
207             _resourcePrimKey = resourcePrimKey;
208         }
209     }
210 
211     public long getCompanyId() {
212         return _companyId;
213     }
214 
215     public void setCompanyId(long companyId) {
216         if (companyId != _companyId) {
217             _companyId = companyId;
218         }
219     }
220 
221     public long getUserId() {
222         return _userId;
223     }
224 
225     public void setUserId(long userId) {
226         if (userId != _userId) {
227             _userId = userId;
228         }
229     }
230 
231     public String getUserName() {
232         return GetterUtil.getString(_userName);
233     }
234 
235     public void setUserName(String userName) {
236         if (((userName == null) && (_userName != null)) ||
237                 ((userName != null) && (_userName == null)) ||
238                 ((userName != null) && (_userName != null) &&
239                 !userName.equals(_userName))) {
240             _userName = userName;
241         }
242     }
243 
244     public Date getCreateDate() {
245         return _createDate;
246     }
247 
248     public void setCreateDate(Date createDate) {
249         if (((createDate == null) && (_createDate != null)) ||
250                 ((createDate != null) && (_createDate == null)) ||
251                 ((createDate != null) && (_createDate != null) &&
252                 !createDate.equals(_createDate))) {
253             _createDate = createDate;
254         }
255     }
256 
257     public Date getModifiedDate() {
258         return _modifiedDate;
259     }
260 
261     public void setModifiedDate(Date modifiedDate) {
262         if (((modifiedDate == null) && (_modifiedDate != null)) ||
263                 ((modifiedDate != null) && (_modifiedDate == null)) ||
264                 ((modifiedDate != null) && (_modifiedDate != null) &&
265                 !modifiedDate.equals(_modifiedDate))) {
266             _modifiedDate = modifiedDate;
267         }
268     }
269 
270     public long getNodeId() {
271         return _nodeId;
272     }
273 
274     public void setNodeId(long nodeId) {
275         if (nodeId != _nodeId) {
276             _nodeId = nodeId;
277         }
278     }
279 
280     public String getTitle() {
281         return GetterUtil.getString(_title);
282     }
283 
284     public void setTitle(String title) {
285         if (((title == null) && (_title != null)) ||
286                 ((title != null) && (_title == null)) ||
287                 ((title != null) && (_title != null) && !title.equals(_title))) {
288             _title = title;
289         }
290     }
291 
292     public double getVersion() {
293         return _version;
294     }
295 
296     public void setVersion(double version) {
297         if (version != _version) {
298             _version = version;
299         }
300     }
301 
302     public boolean getMinorEdit() {
303         return _minorEdit;
304     }
305 
306     public boolean isMinorEdit() {
307         return _minorEdit;
308     }
309 
310     public void setMinorEdit(boolean minorEdit) {
311         if (minorEdit != _minorEdit) {
312             _minorEdit = minorEdit;
313         }
314     }
315 
316     public String getContent() {
317         return GetterUtil.getString(_content);
318     }
319 
320     public void setContent(String content) {
321         if (((content == null) && (_content != null)) ||
322                 ((content != null) && (_content == null)) ||
323                 ((content != null) && (_content != null) &&
324                 !content.equals(_content))) {
325             _content = content;
326         }
327     }
328 
329     public String getSummary() {
330         return GetterUtil.getString(_summary);
331     }
332 
333     public void setSummary(String summary) {
334         if (((summary == null) && (_summary != null)) ||
335                 ((summary != null) && (_summary == null)) ||
336                 ((summary != null) && (_summary != null) &&
337                 !summary.equals(_summary))) {
338             _summary = summary;
339         }
340     }
341 
342     public String getFormat() {
343         return GetterUtil.getString(_format);
344     }
345 
346     public void setFormat(String format) {
347         if (((format == null) && (_format != null)) ||
348                 ((format != null) && (_format == null)) ||
349                 ((format != null) && (_format != null) &&
350                 !format.equals(_format))) {
351             _format = format;
352         }
353     }
354 
355     public boolean getHead() {
356         return _head;
357     }
358 
359     public boolean isHead() {
360         return _head;
361     }
362 
363     public void setHead(boolean head) {
364         if (head != _head) {
365             _head = head;
366         }
367     }
368 
369     public String getParentTitle() {
370         return GetterUtil.getString(_parentTitle);
371     }
372 
373     public void setParentTitle(String parentTitle) {
374         if (((parentTitle == null) && (_parentTitle != null)) ||
375                 ((parentTitle != null) && (_parentTitle == null)) ||
376                 ((parentTitle != null) && (_parentTitle != null) &&
377                 !parentTitle.equals(_parentTitle))) {
378             _parentTitle = parentTitle;
379         }
380     }
381 
382     public String getRedirectTitle() {
383         return GetterUtil.getString(_redirectTitle);
384     }
385 
386     public void setRedirectTitle(String redirectTitle) {
387         if (((redirectTitle == null) && (_redirectTitle != null)) ||
388                 ((redirectTitle != null) && (_redirectTitle == null)) ||
389                 ((redirectTitle != null) && (_redirectTitle != null) &&
390                 !redirectTitle.equals(_redirectTitle))) {
391             _redirectTitle = redirectTitle;
392         }
393     }
394 
395     public WikiPage toEscapedModel() {
396         if (isEscapedModel()) {
397             return (WikiPage)this;
398         }
399         else {
400             WikiPage model = new WikiPageImpl();
401 
402             model.setNew(isNew());
403             model.setEscapedModel(true);
404 
405             model.setUuid(HtmlUtil.escape(getUuid()));
406             model.setPageId(getPageId());
407             model.setResourcePrimKey(getResourcePrimKey());
408             model.setCompanyId(getCompanyId());
409             model.setUserId(getUserId());
410             model.setUserName(HtmlUtil.escape(getUserName()));
411             model.setCreateDate(getCreateDate());
412             model.setModifiedDate(getModifiedDate());
413             model.setNodeId(getNodeId());
414             model.setTitle(HtmlUtil.escape(getTitle()));
415             model.setVersion(getVersion());
416             model.setMinorEdit(getMinorEdit());
417             model.setContent(HtmlUtil.escape(getContent()));
418             model.setSummary(HtmlUtil.escape(getSummary()));
419             model.setFormat(HtmlUtil.escape(getFormat()));
420             model.setHead(getHead());
421             model.setParentTitle(HtmlUtil.escape(getParentTitle()));
422             model.setRedirectTitle(HtmlUtil.escape(getRedirectTitle()));
423 
424             model = (WikiPage)Proxy.newProxyInstance(WikiPage.class.getClassLoader(),
425                     new Class[] { WikiPage.class },
426                     new ReadOnlyBeanHandler(model));
427 
428             return model;
429         }
430     }
431 
432     public Object clone() {
433         WikiPageImpl clone = new WikiPageImpl();
434 
435         clone.setUuid(getUuid());
436         clone.setPageId(getPageId());
437         clone.setResourcePrimKey(getResourcePrimKey());
438         clone.setCompanyId(getCompanyId());
439         clone.setUserId(getUserId());
440         clone.setUserName(getUserName());
441         clone.setCreateDate(getCreateDate());
442         clone.setModifiedDate(getModifiedDate());
443         clone.setNodeId(getNodeId());
444         clone.setTitle(getTitle());
445         clone.setVersion(getVersion());
446         clone.setMinorEdit(getMinorEdit());
447         clone.setContent(getContent());
448         clone.setSummary(getSummary());
449         clone.setFormat(getFormat());
450         clone.setHead(getHead());
451         clone.setParentTitle(getParentTitle());
452         clone.setRedirectTitle(getRedirectTitle());
453 
454         return clone;
455     }
456 
457     public int compareTo(Object obj) {
458         if (obj == null) {
459             return -1;
460         }
461 
462         WikiPageImpl wikiPage = (WikiPageImpl)obj;
463 
464         int value = 0;
465 
466         if (getNodeId() < wikiPage.getNodeId()) {
467             value = -1;
468         }
469         else if (getNodeId() > wikiPage.getNodeId()) {
470             value = 1;
471         }
472         else {
473             value = 0;
474         }
475 
476         if (value != 0) {
477             return value;
478         }
479 
480         value = getTitle().toLowerCase()
481                     .compareTo(wikiPage.getTitle().toLowerCase());
482 
483         if (value != 0) {
484             return value;
485         }
486 
487         if (getVersion() < wikiPage.getVersion()) {
488             value = -1;
489         }
490         else if (getVersion() > wikiPage.getVersion()) {
491             value = 1;
492         }
493         else {
494             value = 0;
495         }
496 
497         if (value != 0) {
498             return value;
499         }
500 
501         return 0;
502     }
503 
504     public boolean equals(Object obj) {
505         if (obj == null) {
506             return false;
507         }
508 
509         WikiPageImpl wikiPage = null;
510 
511         try {
512             wikiPage = (WikiPageImpl)obj;
513         }
514         catch (ClassCastException cce) {
515             return false;
516         }
517 
518         long pk = wikiPage.getPrimaryKey();
519 
520         if (getPrimaryKey() == pk) {
521             return true;
522         }
523         else {
524             return false;
525         }
526     }
527 
528     public int hashCode() {
529         return (int)getPrimaryKey();
530     }
531 
532     private String _uuid;
533     private long _pageId;
534     private long _resourcePrimKey;
535     private long _companyId;
536     private long _userId;
537     private String _userName;
538     private Date _createDate;
539     private Date _modifiedDate;
540     private long _nodeId;
541     private String _title;
542     private double _version;
543     private boolean _minorEdit;
544     private String _content;
545     private String _summary;
546     private String _format;
547     private boolean _head;
548     private String _parentTitle;
549     private String _redirectTitle;
550 }