1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.blogs.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.kernel.util.StringPool;
23  import com.liferay.portal.kernel.workflow.WorkflowConstants;
24  import com.liferay.portal.model.impl.BaseModelImpl;
25  import com.liferay.portal.service.ServiceContext;
26  import com.liferay.portal.util.PortalUtil;
27  
28  import com.liferay.portlet.blogs.model.BlogsEntry;
29  import com.liferay.portlet.blogs.model.BlogsEntrySoap;
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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="BlogsEntryModelImpl.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 interface is a model that represents the BlogsEntry table in the
53   * database.
54   * </p>
55   *
56   * @author    Brian Wing Shun Chan
57   * @see       BlogsEntryImpl
58   * @see       com.liferay.portlet.blogs.model.BlogsEntry
59   * @see       com.liferay.portlet.blogs.model.BlogsEntryModel
60   * @generated
61   */
62  public class BlogsEntryModelImpl extends BaseModelImpl<BlogsEntry> {
63      public static final String TABLE_NAME = "BlogsEntry";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              { "entryId", new Integer(Types.BIGINT) },
67              { "groupId", new Integer(Types.BIGINT) },
68              { "companyId", new Integer(Types.BIGINT) },
69              { "userId", new Integer(Types.BIGINT) },
70              { "userName", new Integer(Types.VARCHAR) },
71              { "createDate", new Integer(Types.TIMESTAMP) },
72              { "modifiedDate", new Integer(Types.TIMESTAMP) },
73              { "title", new Integer(Types.VARCHAR) },
74              { "urlTitle", new Integer(Types.VARCHAR) },
75              { "content", new Integer(Types.CLOB) },
76              { "displayDate", new Integer(Types.TIMESTAMP) },
77              { "allowPingbacks", new Integer(Types.BOOLEAN) },
78              { "allowTrackbacks", new Integer(Types.BOOLEAN) },
79              { "trackbacks", new Integer(Types.CLOB) },
80              { "status", new Integer(Types.INTEGER) },
81              { "statusByUserId", new Integer(Types.BIGINT) },
82              { "statusByUserName", new Integer(Types.VARCHAR) },
83              { "statusDate", new Integer(Types.TIMESTAMP) }
84          };
85      public static final String TABLE_SQL_CREATE = "create table BlogsEntry (uuid_ VARCHAR(75) null,entryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,title VARCHAR(150) null,urlTitle VARCHAR(150) null,content TEXT null,displayDate DATE null,allowPingbacks BOOLEAN,allowTrackbacks BOOLEAN,trackbacks TEXT null,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
86      public static final String TABLE_SQL_DROP = "drop table BlogsEntry";
87      public static final String ORDER_BY_JPQL = " ORDER BY blogsEntry.displayDate DESC";
88      public static final String ORDER_BY_SQL = " ORDER BY BlogsEntry.displayDate DESC";
89      public static final String DATA_SOURCE = "liferayDataSource";
90      public static final String SESSION_FACTORY = "liferaySessionFactory";
91      public static final String TX_MANAGER = "liferayTransactionManager";
92      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.entity.cache.enabled.com.liferay.portlet.blogs.model.BlogsEntry"),
94              true);
95      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.blogs.model.BlogsEntry"),
97              true);
98  
99      public static BlogsEntry toModel(BlogsEntrySoap soapModel) {
100         BlogsEntry model = new BlogsEntryImpl();
101 
102         model.setUuid(soapModel.getUuid());
103         model.setEntryId(soapModel.getEntryId());
104         model.setGroupId(soapModel.getGroupId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setUserId(soapModel.getUserId());
107         model.setUserName(soapModel.getUserName());
108         model.setCreateDate(soapModel.getCreateDate());
109         model.setModifiedDate(soapModel.getModifiedDate());
110         model.setTitle(soapModel.getTitle());
111         model.setUrlTitle(soapModel.getUrlTitle());
112         model.setContent(soapModel.getContent());
113         model.setDisplayDate(soapModel.getDisplayDate());
114         model.setAllowPingbacks(soapModel.getAllowPingbacks());
115         model.setAllowTrackbacks(soapModel.getAllowTrackbacks());
116         model.setTrackbacks(soapModel.getTrackbacks());
117         model.setStatus(soapModel.getStatus());
118         model.setStatusByUserId(soapModel.getStatusByUserId());
119         model.setStatusByUserName(soapModel.getStatusByUserName());
120         model.setStatusDate(soapModel.getStatusDate());
121 
122         return model;
123     }
124 
125     public static List<BlogsEntry> toModels(BlogsEntrySoap[] soapModels) {
126         List<BlogsEntry> models = new ArrayList<BlogsEntry>(soapModels.length);
127 
128         for (BlogsEntrySoap soapModel : soapModels) {
129             models.add(toModel(soapModel));
130         }
131 
132         return models;
133     }
134 
135     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
136                 "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsEntry"));
137 
138     public BlogsEntryModelImpl() {
139     }
140 
141     public long getPrimaryKey() {
142         return _entryId;
143     }
144 
145     public void setPrimaryKey(long pk) {
146         setEntryId(pk);
147     }
148 
149     public Serializable getPrimaryKeyObj() {
150         return new Long(_entryId);
151     }
152 
153     public String getUuid() {
154         if (_uuid == null) {
155             return StringPool.BLANK;
156         }
157         else {
158             return _uuid;
159         }
160     }
161 
162     public void setUuid(String uuid) {
163         _uuid = uuid;
164 
165         if (_originalUuid == null) {
166             _originalUuid = uuid;
167         }
168     }
169 
170     public String getOriginalUuid() {
171         return GetterUtil.getString(_originalUuid);
172     }
173 
174     public long getEntryId() {
175         return _entryId;
176     }
177 
178     public void setEntryId(long entryId) {
179         _entryId = entryId;
180     }
181 
182     public long getGroupId() {
183         return _groupId;
184     }
185 
186     public void setGroupId(long groupId) {
187         _groupId = groupId;
188 
189         if (!_setOriginalGroupId) {
190             _setOriginalGroupId = true;
191 
192             _originalGroupId = groupId;
193         }
194     }
195 
196     public long getOriginalGroupId() {
197         return _originalGroupId;
198     }
199 
200     public long getCompanyId() {
201         return _companyId;
202     }
203 
204     public void setCompanyId(long companyId) {
205         _companyId = companyId;
206     }
207 
208     public long getUserId() {
209         return _userId;
210     }
211 
212     public void setUserId(long userId) {
213         _userId = userId;
214     }
215 
216     public String getUserUuid() throws SystemException {
217         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
218     }
219 
220     public void setUserUuid(String userUuid) {
221         _userUuid = userUuid;
222     }
223 
224     public String getUserName() {
225         if (_userName == null) {
226             return StringPool.BLANK;
227         }
228         else {
229             return _userName;
230         }
231     }
232 
233     public void setUserName(String userName) {
234         _userName = userName;
235     }
236 
237     public Date getCreateDate() {
238         return _createDate;
239     }
240 
241     public void setCreateDate(Date createDate) {
242         _createDate = createDate;
243     }
244 
245     public Date getModifiedDate() {
246         return _modifiedDate;
247     }
248 
249     public void setModifiedDate(Date modifiedDate) {
250         _modifiedDate = modifiedDate;
251     }
252 
253     public String getTitle() {
254         if (_title == null) {
255             return StringPool.BLANK;
256         }
257         else {
258             return _title;
259         }
260     }
261 
262     public void setTitle(String title) {
263         _title = title;
264     }
265 
266     public String getUrlTitle() {
267         if (_urlTitle == null) {
268             return StringPool.BLANK;
269         }
270         else {
271             return _urlTitle;
272         }
273     }
274 
275     public void setUrlTitle(String urlTitle) {
276         _urlTitle = urlTitle;
277 
278         if (_originalUrlTitle == null) {
279             _originalUrlTitle = urlTitle;
280         }
281     }
282 
283     public String getOriginalUrlTitle() {
284         return GetterUtil.getString(_originalUrlTitle);
285     }
286 
287     public String getContent() {
288         if (_content == null) {
289             return StringPool.BLANK;
290         }
291         else {
292             return _content;
293         }
294     }
295 
296     public void setContent(String content) {
297         _content = content;
298     }
299 
300     public Date getDisplayDate() {
301         return _displayDate;
302     }
303 
304     public void setDisplayDate(Date displayDate) {
305         _displayDate = displayDate;
306     }
307 
308     public boolean getAllowPingbacks() {
309         return _allowPingbacks;
310     }
311 
312     public boolean isAllowPingbacks() {
313         return _allowPingbacks;
314     }
315 
316     public void setAllowPingbacks(boolean allowPingbacks) {
317         _allowPingbacks = allowPingbacks;
318     }
319 
320     public boolean getAllowTrackbacks() {
321         return _allowTrackbacks;
322     }
323 
324     public boolean isAllowTrackbacks() {
325         return _allowTrackbacks;
326     }
327 
328     public void setAllowTrackbacks(boolean allowTrackbacks) {
329         _allowTrackbacks = allowTrackbacks;
330     }
331 
332     public String getTrackbacks() {
333         if (_trackbacks == null) {
334             return StringPool.BLANK;
335         }
336         else {
337             return _trackbacks;
338         }
339     }
340 
341     public void setTrackbacks(String trackbacks) {
342         _trackbacks = trackbacks;
343     }
344 
345     public int getStatus() {
346         return _status;
347     }
348 
349     public void setStatus(int status) {
350         _status = status;
351     }
352 
353     public long getStatusByUserId() {
354         return _statusByUserId;
355     }
356 
357     public void setStatusByUserId(long statusByUserId) {
358         _statusByUserId = statusByUserId;
359     }
360 
361     public String getStatusByUserUuid() throws SystemException {
362         return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
363             _statusByUserUuid);
364     }
365 
366     public void setStatusByUserUuid(String statusByUserUuid) {
367         _statusByUserUuid = statusByUserUuid;
368     }
369 
370     public String getStatusByUserName() {
371         if (_statusByUserName == null) {
372             return StringPool.BLANK;
373         }
374         else {
375             return _statusByUserName;
376         }
377     }
378 
379     public void setStatusByUserName(String statusByUserName) {
380         _statusByUserName = statusByUserName;
381     }
382 
383     public Date getStatusDate() {
384         return _statusDate;
385     }
386 
387     public void setStatusDate(Date statusDate) {
388         _statusDate = statusDate;
389     }
390 
391     public boolean isApproved() {
392         if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
393             return true;
394         }
395         else {
396             return false;
397         }
398     }
399 
400     public boolean isDraft() {
401         if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
402             return true;
403         }
404         else {
405             return false;
406         }
407     }
408 
409     public boolean isExpired() {
410         if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
411             return true;
412         }
413         else {
414             return false;
415         }
416     }
417 
418     public boolean isPending() {
419         if (getStatus() == WorkflowConstants.STATUS_PENDING) {
420             return true;
421         }
422         else {
423             return false;
424         }
425     }
426 
427     public BlogsEntry toEscapedModel() {
428         if (isEscapedModel()) {
429             return (BlogsEntry)this;
430         }
431         else {
432             return (BlogsEntry)Proxy.newProxyInstance(BlogsEntry.class.getClassLoader(),
433                 new Class[] { BlogsEntry.class },
434                 new AutoEscapeBeanHandler(this));
435         }
436     }
437 
438     public ExpandoBridge getExpandoBridge() {
439         if (_expandoBridge == null) {
440             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
441                     BlogsEntry.class.getName(), getPrimaryKey());
442         }
443 
444         return _expandoBridge;
445     }
446 
447     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
448         getExpandoBridge().setAttributes(serviceContext);
449     }
450 
451     public Object clone() {
452         BlogsEntryImpl clone = new BlogsEntryImpl();
453 
454         clone.setUuid(getUuid());
455         clone.setEntryId(getEntryId());
456         clone.setGroupId(getGroupId());
457         clone.setCompanyId(getCompanyId());
458         clone.setUserId(getUserId());
459         clone.setUserName(getUserName());
460         clone.setCreateDate(getCreateDate());
461         clone.setModifiedDate(getModifiedDate());
462         clone.setTitle(getTitle());
463         clone.setUrlTitle(getUrlTitle());
464         clone.setContent(getContent());
465         clone.setDisplayDate(getDisplayDate());
466         clone.setAllowPingbacks(getAllowPingbacks());
467         clone.setAllowTrackbacks(getAllowTrackbacks());
468         clone.setTrackbacks(getTrackbacks());
469         clone.setStatus(getStatus());
470         clone.setStatusByUserId(getStatusByUserId());
471         clone.setStatusByUserName(getStatusByUserName());
472         clone.setStatusDate(getStatusDate());
473 
474         return clone;
475     }
476 
477     public int compareTo(BlogsEntry blogsEntry) {
478         int value = 0;
479 
480         value = DateUtil.compareTo(getDisplayDate(), blogsEntry.getDisplayDate());
481 
482         value = value * -1;
483 
484         if (value != 0) {
485             return value;
486         }
487 
488         return 0;
489     }
490 
491     public boolean equals(Object obj) {
492         if (obj == null) {
493             return false;
494         }
495 
496         BlogsEntry blogsEntry = null;
497 
498         try {
499             blogsEntry = (BlogsEntry)obj;
500         }
501         catch (ClassCastException cce) {
502             return false;
503         }
504 
505         long pk = blogsEntry.getPrimaryKey();
506 
507         if (getPrimaryKey() == pk) {
508             return true;
509         }
510         else {
511             return false;
512         }
513     }
514 
515     public int hashCode() {
516         return (int)getPrimaryKey();
517     }
518 
519     public String toString() {
520         StringBundler sb = new StringBundler(39);
521 
522         sb.append("{uuid=");
523         sb.append(getUuid());
524         sb.append(", entryId=");
525         sb.append(getEntryId());
526         sb.append(", groupId=");
527         sb.append(getGroupId());
528         sb.append(", companyId=");
529         sb.append(getCompanyId());
530         sb.append(", userId=");
531         sb.append(getUserId());
532         sb.append(", userName=");
533         sb.append(getUserName());
534         sb.append(", createDate=");
535         sb.append(getCreateDate());
536         sb.append(", modifiedDate=");
537         sb.append(getModifiedDate());
538         sb.append(", title=");
539         sb.append(getTitle());
540         sb.append(", urlTitle=");
541         sb.append(getUrlTitle());
542         sb.append(", content=");
543         sb.append(getContent());
544         sb.append(", displayDate=");
545         sb.append(getDisplayDate());
546         sb.append(", allowPingbacks=");
547         sb.append(getAllowPingbacks());
548         sb.append(", allowTrackbacks=");
549         sb.append(getAllowTrackbacks());
550         sb.append(", trackbacks=");
551         sb.append(getTrackbacks());
552         sb.append(", status=");
553         sb.append(getStatus());
554         sb.append(", statusByUserId=");
555         sb.append(getStatusByUserId());
556         sb.append(", statusByUserName=");
557         sb.append(getStatusByUserName());
558         sb.append(", statusDate=");
559         sb.append(getStatusDate());
560         sb.append("}");
561 
562         return sb.toString();
563     }
564 
565     public String toXmlString() {
566         StringBundler sb = new StringBundler(61);
567 
568         sb.append("<model><model-name>");
569         sb.append("com.liferay.portlet.blogs.model.BlogsEntry");
570         sb.append("</model-name>");
571 
572         sb.append(
573             "<column><column-name>uuid</column-name><column-value><![CDATA[");
574         sb.append(getUuid());
575         sb.append("]]></column-value></column>");
576         sb.append(
577             "<column><column-name>entryId</column-name><column-value><![CDATA[");
578         sb.append(getEntryId());
579         sb.append("]]></column-value></column>");
580         sb.append(
581             "<column><column-name>groupId</column-name><column-value><![CDATA[");
582         sb.append(getGroupId());
583         sb.append("]]></column-value></column>");
584         sb.append(
585             "<column><column-name>companyId</column-name><column-value><![CDATA[");
586         sb.append(getCompanyId());
587         sb.append("]]></column-value></column>");
588         sb.append(
589             "<column><column-name>userId</column-name><column-value><![CDATA[");
590         sb.append(getUserId());
591         sb.append("]]></column-value></column>");
592         sb.append(
593             "<column><column-name>userName</column-name><column-value><![CDATA[");
594         sb.append(getUserName());
595         sb.append("]]></column-value></column>");
596         sb.append(
597             "<column><column-name>createDate</column-name><column-value><![CDATA[");
598         sb.append(getCreateDate());
599         sb.append("]]></column-value></column>");
600         sb.append(
601             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
602         sb.append(getModifiedDate());
603         sb.append("]]></column-value></column>");
604         sb.append(
605             "<column><column-name>title</column-name><column-value><![CDATA[");
606         sb.append(getTitle());
607         sb.append("]]></column-value></column>");
608         sb.append(
609             "<column><column-name>urlTitle</column-name><column-value><![CDATA[");
610         sb.append(getUrlTitle());
611         sb.append("]]></column-value></column>");
612         sb.append(
613             "<column><column-name>content</column-name><column-value><![CDATA[");
614         sb.append(getContent());
615         sb.append("]]></column-value></column>");
616         sb.append(
617             "<column><column-name>displayDate</column-name><column-value><![CDATA[");
618         sb.append(getDisplayDate());
619         sb.append("]]></column-value></column>");
620         sb.append(
621             "<column><column-name>allowPingbacks</column-name><column-value><![CDATA[");
622         sb.append(getAllowPingbacks());
623         sb.append("]]></column-value></column>");
624         sb.append(
625             "<column><column-name>allowTrackbacks</column-name><column-value><![CDATA[");
626         sb.append(getAllowTrackbacks());
627         sb.append("]]></column-value></column>");
628         sb.append(
629             "<column><column-name>trackbacks</column-name><column-value><![CDATA[");
630         sb.append(getTrackbacks());
631         sb.append("]]></column-value></column>");
632         sb.append(
633             "<column><column-name>status</column-name><column-value><![CDATA[");
634         sb.append(getStatus());
635         sb.append("]]></column-value></column>");
636         sb.append(
637             "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
638         sb.append(getStatusByUserId());
639         sb.append("]]></column-value></column>");
640         sb.append(
641             "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
642         sb.append(getStatusByUserName());
643         sb.append("]]></column-value></column>");
644         sb.append(
645             "<column><column-name>statusDate</column-name><column-value><![CDATA[");
646         sb.append(getStatusDate());
647         sb.append("]]></column-value></column>");
648 
649         sb.append("</model>");
650 
651         return sb.toString();
652     }
653 
654     private String _uuid;
655     private String _originalUuid;
656     private long _entryId;
657     private long _groupId;
658     private long _originalGroupId;
659     private boolean _setOriginalGroupId;
660     private long _companyId;
661     private long _userId;
662     private String _userUuid;
663     private String _userName;
664     private Date _createDate;
665     private Date _modifiedDate;
666     private String _title;
667     private String _urlTitle;
668     private String _originalUrlTitle;
669     private String _content;
670     private Date _displayDate;
671     private boolean _allowPingbacks;
672     private boolean _allowTrackbacks;
673     private String _trackbacks;
674     private int _status;
675     private long _statusByUserId;
676     private String _statusByUserUuid;
677     private String _statusByUserName;
678     private Date _statusDate;
679     private transient ExpandoBridge _expandoBridge;
680 }