001    /**
002     * Copyright (c) 2000-2011 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.announcements.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.model.impl.BaseModelImpl;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.announcements.model.AnnouncementsEntry;
028    import com.liferay.portlet.announcements.model.AnnouncementsEntryModel;
029    import com.liferay.portlet.announcements.model.AnnouncementsEntrySoap;
030    import com.liferay.portlet.expando.model.ExpandoBridge;
031    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032    
033    import java.io.Serializable;
034    
035    import java.lang.reflect.Proxy;
036    
037    import java.sql.Types;
038    
039    import java.util.ArrayList;
040    import java.util.Date;
041    import java.util.List;
042    
043    /**
044     * The base model implementation for the AnnouncementsEntry service. Represents a row in the "AnnouncementsEntry" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link com.liferay.portlet.announcements.model.AnnouncementsEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AnnouncementsEntryImpl}.
048     * </p>
049     *
050     * <p>
051     * Never modify or reference this class directly. All methods that expect a announcements entry model instance should use the {@link com.liferay.portlet.announcements.model.AnnouncementsEntry} interface instead.
052     * </p>
053     *
054     * @author Brian Wing Shun Chan
055     * @see AnnouncementsEntryImpl
056     * @see com.liferay.portlet.announcements.model.AnnouncementsEntry
057     * @see com.liferay.portlet.announcements.model.AnnouncementsEntryModel
058     * @generated
059     */
060    public class AnnouncementsEntryModelImpl extends BaseModelImpl<AnnouncementsEntry>
061            implements AnnouncementsEntryModel {
062            public static final String TABLE_NAME = "AnnouncementsEntry";
063            public static final Object[][] TABLE_COLUMNS = {
064                            { "uuid_", new Integer(Types.VARCHAR) },
065                            { "entryId", new Integer(Types.BIGINT) },
066                            { "companyId", new Integer(Types.BIGINT) },
067                            { "userId", new Integer(Types.BIGINT) },
068                            { "userName", new Integer(Types.VARCHAR) },
069                            { "createDate", new Integer(Types.TIMESTAMP) },
070                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
071                            { "classNameId", new Integer(Types.BIGINT) },
072                            { "classPK", new Integer(Types.BIGINT) },
073                            { "title", new Integer(Types.VARCHAR) },
074                            { "content", new Integer(Types.VARCHAR) },
075                            { "url", new Integer(Types.VARCHAR) },
076                            { "type_", new Integer(Types.VARCHAR) },
077                            { "displayDate", new Integer(Types.TIMESTAMP) },
078                            { "expirationDate", new Integer(Types.TIMESTAMP) },
079                            { "priority", new Integer(Types.INTEGER) },
080                            { "alert", new Integer(Types.BOOLEAN) }
081                    };
082            public static final String TABLE_SQL_CREATE = "create table AnnouncementsEntry (uuid_ VARCHAR(75) null,entryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,title VARCHAR(75) null,content STRING null,url STRING null,type_ VARCHAR(75) null,displayDate DATE null,expirationDate DATE null,priority INTEGER,alert BOOLEAN)";
083            public static final String TABLE_SQL_DROP = "drop table AnnouncementsEntry";
084            public static final String ORDER_BY_JPQL = " ORDER BY announcementsEntry.priority ASC, announcementsEntry.modifiedDate ASC";
085            public static final String ORDER_BY_SQL = " ORDER BY AnnouncementsEntry.priority ASC, AnnouncementsEntry.modifiedDate ASC";
086            public static final String DATA_SOURCE = "liferayDataSource";
087            public static final String SESSION_FACTORY = "liferaySessionFactory";
088            public static final String TX_MANAGER = "liferayTransactionManager";
089            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsEntry"),
091                            true);
092            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093                                    "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsEntry"),
094                            true);
095    
096            /**
097             * Converts the soap model instance into a normal model instance.
098             *
099             * @param soapModel the soap model instance to convert
100             * @return the normal model instance
101             */
102            public static AnnouncementsEntry toModel(AnnouncementsEntrySoap soapModel) {
103                    AnnouncementsEntry model = new AnnouncementsEntryImpl();
104    
105                    model.setUuid(soapModel.getUuid());
106                    model.setEntryId(soapModel.getEntryId());
107                    model.setCompanyId(soapModel.getCompanyId());
108                    model.setUserId(soapModel.getUserId());
109                    model.setUserName(soapModel.getUserName());
110                    model.setCreateDate(soapModel.getCreateDate());
111                    model.setModifiedDate(soapModel.getModifiedDate());
112                    model.setClassNameId(soapModel.getClassNameId());
113                    model.setClassPK(soapModel.getClassPK());
114                    model.setTitle(soapModel.getTitle());
115                    model.setContent(soapModel.getContent());
116                    model.setUrl(soapModel.getUrl());
117                    model.setType(soapModel.getType());
118                    model.setDisplayDate(soapModel.getDisplayDate());
119                    model.setExpirationDate(soapModel.getExpirationDate());
120                    model.setPriority(soapModel.getPriority());
121                    model.setAlert(soapModel.getAlert());
122    
123                    return model;
124            }
125    
126            /**
127             * Converts the soap model instances into normal model instances.
128             *
129             * @param soapModels the soap model instances to convert
130             * @return the normal model instances
131             */
132            public static List<AnnouncementsEntry> toModels(
133                    AnnouncementsEntrySoap[] soapModels) {
134                    List<AnnouncementsEntry> models = new ArrayList<AnnouncementsEntry>(soapModels.length);
135    
136                    for (AnnouncementsEntrySoap soapModel : soapModels) {
137                            models.add(toModel(soapModel));
138                    }
139    
140                    return models;
141            }
142    
143            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
144                                    "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsEntry"));
145    
146            public AnnouncementsEntryModelImpl() {
147            }
148    
149            public long getPrimaryKey() {
150                    return _entryId;
151            }
152    
153            public void setPrimaryKey(long pk) {
154                    setEntryId(pk);
155            }
156    
157            public Serializable getPrimaryKeyObj() {
158                    return new Long(_entryId);
159            }
160    
161            public String getUuid() {
162                    if (_uuid == null) {
163                            return StringPool.BLANK;
164                    }
165                    else {
166                            return _uuid;
167                    }
168            }
169    
170            public void setUuid(String uuid) {
171                    _uuid = uuid;
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 getCompanyId() {
183                    return _companyId;
184            }
185    
186            public void setCompanyId(long companyId) {
187                    _companyId = companyId;
188            }
189    
190            public long getUserId() {
191                    return _userId;
192            }
193    
194            public void setUserId(long userId) {
195                    _userId = userId;
196            }
197    
198            public String getUserUuid() throws SystemException {
199                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
200            }
201    
202            public void setUserUuid(String userUuid) {
203                    _userUuid = userUuid;
204            }
205    
206            public String getUserName() {
207                    if (_userName == null) {
208                            return StringPool.BLANK;
209                    }
210                    else {
211                            return _userName;
212                    }
213            }
214    
215            public void setUserName(String userName) {
216                    _userName = userName;
217            }
218    
219            public Date getCreateDate() {
220                    return _createDate;
221            }
222    
223            public void setCreateDate(Date createDate) {
224                    _createDate = createDate;
225            }
226    
227            public Date getModifiedDate() {
228                    return _modifiedDate;
229            }
230    
231            public void setModifiedDate(Date modifiedDate) {
232                    _modifiedDate = modifiedDate;
233            }
234    
235            public String getClassName() {
236                    if (getClassNameId() <= 0) {
237                            return StringPool.BLANK;
238                    }
239    
240                    return PortalUtil.getClassName(getClassNameId());
241            }
242    
243            public long getClassNameId() {
244                    return _classNameId;
245            }
246    
247            public void setClassNameId(long classNameId) {
248                    _classNameId = classNameId;
249            }
250    
251            public long getClassPK() {
252                    return _classPK;
253            }
254    
255            public void setClassPK(long classPK) {
256                    _classPK = classPK;
257            }
258    
259            public String getTitle() {
260                    if (_title == null) {
261                            return StringPool.BLANK;
262                    }
263                    else {
264                            return _title;
265                    }
266            }
267    
268            public void setTitle(String title) {
269                    _title = title;
270            }
271    
272            public String getContent() {
273                    if (_content == null) {
274                            return StringPool.BLANK;
275                    }
276                    else {
277                            return _content;
278                    }
279            }
280    
281            public void setContent(String content) {
282                    _content = content;
283            }
284    
285            public String getUrl() {
286                    if (_url == null) {
287                            return StringPool.BLANK;
288                    }
289                    else {
290                            return _url;
291                    }
292            }
293    
294            public void setUrl(String url) {
295                    _url = url;
296            }
297    
298            public String getType() {
299                    if (_type == null) {
300                            return StringPool.BLANK;
301                    }
302                    else {
303                            return _type;
304                    }
305            }
306    
307            public void setType(String type) {
308                    _type = type;
309            }
310    
311            public Date getDisplayDate() {
312                    return _displayDate;
313            }
314    
315            public void setDisplayDate(Date displayDate) {
316                    _displayDate = displayDate;
317            }
318    
319            public Date getExpirationDate() {
320                    return _expirationDate;
321            }
322    
323            public void setExpirationDate(Date expirationDate) {
324                    _expirationDate = expirationDate;
325            }
326    
327            public int getPriority() {
328                    return _priority;
329            }
330    
331            public void setPriority(int priority) {
332                    _priority = priority;
333            }
334    
335            public boolean getAlert() {
336                    return _alert;
337            }
338    
339            public boolean isAlert() {
340                    return _alert;
341            }
342    
343            public void setAlert(boolean alert) {
344                    _alert = alert;
345            }
346    
347            public AnnouncementsEntry toEscapedModel() {
348                    if (isEscapedModel()) {
349                            return (AnnouncementsEntry)this;
350                    }
351                    else {
352                            return (AnnouncementsEntry)Proxy.newProxyInstance(AnnouncementsEntry.class.getClassLoader(),
353                                    new Class[] { AnnouncementsEntry.class },
354                                    new AutoEscapeBeanHandler(this));
355                    }
356            }
357    
358            public ExpandoBridge getExpandoBridge() {
359                    if (_expandoBridge == null) {
360                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
361                                            AnnouncementsEntry.class.getName(), getPrimaryKey());
362                    }
363    
364                    return _expandoBridge;
365            }
366    
367            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
368                    getExpandoBridge().setAttributes(serviceContext);
369            }
370    
371            public Object clone() {
372                    AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
373    
374                    announcementsEntryImpl.setUuid(getUuid());
375    
376                    announcementsEntryImpl.setEntryId(getEntryId());
377    
378                    announcementsEntryImpl.setCompanyId(getCompanyId());
379    
380                    announcementsEntryImpl.setUserId(getUserId());
381    
382                    announcementsEntryImpl.setUserName(getUserName());
383    
384                    announcementsEntryImpl.setCreateDate(getCreateDate());
385    
386                    announcementsEntryImpl.setModifiedDate(getModifiedDate());
387    
388                    announcementsEntryImpl.setClassNameId(getClassNameId());
389    
390                    announcementsEntryImpl.setClassPK(getClassPK());
391    
392                    announcementsEntryImpl.setTitle(getTitle());
393    
394                    announcementsEntryImpl.setContent(getContent());
395    
396                    announcementsEntryImpl.setUrl(getUrl());
397    
398                    announcementsEntryImpl.setType(getType());
399    
400                    announcementsEntryImpl.setDisplayDate(getDisplayDate());
401    
402                    announcementsEntryImpl.setExpirationDate(getExpirationDate());
403    
404                    announcementsEntryImpl.setPriority(getPriority());
405    
406                    announcementsEntryImpl.setAlert(getAlert());
407    
408                    return announcementsEntryImpl;
409            }
410    
411            public int compareTo(AnnouncementsEntry announcementsEntry) {
412                    int value = 0;
413    
414                    if (getPriority() < announcementsEntry.getPriority()) {
415                            value = -1;
416                    }
417                    else if (getPriority() > announcementsEntry.getPriority()) {
418                            value = 1;
419                    }
420                    else {
421                            value = 0;
422                    }
423    
424                    if (value != 0) {
425                            return value;
426                    }
427    
428                    value = DateUtil.compareTo(getModifiedDate(),
429                                    announcementsEntry.getModifiedDate());
430    
431                    if (value != 0) {
432                            return value;
433                    }
434    
435                    return 0;
436            }
437    
438            public boolean equals(Object obj) {
439                    if (obj == null) {
440                            return false;
441                    }
442    
443                    AnnouncementsEntry announcementsEntry = null;
444    
445                    try {
446                            announcementsEntry = (AnnouncementsEntry)obj;
447                    }
448                    catch (ClassCastException cce) {
449                            return false;
450                    }
451    
452                    long pk = announcementsEntry.getPrimaryKey();
453    
454                    if (getPrimaryKey() == pk) {
455                            return true;
456                    }
457                    else {
458                            return false;
459                    }
460            }
461    
462            public int hashCode() {
463                    return (int)getPrimaryKey();
464            }
465    
466            public String toString() {
467                    StringBundler sb = new StringBundler(35);
468    
469                    sb.append("{uuid=");
470                    sb.append(getUuid());
471                    sb.append(", entryId=");
472                    sb.append(getEntryId());
473                    sb.append(", companyId=");
474                    sb.append(getCompanyId());
475                    sb.append(", userId=");
476                    sb.append(getUserId());
477                    sb.append(", userName=");
478                    sb.append(getUserName());
479                    sb.append(", createDate=");
480                    sb.append(getCreateDate());
481                    sb.append(", modifiedDate=");
482                    sb.append(getModifiedDate());
483                    sb.append(", classNameId=");
484                    sb.append(getClassNameId());
485                    sb.append(", classPK=");
486                    sb.append(getClassPK());
487                    sb.append(", title=");
488                    sb.append(getTitle());
489                    sb.append(", content=");
490                    sb.append(getContent());
491                    sb.append(", url=");
492                    sb.append(getUrl());
493                    sb.append(", type=");
494                    sb.append(getType());
495                    sb.append(", displayDate=");
496                    sb.append(getDisplayDate());
497                    sb.append(", expirationDate=");
498                    sb.append(getExpirationDate());
499                    sb.append(", priority=");
500                    sb.append(getPriority());
501                    sb.append(", alert=");
502                    sb.append(getAlert());
503                    sb.append("}");
504    
505                    return sb.toString();
506            }
507    
508            public String toXmlString() {
509                    StringBundler sb = new StringBundler(55);
510    
511                    sb.append("<model><model-name>");
512                    sb.append("com.liferay.portlet.announcements.model.AnnouncementsEntry");
513                    sb.append("</model-name>");
514    
515                    sb.append(
516                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
517                    sb.append(getUuid());
518                    sb.append("]]></column-value></column>");
519                    sb.append(
520                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
521                    sb.append(getEntryId());
522                    sb.append("]]></column-value></column>");
523                    sb.append(
524                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
525                    sb.append(getCompanyId());
526                    sb.append("]]></column-value></column>");
527                    sb.append(
528                            "<column><column-name>userId</column-name><column-value><![CDATA[");
529                    sb.append(getUserId());
530                    sb.append("]]></column-value></column>");
531                    sb.append(
532                            "<column><column-name>userName</column-name><column-value><![CDATA[");
533                    sb.append(getUserName());
534                    sb.append("]]></column-value></column>");
535                    sb.append(
536                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
537                    sb.append(getCreateDate());
538                    sb.append("]]></column-value></column>");
539                    sb.append(
540                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
541                    sb.append(getModifiedDate());
542                    sb.append("]]></column-value></column>");
543                    sb.append(
544                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
545                    sb.append(getClassNameId());
546                    sb.append("]]></column-value></column>");
547                    sb.append(
548                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
549                    sb.append(getClassPK());
550                    sb.append("]]></column-value></column>");
551                    sb.append(
552                            "<column><column-name>title</column-name><column-value><![CDATA[");
553                    sb.append(getTitle());
554                    sb.append("]]></column-value></column>");
555                    sb.append(
556                            "<column><column-name>content</column-name><column-value><![CDATA[");
557                    sb.append(getContent());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>url</column-name><column-value><![CDATA[");
561                    sb.append(getUrl());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>type</column-name><column-value><![CDATA[");
565                    sb.append(getType());
566                    sb.append("]]></column-value></column>");
567                    sb.append(
568                            "<column><column-name>displayDate</column-name><column-value><![CDATA[");
569                    sb.append(getDisplayDate());
570                    sb.append("]]></column-value></column>");
571                    sb.append(
572                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
573                    sb.append(getExpirationDate());
574                    sb.append("]]></column-value></column>");
575                    sb.append(
576                            "<column><column-name>priority</column-name><column-value><![CDATA[");
577                    sb.append(getPriority());
578                    sb.append("]]></column-value></column>");
579                    sb.append(
580                            "<column><column-name>alert</column-name><column-value><![CDATA[");
581                    sb.append(getAlert());
582                    sb.append("]]></column-value></column>");
583    
584                    sb.append("</model>");
585    
586                    return sb.toString();
587            }
588    
589            private String _uuid;
590            private long _entryId;
591            private long _companyId;
592            private long _userId;
593            private String _userUuid;
594            private String _userName;
595            private Date _createDate;
596            private Date _modifiedDate;
597            private long _classNameId;
598            private long _classPK;
599            private String _title;
600            private String _content;
601            private String _url;
602            private String _type;
603            private Date _displayDate;
604            private Date _expirationDate;
605            private int _priority;
606            private boolean _alert;
607            private transient ExpandoBridge _expandoBridge;
608    }