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.journal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.journal.model.JournalArticle;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.Date;
41  
42  /**
43   * <a href="JournalArticleModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>JournalArticle</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.journal.service.model.JournalArticle
58   * @see com.liferay.portlet.journal.service.model.JournalArticleModel
59   * @see com.liferay.portlet.journal.service.model.impl.JournalArticleImpl
60   *
61   */
62  public class JournalArticleModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "JournalArticle";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              
67  
68              { "id_", new Integer(Types.BIGINT) },
69              
70  
71              { "resourcePrimKey", new Integer(Types.BIGINT) },
72              
73  
74              { "groupId", new Integer(Types.BIGINT) },
75              
76  
77              { "companyId", new Integer(Types.BIGINT) },
78              
79  
80              { "userId", new Integer(Types.BIGINT) },
81              
82  
83              { "userName", new Integer(Types.VARCHAR) },
84              
85  
86              { "createDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "modifiedDate", new Integer(Types.TIMESTAMP) },
90              
91  
92              { "articleId", new Integer(Types.VARCHAR) },
93              
94  
95              { "version", new Integer(Types.DOUBLE) },
96              
97  
98              { "title", new Integer(Types.VARCHAR) },
99              
100 
101             { "description", new Integer(Types.VARCHAR) },
102             
103 
104             { "content", new Integer(Types.CLOB) },
105             
106 
107             { "type_", new Integer(Types.VARCHAR) },
108             
109 
110             { "structureId", new Integer(Types.VARCHAR) },
111             
112 
113             { "templateId", new Integer(Types.VARCHAR) },
114             
115 
116             { "displayDate", new Integer(Types.TIMESTAMP) },
117             
118 
119             { "approved", new Integer(Types.BOOLEAN) },
120             
121 
122             { "approvedByUserId", new Integer(Types.BIGINT) },
123             
124 
125             { "approvedByUserName", new Integer(Types.VARCHAR) },
126             
127 
128             { "approvedDate", new Integer(Types.TIMESTAMP) },
129             
130 
131             { "expired", new Integer(Types.BOOLEAN) },
132             
133 
134             { "expirationDate", new Integer(Types.TIMESTAMP) },
135             
136 
137             { "reviewDate", new Integer(Types.TIMESTAMP) },
138             
139 
140             { "indexable", new Integer(Types.BOOLEAN) },
141             
142 
143             { "smallImage", new Integer(Types.BOOLEAN) },
144             
145 
146             { "smallImageId", new Integer(Types.BIGINT) },
147             
148 
149             { "smallImageURL", new Integer(Types.VARCHAR) }
150         };
151     public static final String TABLE_SQL_CREATE = "create table JournalArticle (uuid_ VARCHAR(75) null,id_ LONG not null primary key,resourcePrimKey LONG,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,articleId VARCHAR(75) null,version DOUBLE,title VARCHAR(100) null,description STRING null,content TEXT null,type_ VARCHAR(75) null,structureId VARCHAR(75) null,templateId VARCHAR(75) null,displayDate DATE null,approved BOOLEAN,approvedByUserId LONG,approvedByUserName VARCHAR(75) null,approvedDate DATE null,expired BOOLEAN,expirationDate DATE null,reviewDate DATE null,indexable BOOLEAN,smallImage BOOLEAN,smallImageId LONG,smallImageURL VARCHAR(75) null)";
152     public static final String TABLE_SQL_DROP = "drop table JournalArticle";
153     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
154                 "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticle"),
155             true);
156     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
157                 "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticle"));
158 
159     public JournalArticleModelImpl() {
160     }
161 
162     public long getPrimaryKey() {
163         return _id;
164     }
165 
166     public void setPrimaryKey(long pk) {
167         setId(pk);
168     }
169 
170     public Serializable getPrimaryKeyObj() {
171         return new Long(_id);
172     }
173 
174     public String getUuid() {
175         return GetterUtil.getString(_uuid);
176     }
177 
178     public void setUuid(String uuid) {
179         if ((uuid != null) && (uuid != _uuid)) {
180             _uuid = uuid;
181         }
182     }
183 
184     public long getId() {
185         return _id;
186     }
187 
188     public void setId(long id) {
189         if (id != _id) {
190             _id = id;
191         }
192     }
193 
194     public long getResourcePrimKey() {
195         return _resourcePrimKey;
196     }
197 
198     public void setResourcePrimKey(long resourcePrimKey) {
199         if (resourcePrimKey != _resourcePrimKey) {
200             _resourcePrimKey = resourcePrimKey;
201         }
202     }
203 
204     public long getGroupId() {
205         return _groupId;
206     }
207 
208     public void setGroupId(long groupId) {
209         if (groupId != _groupId) {
210             _groupId = groupId;
211         }
212     }
213 
214     public long getCompanyId() {
215         return _companyId;
216     }
217 
218     public void setCompanyId(long companyId) {
219         if (companyId != _companyId) {
220             _companyId = companyId;
221         }
222     }
223 
224     public long getUserId() {
225         return _userId;
226     }
227 
228     public void setUserId(long userId) {
229         if (userId != _userId) {
230             _userId = userId;
231         }
232     }
233 
234     public String getUserName() {
235         return GetterUtil.getString(_userName);
236     }
237 
238     public void setUserName(String userName) {
239         if (((userName == null) && (_userName != null)) ||
240                 ((userName != null) && (_userName == null)) ||
241                 ((userName != null) && (_userName != null) &&
242                 !userName.equals(_userName))) {
243             _userName = userName;
244         }
245     }
246 
247     public Date getCreateDate() {
248         return _createDate;
249     }
250 
251     public void setCreateDate(Date createDate) {
252         if (((createDate == null) && (_createDate != null)) ||
253                 ((createDate != null) && (_createDate == null)) ||
254                 ((createDate != null) && (_createDate != null) &&
255                 !createDate.equals(_createDate))) {
256             _createDate = createDate;
257         }
258     }
259 
260     public Date getModifiedDate() {
261         return _modifiedDate;
262     }
263 
264     public void setModifiedDate(Date modifiedDate) {
265         if (((modifiedDate == null) && (_modifiedDate != null)) ||
266                 ((modifiedDate != null) && (_modifiedDate == null)) ||
267                 ((modifiedDate != null) && (_modifiedDate != null) &&
268                 !modifiedDate.equals(_modifiedDate))) {
269             _modifiedDate = modifiedDate;
270         }
271     }
272 
273     public String getArticleId() {
274         return GetterUtil.getString(_articleId);
275     }
276 
277     public void setArticleId(String articleId) {
278         if (((articleId == null) && (_articleId != null)) ||
279                 ((articleId != null) && (_articleId == null)) ||
280                 ((articleId != null) && (_articleId != null) &&
281                 !articleId.equals(_articleId))) {
282             _articleId = articleId;
283         }
284     }
285 
286     public double getVersion() {
287         return _version;
288     }
289 
290     public void setVersion(double version) {
291         if (version != _version) {
292             _version = version;
293         }
294     }
295 
296     public String getTitle() {
297         return GetterUtil.getString(_title);
298     }
299 
300     public void setTitle(String title) {
301         if (((title == null) && (_title != null)) ||
302                 ((title != null) && (_title == null)) ||
303                 ((title != null) && (_title != null) && !title.equals(_title))) {
304             _title = title;
305         }
306     }
307 
308     public String getDescription() {
309         return GetterUtil.getString(_description);
310     }
311 
312     public void setDescription(String description) {
313         if (((description == null) && (_description != null)) ||
314                 ((description != null) && (_description == null)) ||
315                 ((description != null) && (_description != null) &&
316                 !description.equals(_description))) {
317             _description = description;
318         }
319     }
320 
321     public String getContent() {
322         return GetterUtil.getString(_content);
323     }
324 
325     public void setContent(String content) {
326         if (((content == null) && (_content != null)) ||
327                 ((content != null) && (_content == null)) ||
328                 ((content != null) && (_content != null) &&
329                 !content.equals(_content))) {
330             _content = content;
331         }
332     }
333 
334     public String getType() {
335         return GetterUtil.getString(_type);
336     }
337 
338     public void setType(String type) {
339         if (((type == null) && (_type != null)) ||
340                 ((type != null) && (_type == null)) ||
341                 ((type != null) && (_type != null) && !type.equals(_type))) {
342             _type = type;
343         }
344     }
345 
346     public String getStructureId() {
347         return GetterUtil.getString(_structureId);
348     }
349 
350     public void setStructureId(String structureId) {
351         if (((structureId == null) && (_structureId != null)) ||
352                 ((structureId != null) && (_structureId == null)) ||
353                 ((structureId != null) && (_structureId != null) &&
354                 !structureId.equals(_structureId))) {
355             _structureId = structureId;
356         }
357     }
358 
359     public String getTemplateId() {
360         return GetterUtil.getString(_templateId);
361     }
362 
363     public void setTemplateId(String templateId) {
364         if (((templateId == null) && (_templateId != null)) ||
365                 ((templateId != null) && (_templateId == null)) ||
366                 ((templateId != null) && (_templateId != null) &&
367                 !templateId.equals(_templateId))) {
368             _templateId = templateId;
369         }
370     }
371 
372     public Date getDisplayDate() {
373         return _displayDate;
374     }
375 
376     public void setDisplayDate(Date displayDate) {
377         if (((displayDate == null) && (_displayDate != null)) ||
378                 ((displayDate != null) && (_displayDate == null)) ||
379                 ((displayDate != null) && (_displayDate != null) &&
380                 !displayDate.equals(_displayDate))) {
381             _displayDate = displayDate;
382         }
383     }
384 
385     public boolean getApproved() {
386         return _approved;
387     }
388 
389     public boolean isApproved() {
390         return _approved;
391     }
392 
393     public void setApproved(boolean approved) {
394         if (approved != _approved) {
395             _approved = approved;
396         }
397     }
398 
399     public long getApprovedByUserId() {
400         return _approvedByUserId;
401     }
402 
403     public void setApprovedByUserId(long approvedByUserId) {
404         if (approvedByUserId != _approvedByUserId) {
405             _approvedByUserId = approvedByUserId;
406         }
407     }
408 
409     public String getApprovedByUserName() {
410         return GetterUtil.getString(_approvedByUserName);
411     }
412 
413     public void setApprovedByUserName(String approvedByUserName) {
414         if (((approvedByUserName == null) && (_approvedByUserName != null)) ||
415                 ((approvedByUserName != null) && (_approvedByUserName == null)) ||
416                 ((approvedByUserName != null) && (_approvedByUserName != null) &&
417                 !approvedByUserName.equals(_approvedByUserName))) {
418             _approvedByUserName = approvedByUserName;
419         }
420     }
421 
422     public Date getApprovedDate() {
423         return _approvedDate;
424     }
425 
426     public void setApprovedDate(Date approvedDate) {
427         if (((approvedDate == null) && (_approvedDate != null)) ||
428                 ((approvedDate != null) && (_approvedDate == null)) ||
429                 ((approvedDate != null) && (_approvedDate != null) &&
430                 !approvedDate.equals(_approvedDate))) {
431             _approvedDate = approvedDate;
432         }
433     }
434 
435     public boolean getExpired() {
436         return _expired;
437     }
438 
439     public boolean isExpired() {
440         return _expired;
441     }
442 
443     public void setExpired(boolean expired) {
444         if (expired != _expired) {
445             _expired = expired;
446         }
447     }
448 
449     public Date getExpirationDate() {
450         return _expirationDate;
451     }
452 
453     public void setExpirationDate(Date expirationDate) {
454         if (((expirationDate == null) && (_expirationDate != null)) ||
455                 ((expirationDate != null) && (_expirationDate == null)) ||
456                 ((expirationDate != null) && (_expirationDate != null) &&
457                 !expirationDate.equals(_expirationDate))) {
458             _expirationDate = expirationDate;
459         }
460     }
461 
462     public Date getReviewDate() {
463         return _reviewDate;
464     }
465 
466     public void setReviewDate(Date reviewDate) {
467         if (((reviewDate == null) && (_reviewDate != null)) ||
468                 ((reviewDate != null) && (_reviewDate == null)) ||
469                 ((reviewDate != null) && (_reviewDate != null) &&
470                 !reviewDate.equals(_reviewDate))) {
471             _reviewDate = reviewDate;
472         }
473     }
474 
475     public boolean getIndexable() {
476         return _indexable;
477     }
478 
479     public boolean isIndexable() {
480         return _indexable;
481     }
482 
483     public void setIndexable(boolean indexable) {
484         if (indexable != _indexable) {
485             _indexable = indexable;
486         }
487     }
488 
489     public boolean getSmallImage() {
490         return _smallImage;
491     }
492 
493     public boolean isSmallImage() {
494         return _smallImage;
495     }
496 
497     public void setSmallImage(boolean smallImage) {
498         if (smallImage != _smallImage) {
499             _smallImage = smallImage;
500         }
501     }
502 
503     public long getSmallImageId() {
504         return _smallImageId;
505     }
506 
507     public void setSmallImageId(long smallImageId) {
508         if (smallImageId != _smallImageId) {
509             _smallImageId = smallImageId;
510         }
511     }
512 
513     public String getSmallImageURL() {
514         return GetterUtil.getString(_smallImageURL);
515     }
516 
517     public void setSmallImageURL(String smallImageURL) {
518         if (((smallImageURL == null) && (_smallImageURL != null)) ||
519                 ((smallImageURL != null) && (_smallImageURL == null)) ||
520                 ((smallImageURL != null) && (_smallImageURL != null) &&
521                 !smallImageURL.equals(_smallImageURL))) {
522             _smallImageURL = smallImageURL;
523         }
524     }
525 
526     public JournalArticle toEscapedModel() {
527         if (isEscapedModel()) {
528             return (JournalArticle)this;
529         }
530         else {
531             JournalArticle model = new JournalArticleImpl();
532 
533             model.setEscapedModel(true);
534 
535             model.setUuid(Html.escape(getUuid()));
536             model.setId(getId());
537             model.setResourcePrimKey(getResourcePrimKey());
538             model.setGroupId(getGroupId());
539             model.setCompanyId(getCompanyId());
540             model.setUserId(getUserId());
541             model.setUserName(Html.escape(getUserName()));
542             model.setCreateDate(getCreateDate());
543             model.setModifiedDate(getModifiedDate());
544             model.setArticleId(getArticleId());
545             model.setVersion(getVersion());
546             model.setTitle(Html.escape(getTitle()));
547             model.setDescription(Html.escape(getDescription()));
548             model.setContent(Html.escape(getContent()));
549             model.setType(Html.escape(getType()));
550             model.setStructureId(getStructureId());
551             model.setTemplateId(getTemplateId());
552             model.setDisplayDate(getDisplayDate());
553             model.setApproved(getApproved());
554             model.setApprovedByUserId(getApprovedByUserId());
555             model.setApprovedByUserName(Html.escape(getApprovedByUserName()));
556             model.setApprovedDate(getApprovedDate());
557             model.setExpired(getExpired());
558             model.setExpirationDate(getExpirationDate());
559             model.setReviewDate(getReviewDate());
560             model.setIndexable(getIndexable());
561             model.setSmallImage(getSmallImage());
562             model.setSmallImageId(getSmallImageId());
563             model.setSmallImageURL(Html.escape(getSmallImageURL()));
564 
565             model = (JournalArticle)Proxy.newProxyInstance(JournalArticle.class.getClassLoader(),
566                     new Class[] { JournalArticle.class },
567                     new ReadOnlyBeanHandler(model));
568 
569             return model;
570         }
571     }
572 
573     public Object clone() {
574         JournalArticleImpl clone = new JournalArticleImpl();
575 
576         clone.setUuid(getUuid());
577         clone.setId(getId());
578         clone.setResourcePrimKey(getResourcePrimKey());
579         clone.setGroupId(getGroupId());
580         clone.setCompanyId(getCompanyId());
581         clone.setUserId(getUserId());
582         clone.setUserName(getUserName());
583         clone.setCreateDate(getCreateDate());
584         clone.setModifiedDate(getModifiedDate());
585         clone.setArticleId(getArticleId());
586         clone.setVersion(getVersion());
587         clone.setTitle(getTitle());
588         clone.setDescription(getDescription());
589         clone.setContent(getContent());
590         clone.setType(getType());
591         clone.setStructureId(getStructureId());
592         clone.setTemplateId(getTemplateId());
593         clone.setDisplayDate(getDisplayDate());
594         clone.setApproved(getApproved());
595         clone.setApprovedByUserId(getApprovedByUserId());
596         clone.setApprovedByUserName(getApprovedByUserName());
597         clone.setApprovedDate(getApprovedDate());
598         clone.setExpired(getExpired());
599         clone.setExpirationDate(getExpirationDate());
600         clone.setReviewDate(getReviewDate());
601         clone.setIndexable(getIndexable());
602         clone.setSmallImage(getSmallImage());
603         clone.setSmallImageId(getSmallImageId());
604         clone.setSmallImageURL(getSmallImageURL());
605 
606         return clone;
607     }
608 
609     public int compareTo(Object obj) {
610         if (obj == null) {
611             return -1;
612         }
613 
614         JournalArticleImpl journalArticle = (JournalArticleImpl)obj;
615 
616         int value = 0;
617 
618         value = getArticleId().compareTo(journalArticle.getArticleId());
619 
620         if (value != 0) {
621             return value;
622         }
623 
624         if (getVersion() < journalArticle.getVersion()) {
625             value = -1;
626         }
627         else if (getVersion() > journalArticle.getVersion()) {
628             value = 1;
629         }
630         else {
631             value = 0;
632         }
633 
634         value = value * -1;
635 
636         if (value != 0) {
637             return value;
638         }
639 
640         return 0;
641     }
642 
643     public boolean equals(Object obj) {
644         if (obj == null) {
645             return false;
646         }
647 
648         JournalArticleImpl journalArticle = null;
649 
650         try {
651             journalArticle = (JournalArticleImpl)obj;
652         }
653         catch (ClassCastException cce) {
654             return false;
655         }
656 
657         long pk = journalArticle.getPrimaryKey();
658 
659         if (getPrimaryKey() == pk) {
660             return true;
661         }
662         else {
663             return false;
664         }
665     }
666 
667     public int hashCode() {
668         return (int)getPrimaryKey();
669     }
670 
671     private String _uuid;
672     private long _id;
673     private long _resourcePrimKey;
674     private long _groupId;
675     private long _companyId;
676     private long _userId;
677     private String _userName;
678     private Date _createDate;
679     private Date _modifiedDate;
680     private String _articleId;
681     private double _version;
682     private String _title;
683     private String _description;
684     private String _content;
685     private String _type;
686     private String _structureId;
687     private String _templateId;
688     private Date _displayDate;
689     private boolean _approved;
690     private long _approvedByUserId;
691     private String _approvedByUserName;
692     private Date _approvedDate;
693     private boolean _expired;
694     private Date _expirationDate;
695     private Date _reviewDate;
696     private boolean _indexable;
697     private boolean _smallImage;
698     private long _smallImageId;
699     private String _smallImageURL;
700 }