001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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            public boolean isApproved() {
404                    if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
405                            return true;
406                    }
407                    else {
408                            return false;
409                    }
410            }
411    
412            public boolean isDraft() {
413                    if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
414                            return true;
415                    }
416                    else {
417                            return false;
418                    }
419            }
420    
421            public boolean isExpired() {
422                    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
423                            return true;
424                    }
425                    else {
426                            return false;
427                    }
428            }
429    
430            public boolean isPending() {
431                    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
432                            return true;
433                    }
434                    else {
435                            return false;
436                    }
437            }
438    
439            public BlogsEntry toEscapedModel() {
440                    if (isEscapedModel()) {
441                            return (BlogsEntry)this;
442                    }
443                    else {
444                            return (BlogsEntry)Proxy.newProxyInstance(BlogsEntry.class.getClassLoader(),
445                                    new Class[] { BlogsEntry.class },
446                                    new AutoEscapeBeanHandler(this));
447                    }
448            }
449    
450            public ExpandoBridge getExpandoBridge() {
451                    if (_expandoBridge == null) {
452                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
453                                            BlogsEntry.class.getName(), getPrimaryKey());
454                    }
455    
456                    return _expandoBridge;
457            }
458    
459            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
460                    getExpandoBridge().setAttributes(serviceContext);
461            }
462    
463            public Object clone() {
464                    BlogsEntryImpl clone = new BlogsEntryImpl();
465    
466                    clone.setUuid(getUuid());
467                    clone.setEntryId(getEntryId());
468                    clone.setGroupId(getGroupId());
469                    clone.setCompanyId(getCompanyId());
470                    clone.setUserId(getUserId());
471                    clone.setUserName(getUserName());
472                    clone.setCreateDate(getCreateDate());
473                    clone.setModifiedDate(getModifiedDate());
474                    clone.setTitle(getTitle());
475                    clone.setUrlTitle(getUrlTitle());
476                    clone.setContent(getContent());
477                    clone.setDisplayDate(getDisplayDate());
478                    clone.setAllowPingbacks(getAllowPingbacks());
479                    clone.setAllowTrackbacks(getAllowTrackbacks());
480                    clone.setTrackbacks(getTrackbacks());
481                    clone.setStatus(getStatus());
482                    clone.setStatusByUserId(getStatusByUserId());
483                    clone.setStatusByUserName(getStatusByUserName());
484                    clone.setStatusDate(getStatusDate());
485    
486                    return clone;
487            }
488    
489            public int compareTo(BlogsEntry blogsEntry) {
490                    int value = 0;
491    
492                    value = DateUtil.compareTo(getDisplayDate(), blogsEntry.getDisplayDate());
493    
494                    value = value * -1;
495    
496                    if (value != 0) {
497                            return value;
498                    }
499    
500                    return 0;
501            }
502    
503            public boolean equals(Object obj) {
504                    if (obj == null) {
505                            return false;
506                    }
507    
508                    BlogsEntry blogsEntry = null;
509    
510                    try {
511                            blogsEntry = (BlogsEntry)obj;
512                    }
513                    catch (ClassCastException cce) {
514                            return false;
515                    }
516    
517                    long pk = blogsEntry.getPrimaryKey();
518    
519                    if (getPrimaryKey() == pk) {
520                            return true;
521                    }
522                    else {
523                            return false;
524                    }
525            }
526    
527            public int hashCode() {
528                    return (int)getPrimaryKey();
529            }
530    
531            public String toString() {
532                    StringBundler sb = new StringBundler(39);
533    
534                    sb.append("{uuid=");
535                    sb.append(getUuid());
536                    sb.append(", entryId=");
537                    sb.append(getEntryId());
538                    sb.append(", groupId=");
539                    sb.append(getGroupId());
540                    sb.append(", companyId=");
541                    sb.append(getCompanyId());
542                    sb.append(", userId=");
543                    sb.append(getUserId());
544                    sb.append(", userName=");
545                    sb.append(getUserName());
546                    sb.append(", createDate=");
547                    sb.append(getCreateDate());
548                    sb.append(", modifiedDate=");
549                    sb.append(getModifiedDate());
550                    sb.append(", title=");
551                    sb.append(getTitle());
552                    sb.append(", urlTitle=");
553                    sb.append(getUrlTitle());
554                    sb.append(", content=");
555                    sb.append(getContent());
556                    sb.append(", displayDate=");
557                    sb.append(getDisplayDate());
558                    sb.append(", allowPingbacks=");
559                    sb.append(getAllowPingbacks());
560                    sb.append(", allowTrackbacks=");
561                    sb.append(getAllowTrackbacks());
562                    sb.append(", trackbacks=");
563                    sb.append(getTrackbacks());
564                    sb.append(", status=");
565                    sb.append(getStatus());
566                    sb.append(", statusByUserId=");
567                    sb.append(getStatusByUserId());
568                    sb.append(", statusByUserName=");
569                    sb.append(getStatusByUserName());
570                    sb.append(", statusDate=");
571                    sb.append(getStatusDate());
572                    sb.append("}");
573    
574                    return sb.toString();
575            }
576    
577            public String toXmlString() {
578                    StringBundler sb = new StringBundler(61);
579    
580                    sb.append("<model><model-name>");
581                    sb.append("com.liferay.portlet.blogs.model.BlogsEntry");
582                    sb.append("</model-name>");
583    
584                    sb.append(
585                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
586                    sb.append(getUuid());
587                    sb.append("]]></column-value></column>");
588                    sb.append(
589                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
590                    sb.append(getEntryId());
591                    sb.append("]]></column-value></column>");
592                    sb.append(
593                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
594                    sb.append(getGroupId());
595                    sb.append("]]></column-value></column>");
596                    sb.append(
597                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
598                    sb.append(getCompanyId());
599                    sb.append("]]></column-value></column>");
600                    sb.append(
601                            "<column><column-name>userId</column-name><column-value><![CDATA[");
602                    sb.append(getUserId());
603                    sb.append("]]></column-value></column>");
604                    sb.append(
605                            "<column><column-name>userName</column-name><column-value><![CDATA[");
606                    sb.append(getUserName());
607                    sb.append("]]></column-value></column>");
608                    sb.append(
609                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
610                    sb.append(getCreateDate());
611                    sb.append("]]></column-value></column>");
612                    sb.append(
613                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
614                    sb.append(getModifiedDate());
615                    sb.append("]]></column-value></column>");
616                    sb.append(
617                            "<column><column-name>title</column-name><column-value><![CDATA[");
618                    sb.append(getTitle());
619                    sb.append("]]></column-value></column>");
620                    sb.append(
621                            "<column><column-name>urlTitle</column-name><column-value><![CDATA[");
622                    sb.append(getUrlTitle());
623                    sb.append("]]></column-value></column>");
624                    sb.append(
625                            "<column><column-name>content</column-name><column-value><![CDATA[");
626                    sb.append(getContent());
627                    sb.append("]]></column-value></column>");
628                    sb.append(
629                            "<column><column-name>displayDate</column-name><column-value><![CDATA[");
630                    sb.append(getDisplayDate());
631                    sb.append("]]></column-value></column>");
632                    sb.append(
633                            "<column><column-name>allowPingbacks</column-name><column-value><![CDATA[");
634                    sb.append(getAllowPingbacks());
635                    sb.append("]]></column-value></column>");
636                    sb.append(
637                            "<column><column-name>allowTrackbacks</column-name><column-value><![CDATA[");
638                    sb.append(getAllowTrackbacks());
639                    sb.append("]]></column-value></column>");
640                    sb.append(
641                            "<column><column-name>trackbacks</column-name><column-value><![CDATA[");
642                    sb.append(getTrackbacks());
643                    sb.append("]]></column-value></column>");
644                    sb.append(
645                            "<column><column-name>status</column-name><column-value><![CDATA[");
646                    sb.append(getStatus());
647                    sb.append("]]></column-value></column>");
648                    sb.append(
649                            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
650                    sb.append(getStatusByUserId());
651                    sb.append("]]></column-value></column>");
652                    sb.append(
653                            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
654                    sb.append(getStatusByUserName());
655                    sb.append("]]></column-value></column>");
656                    sb.append(
657                            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
658                    sb.append(getStatusDate());
659                    sb.append("]]></column-value></column>");
660    
661                    sb.append("</model>");
662    
663                    return sb.toString();
664            }
665    
666            private String _uuid;
667            private String _originalUuid;
668            private long _entryId;
669            private long _groupId;
670            private long _originalGroupId;
671            private boolean _setOriginalGroupId;
672            private long _companyId;
673            private long _userId;
674            private String _userUuid;
675            private String _userName;
676            private Date _createDate;
677            private Date _modifiedDate;
678            private String _title;
679            private String _urlTitle;
680            private String _originalUrlTitle;
681            private String _content;
682            private Date _displayDate;
683            private boolean _allowPingbacks;
684            private boolean _allowTrackbacks;
685            private String _trackbacks;
686            private int _status;
687            private long _statusByUserId;
688            private String _statusByUserUuid;
689            private String _statusByUserName;
690            private Date _statusDate;
691            private transient ExpandoBridge _expandoBridge;
692    }