001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.blogs.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.kernel.workflow.WorkflowConstants;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.blogs.model.BlogsEntry;
029    import com.liferay.portlet.blogs.model.BlogsEntryModel;
030    import com.liferay.portlet.blogs.model.BlogsEntrySoap;
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.lang.reflect.Proxy;
037    
038    import java.sql.Types;
039    
040    import java.util.ArrayList;
041    import java.util.Date;
042    import java.util.List;
043    
044    /**
045     * The base model implementation for the BlogsEntry service. Represents a row in the "BlogsEntry" database table, with each column mapped to a property of this class.
046     *
047     * <p>
048     * This implementation and its corresponding interface {@link com.liferay.portlet.blogs.model.BlogsEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BlogsEntryImpl}.
049     * </p>
050     *
051     * <p>
052     * Never modify or reference this class directly. All methods that expect a blogs entry model instance should use the {@link com.liferay.portlet.blogs.model.BlogsEntry} interface instead.
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see BlogsEntryImpl
057     * @see com.liferay.portlet.blogs.model.BlogsEntry
058     * @see com.liferay.portlet.blogs.model.BlogsEntryModel
059     * @generated
060     */
061    public class BlogsEntryModelImpl extends BaseModelImpl<BlogsEntry>
062            implements BlogsEntryModel {
063            public static final String TABLE_NAME = "BlogsEntry";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "uuid_", new Integer(Types.VARCHAR) },
066                            { "entryId", new Integer(Types.BIGINT) },
067                            { "groupId", new Integer(Types.BIGINT) },
068                            { "companyId", new Integer(Types.BIGINT) },
069                            { "userId", new Integer(Types.BIGINT) },
070                            { "userName", new Integer(Types.VARCHAR) },
071                            { "createDate", new Integer(Types.TIMESTAMP) },
072                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
073                            { "title", new Integer(Types.VARCHAR) },
074                            { "urlTitle", new Integer(Types.VARCHAR) },
075                            { "content", new Integer(Types.CLOB) },
076                            { "displayDate", new Integer(Types.TIMESTAMP) },
077                            { "allowPingbacks", new Integer(Types.BOOLEAN) },
078                            { "allowTrackbacks", new Integer(Types.BOOLEAN) },
079                            { "trackbacks", new Integer(Types.CLOB) },
080                            { "status", new Integer(Types.INTEGER) },
081                            { "statusByUserId", new Integer(Types.BIGINT) },
082                            { "statusByUserName", new Integer(Types.VARCHAR) },
083                            { "statusDate", new Integer(Types.TIMESTAMP) }
084                    };
085            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)";
086            public static final String TABLE_SQL_DROP = "drop table BlogsEntry";
087            public static final String ORDER_BY_JPQL = " ORDER BY blogsEntry.displayDate DESC";
088            public static final String ORDER_BY_SQL = " ORDER BY BlogsEntry.displayDate DESC";
089            public static final String DATA_SOURCE = "liferayDataSource";
090            public static final String SESSION_FACTORY = "liferaySessionFactory";
091            public static final String TX_MANAGER = "liferayTransactionManager";
092            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093                                    "value.object.entity.cache.enabled.com.liferay.portlet.blogs.model.BlogsEntry"),
094                            true);
095            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
096                                    "value.object.finder.cache.enabled.com.liferay.portlet.blogs.model.BlogsEntry"),
097                            true);
098    
099            /**
100             * Converts the soap model instance into a normal model instance.
101             *
102             * @param soapModel the soap model instance to convert
103             * @return the normal model instance
104             */
105            public static BlogsEntry toModel(BlogsEntrySoap soapModel) {
106                    BlogsEntry model = new BlogsEntryImpl();
107    
108                    model.setUuid(soapModel.getUuid());
109                    model.setEntryId(soapModel.getEntryId());
110                    model.setGroupId(soapModel.getGroupId());
111                    model.setCompanyId(soapModel.getCompanyId());
112                    model.setUserId(soapModel.getUserId());
113                    model.setUserName(soapModel.getUserName());
114                    model.setCreateDate(soapModel.getCreateDate());
115                    model.setModifiedDate(soapModel.getModifiedDate());
116                    model.setTitle(soapModel.getTitle());
117                    model.setUrlTitle(soapModel.getUrlTitle());
118                    model.setContent(soapModel.getContent());
119                    model.setDisplayDate(soapModel.getDisplayDate());
120                    model.setAllowPingbacks(soapModel.getAllowPingbacks());
121                    model.setAllowTrackbacks(soapModel.getAllowTrackbacks());
122                    model.setTrackbacks(soapModel.getTrackbacks());
123                    model.setStatus(soapModel.getStatus());
124                    model.setStatusByUserId(soapModel.getStatusByUserId());
125                    model.setStatusByUserName(soapModel.getStatusByUserName());
126                    model.setStatusDate(soapModel.getStatusDate());
127    
128                    return model;
129            }
130    
131            /**
132             * Converts the soap model instances into normal model instances.
133             *
134             * @param soapModels the soap model instances to convert
135             * @return the normal model instances
136             */
137            public static List<BlogsEntry> toModels(BlogsEntrySoap[] soapModels) {
138                    List<BlogsEntry> models = new ArrayList<BlogsEntry>(soapModels.length);
139    
140                    for (BlogsEntrySoap soapModel : soapModels) {
141                            models.add(toModel(soapModel));
142                    }
143    
144                    return models;
145            }
146    
147            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
148                                    "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsEntry"));
149    
150            public BlogsEntryModelImpl() {
151            }
152    
153            public long getPrimaryKey() {
154                    return _entryId;
155            }
156    
157            public void setPrimaryKey(long pk) {
158                    setEntryId(pk);
159            }
160    
161            public Serializable getPrimaryKeyObj() {
162                    return new Long(_entryId);
163            }
164    
165            public String getUuid() {
166                    if (_uuid == null) {
167                            return StringPool.BLANK;
168                    }
169                    else {
170                            return _uuid;
171                    }
172            }
173    
174            public void setUuid(String uuid) {
175                    _uuid = uuid;
176    
177                    if (_originalUuid == null) {
178                            _originalUuid = uuid;
179                    }
180            }
181    
182            public String getOriginalUuid() {
183                    return GetterUtil.getString(_originalUuid);
184            }
185    
186            public long getEntryId() {
187                    return _entryId;
188            }
189    
190            public void setEntryId(long entryId) {
191                    _entryId = entryId;
192            }
193    
194            public long getGroupId() {
195                    return _groupId;
196            }
197    
198            public void setGroupId(long groupId) {
199                    _groupId = groupId;
200    
201                    if (!_setOriginalGroupId) {
202                            _setOriginalGroupId = true;
203    
204                            _originalGroupId = groupId;
205                    }
206            }
207    
208            public long getOriginalGroupId() {
209                    return _originalGroupId;
210            }
211    
212            public long getCompanyId() {
213                    return _companyId;
214            }
215    
216            public void setCompanyId(long companyId) {
217                    _companyId = companyId;
218            }
219    
220            public long getUserId() {
221                    return _userId;
222            }
223    
224            public void setUserId(long userId) {
225                    _userId = userId;
226            }
227    
228            public String getUserUuid() throws SystemException {
229                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
230            }
231    
232            public void setUserUuid(String userUuid) {
233                    _userUuid = userUuid;
234            }
235    
236            public String getUserName() {
237                    if (_userName == null) {
238                            return StringPool.BLANK;
239                    }
240                    else {
241                            return _userName;
242                    }
243            }
244    
245            public void setUserName(String userName) {
246                    _userName = userName;
247            }
248    
249            public Date getCreateDate() {
250                    return _createDate;
251            }
252    
253            public void setCreateDate(Date createDate) {
254                    _createDate = createDate;
255            }
256    
257            public Date getModifiedDate() {
258                    return _modifiedDate;
259            }
260    
261            public void setModifiedDate(Date modifiedDate) {
262                    _modifiedDate = modifiedDate;
263            }
264    
265            public String getTitle() {
266                    if (_title == null) {
267                            return StringPool.BLANK;
268                    }
269                    else {
270                            return _title;
271                    }
272            }
273    
274            public void setTitle(String title) {
275                    _title = title;
276            }
277    
278            public String getUrlTitle() {
279                    if (_urlTitle == null) {
280                            return StringPool.BLANK;
281                    }
282                    else {
283                            return _urlTitle;
284                    }
285            }
286    
287            public void setUrlTitle(String urlTitle) {
288                    _urlTitle = urlTitle;
289    
290                    if (_originalUrlTitle == null) {
291                            _originalUrlTitle = urlTitle;
292                    }
293            }
294    
295            public String getOriginalUrlTitle() {
296                    return GetterUtil.getString(_originalUrlTitle);
297            }
298    
299            public String getContent() {
300                    if (_content == null) {
301                            return StringPool.BLANK;
302                    }
303                    else {
304                            return _content;
305                    }
306            }
307    
308            public void setContent(String content) {
309                    _content = content;
310            }
311    
312            public Date getDisplayDate() {
313                    return _displayDate;
314            }
315    
316            public void setDisplayDate(Date displayDate) {
317                    _displayDate = displayDate;
318            }
319    
320            public boolean getAllowPingbacks() {
321                    return _allowPingbacks;
322            }
323    
324            public boolean isAllowPingbacks() {
325                    return _allowPingbacks;
326            }
327    
328            public void setAllowPingbacks(boolean allowPingbacks) {
329                    _allowPingbacks = allowPingbacks;
330            }
331    
332            public boolean getAllowTrackbacks() {
333                    return _allowTrackbacks;
334            }
335    
336            public boolean isAllowTrackbacks() {
337                    return _allowTrackbacks;
338            }
339    
340            public void setAllowTrackbacks(boolean allowTrackbacks) {
341                    _allowTrackbacks = allowTrackbacks;
342            }
343    
344            public String getTrackbacks() {
345                    if (_trackbacks == null) {
346                            return StringPool.BLANK;
347                    }
348                    else {
349                            return _trackbacks;
350                    }
351            }
352    
353            public void setTrackbacks(String trackbacks) {
354                    _trackbacks = trackbacks;
355            }
356    
357            public int getStatus() {
358                    return _status;
359            }
360    
361            public void setStatus(int status) {
362                    _status = status;
363            }
364    
365            public long getStatusByUserId() {
366                    return _statusByUserId;
367            }
368    
369            public void setStatusByUserId(long statusByUserId) {
370                    _statusByUserId = statusByUserId;
371            }
372    
373            public String getStatusByUserUuid() throws SystemException {
374                    return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
375                            _statusByUserUuid);
376            }
377    
378            public void setStatusByUserUuid(String statusByUserUuid) {
379                    _statusByUserUuid = statusByUserUuid;
380            }
381    
382            public String getStatusByUserName() {
383                    if (_statusByUserName == null) {
384                            return StringPool.BLANK;
385                    }
386                    else {
387                            return _statusByUserName;
388                    }
389            }
390    
391            public void setStatusByUserName(String statusByUserName) {
392                    _statusByUserName = statusByUserName;
393            }
394    
395            public Date getStatusDate() {
396                    return _statusDate;
397            }
398    
399            public void setStatusDate(Date statusDate) {
400                    _statusDate = statusDate;
401            }
402    
403            /**
404             * @deprecated {@link #isApproved}
405             */
406            public boolean getApproved() {
407                    return isApproved();
408            }
409    
410            public boolean isApproved() {
411                    if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
412                            return true;
413                    }
414                    else {
415                            return false;
416                    }
417            }
418    
419            public boolean isDraft() {
420                    if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
421                            return true;
422                    }
423                    else {
424                            return false;
425                    }
426            }
427    
428            public boolean isExpired() {
429                    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
430                            return true;
431                    }
432                    else {
433                            return false;
434                    }
435            }
436    
437            public boolean isPending() {
438                    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
439                            return true;
440                    }
441                    else {
442                            return false;
443                    }
444            }
445    
446            public BlogsEntry toEscapedModel() {
447                    if (isEscapedModel()) {
448                            return (BlogsEntry)this;
449                    }
450                    else {
451                            return (BlogsEntry)Proxy.newProxyInstance(BlogsEntry.class.getClassLoader(),
452                                    new Class[] { BlogsEntry.class },
453                                    new AutoEscapeBeanHandler(this));
454                    }
455            }
456    
457            public ExpandoBridge getExpandoBridge() {
458                    if (_expandoBridge == null) {
459                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
460                                            BlogsEntry.class.getName(), getPrimaryKey());
461                    }
462    
463                    return _expandoBridge;
464            }
465    
466            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
467                    getExpandoBridge().setAttributes(serviceContext);
468            }
469    
470            public Object clone() {
471                    BlogsEntryImpl clone = new BlogsEntryImpl();
472    
473                    clone.setUuid(getUuid());
474                    clone.setEntryId(getEntryId());
475                    clone.setGroupId(getGroupId());
476                    clone.setCompanyId(getCompanyId());
477                    clone.setUserId(getUserId());
478                    clone.setUserName(getUserName());
479                    clone.setCreateDate(getCreateDate());
480                    clone.setModifiedDate(getModifiedDate());
481                    clone.setTitle(getTitle());
482                    clone.setUrlTitle(getUrlTitle());
483                    clone.setContent(getContent());
484                    clone.setDisplayDate(getDisplayDate());
485                    clone.setAllowPingbacks(getAllowPingbacks());
486                    clone.setAllowTrackbacks(getAllowTrackbacks());
487                    clone.setTrackbacks(getTrackbacks());
488                    clone.setStatus(getStatus());
489                    clone.setStatusByUserId(getStatusByUserId());
490                    clone.setStatusByUserName(getStatusByUserName());
491                    clone.setStatusDate(getStatusDate());
492    
493                    return clone;
494            }
495    
496            public int compareTo(BlogsEntry blogsEntry) {
497                    int value = 0;
498    
499                    value = DateUtil.compareTo(getDisplayDate(), blogsEntry.getDisplayDate());
500    
501                    value = value * -1;
502    
503                    if (value != 0) {
504                            return value;
505                    }
506    
507                    return 0;
508            }
509    
510            public boolean equals(Object obj) {
511                    if (obj == null) {
512                            return false;
513                    }
514    
515                    BlogsEntry blogsEntry = null;
516    
517                    try {
518                            blogsEntry = (BlogsEntry)obj;
519                    }
520                    catch (ClassCastException cce) {
521                            return false;
522                    }
523    
524                    long pk = blogsEntry.getPrimaryKey();
525    
526                    if (getPrimaryKey() == pk) {
527                            return true;
528                    }
529                    else {
530                            return false;
531                    }
532            }
533    
534            public int hashCode() {
535                    return (int)getPrimaryKey();
536            }
537    
538            public String toString() {
539                    StringBundler sb = new StringBundler(39);
540    
541                    sb.append("{uuid=");
542                    sb.append(getUuid());
543                    sb.append(", entryId=");
544                    sb.append(getEntryId());
545                    sb.append(", groupId=");
546                    sb.append(getGroupId());
547                    sb.append(", companyId=");
548                    sb.append(getCompanyId());
549                    sb.append(", userId=");
550                    sb.append(getUserId());
551                    sb.append(", userName=");
552                    sb.append(getUserName());
553                    sb.append(", createDate=");
554                    sb.append(getCreateDate());
555                    sb.append(", modifiedDate=");
556                    sb.append(getModifiedDate());
557                    sb.append(", title=");
558                    sb.append(getTitle());
559                    sb.append(", urlTitle=");
560                    sb.append(getUrlTitle());
561                    sb.append(", content=");
562                    sb.append(getContent());
563                    sb.append(", displayDate=");
564                    sb.append(getDisplayDate());
565                    sb.append(", allowPingbacks=");
566                    sb.append(getAllowPingbacks());
567                    sb.append(", allowTrackbacks=");
568                    sb.append(getAllowTrackbacks());
569                    sb.append(", trackbacks=");
570                    sb.append(getTrackbacks());
571                    sb.append(", status=");
572                    sb.append(getStatus());
573                    sb.append(", statusByUserId=");
574                    sb.append(getStatusByUserId());
575                    sb.append(", statusByUserName=");
576                    sb.append(getStatusByUserName());
577                    sb.append(", statusDate=");
578                    sb.append(getStatusDate());
579                    sb.append("}");
580    
581                    return sb.toString();
582            }
583    
584            public String toXmlString() {
585                    StringBundler sb = new StringBundler(61);
586    
587                    sb.append("<model><model-name>");
588                    sb.append("com.liferay.portlet.blogs.model.BlogsEntry");
589                    sb.append("</model-name>");
590    
591                    sb.append(
592                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
593                    sb.append(getUuid());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
597                    sb.append(getEntryId());
598                    sb.append("]]></column-value></column>");
599                    sb.append(
600                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
601                    sb.append(getGroupId());
602                    sb.append("]]></column-value></column>");
603                    sb.append(
604                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
605                    sb.append(getCompanyId());
606                    sb.append("]]></column-value></column>");
607                    sb.append(
608                            "<column><column-name>userId</column-name><column-value><![CDATA[");
609                    sb.append(getUserId());
610                    sb.append("]]></column-value></column>");
611                    sb.append(
612                            "<column><column-name>userName</column-name><column-value><![CDATA[");
613                    sb.append(getUserName());
614                    sb.append("]]></column-value></column>");
615                    sb.append(
616                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
617                    sb.append(getCreateDate());
618                    sb.append("]]></column-value></column>");
619                    sb.append(
620                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
621                    sb.append(getModifiedDate());
622                    sb.append("]]></column-value></column>");
623                    sb.append(
624                            "<column><column-name>title</column-name><column-value><![CDATA[");
625                    sb.append(getTitle());
626                    sb.append("]]></column-value></column>");
627                    sb.append(
628                            "<column><column-name>urlTitle</column-name><column-value><![CDATA[");
629                    sb.append(getUrlTitle());
630                    sb.append("]]></column-value></column>");
631                    sb.append(
632                            "<column><column-name>content</column-name><column-value><![CDATA[");
633                    sb.append(getContent());
634                    sb.append("]]></column-value></column>");
635                    sb.append(
636                            "<column><column-name>displayDate</column-name><column-value><![CDATA[");
637                    sb.append(getDisplayDate());
638                    sb.append("]]></column-value></column>");
639                    sb.append(
640                            "<column><column-name>allowPingbacks</column-name><column-value><![CDATA[");
641                    sb.append(getAllowPingbacks());
642                    sb.append("]]></column-value></column>");
643                    sb.append(
644                            "<column><column-name>allowTrackbacks</column-name><column-value><![CDATA[");
645                    sb.append(getAllowTrackbacks());
646                    sb.append("]]></column-value></column>");
647                    sb.append(
648                            "<column><column-name>trackbacks</column-name><column-value><![CDATA[");
649                    sb.append(getTrackbacks());
650                    sb.append("]]></column-value></column>");
651                    sb.append(
652                            "<column><column-name>status</column-name><column-value><![CDATA[");
653                    sb.append(getStatus());
654                    sb.append("]]></column-value></column>");
655                    sb.append(
656                            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
657                    sb.append(getStatusByUserId());
658                    sb.append("]]></column-value></column>");
659                    sb.append(
660                            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
661                    sb.append(getStatusByUserName());
662                    sb.append("]]></column-value></column>");
663                    sb.append(
664                            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
665                    sb.append(getStatusDate());
666                    sb.append("]]></column-value></column>");
667    
668                    sb.append("</model>");
669    
670                    return sb.toString();
671            }
672    
673            private String _uuid;
674            private String _originalUuid;
675            private long _entryId;
676            private long _groupId;
677            private long _originalGroupId;
678            private boolean _setOriginalGroupId;
679            private long _companyId;
680            private long _userId;
681            private String _userUuid;
682            private String _userName;
683            private Date _createDate;
684            private Date _modifiedDate;
685            private String _title;
686            private String _urlTitle;
687            private String _originalUrlTitle;
688            private String _content;
689            private Date _displayDate;
690            private boolean _allowPingbacks;
691            private boolean _allowTrackbacks;
692            private String _trackbacks;
693            private int _status;
694            private long _statusByUserId;
695            private String _statusByUserUuid;
696            private String _statusByUserName;
697            private Date _statusDate;
698            private transient ExpandoBridge _expandoBridge;
699    }