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