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.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 clone = new AnnouncementsEntryImpl();
373    
374                    clone.setUuid(getUuid());
375                    clone.setEntryId(getEntryId());
376                    clone.setCompanyId(getCompanyId());
377                    clone.setUserId(getUserId());
378                    clone.setUserName(getUserName());
379                    clone.setCreateDate(getCreateDate());
380                    clone.setModifiedDate(getModifiedDate());
381                    clone.setClassNameId(getClassNameId());
382                    clone.setClassPK(getClassPK());
383                    clone.setTitle(getTitle());
384                    clone.setContent(getContent());
385                    clone.setUrl(getUrl());
386                    clone.setType(getType());
387                    clone.setDisplayDate(getDisplayDate());
388                    clone.setExpirationDate(getExpirationDate());
389                    clone.setPriority(getPriority());
390                    clone.setAlert(getAlert());
391    
392                    return clone;
393            }
394    
395            public int compareTo(AnnouncementsEntry announcementsEntry) {
396                    int value = 0;
397    
398                    if (getPriority() < announcementsEntry.getPriority()) {
399                            value = -1;
400                    }
401                    else if (getPriority() > announcementsEntry.getPriority()) {
402                            value = 1;
403                    }
404                    else {
405                            value = 0;
406                    }
407    
408                    if (value != 0) {
409                            return value;
410                    }
411    
412                    value = DateUtil.compareTo(getModifiedDate(),
413                                    announcementsEntry.getModifiedDate());
414    
415                    if (value != 0) {
416                            return value;
417                    }
418    
419                    return 0;
420            }
421    
422            public boolean equals(Object obj) {
423                    if (obj == null) {
424                            return false;
425                    }
426    
427                    AnnouncementsEntry announcementsEntry = null;
428    
429                    try {
430                            announcementsEntry = (AnnouncementsEntry)obj;
431                    }
432                    catch (ClassCastException cce) {
433                            return false;
434                    }
435    
436                    long pk = announcementsEntry.getPrimaryKey();
437    
438                    if (getPrimaryKey() == pk) {
439                            return true;
440                    }
441                    else {
442                            return false;
443                    }
444            }
445    
446            public int hashCode() {
447                    return (int)getPrimaryKey();
448            }
449    
450            public String toString() {
451                    StringBundler sb = new StringBundler(35);
452    
453                    sb.append("{uuid=");
454                    sb.append(getUuid());
455                    sb.append(", entryId=");
456                    sb.append(getEntryId());
457                    sb.append(", companyId=");
458                    sb.append(getCompanyId());
459                    sb.append(", userId=");
460                    sb.append(getUserId());
461                    sb.append(", userName=");
462                    sb.append(getUserName());
463                    sb.append(", createDate=");
464                    sb.append(getCreateDate());
465                    sb.append(", modifiedDate=");
466                    sb.append(getModifiedDate());
467                    sb.append(", classNameId=");
468                    sb.append(getClassNameId());
469                    sb.append(", classPK=");
470                    sb.append(getClassPK());
471                    sb.append(", title=");
472                    sb.append(getTitle());
473                    sb.append(", content=");
474                    sb.append(getContent());
475                    sb.append(", url=");
476                    sb.append(getUrl());
477                    sb.append(", type=");
478                    sb.append(getType());
479                    sb.append(", displayDate=");
480                    sb.append(getDisplayDate());
481                    sb.append(", expirationDate=");
482                    sb.append(getExpirationDate());
483                    sb.append(", priority=");
484                    sb.append(getPriority());
485                    sb.append(", alert=");
486                    sb.append(getAlert());
487                    sb.append("}");
488    
489                    return sb.toString();
490            }
491    
492            public String toXmlString() {
493                    StringBundler sb = new StringBundler(55);
494    
495                    sb.append("<model><model-name>");
496                    sb.append("com.liferay.portlet.announcements.model.AnnouncementsEntry");
497                    sb.append("</model-name>");
498    
499                    sb.append(
500                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
501                    sb.append(getUuid());
502                    sb.append("]]></column-value></column>");
503                    sb.append(
504                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
505                    sb.append(getEntryId());
506                    sb.append("]]></column-value></column>");
507                    sb.append(
508                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
509                    sb.append(getCompanyId());
510                    sb.append("]]></column-value></column>");
511                    sb.append(
512                            "<column><column-name>userId</column-name><column-value><![CDATA[");
513                    sb.append(getUserId());
514                    sb.append("]]></column-value></column>");
515                    sb.append(
516                            "<column><column-name>userName</column-name><column-value><![CDATA[");
517                    sb.append(getUserName());
518                    sb.append("]]></column-value></column>");
519                    sb.append(
520                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
521                    sb.append(getCreateDate());
522                    sb.append("]]></column-value></column>");
523                    sb.append(
524                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
525                    sb.append(getModifiedDate());
526                    sb.append("]]></column-value></column>");
527                    sb.append(
528                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
529                    sb.append(getClassNameId());
530                    sb.append("]]></column-value></column>");
531                    sb.append(
532                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
533                    sb.append(getClassPK());
534                    sb.append("]]></column-value></column>");
535                    sb.append(
536                            "<column><column-name>title</column-name><column-value><![CDATA[");
537                    sb.append(getTitle());
538                    sb.append("]]></column-value></column>");
539                    sb.append(
540                            "<column><column-name>content</column-name><column-value><![CDATA[");
541                    sb.append(getContent());
542                    sb.append("]]></column-value></column>");
543                    sb.append(
544                            "<column><column-name>url</column-name><column-value><![CDATA[");
545                    sb.append(getUrl());
546                    sb.append("]]></column-value></column>");
547                    sb.append(
548                            "<column><column-name>type</column-name><column-value><![CDATA[");
549                    sb.append(getType());
550                    sb.append("]]></column-value></column>");
551                    sb.append(
552                            "<column><column-name>displayDate</column-name><column-value><![CDATA[");
553                    sb.append(getDisplayDate());
554                    sb.append("]]></column-value></column>");
555                    sb.append(
556                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
557                    sb.append(getExpirationDate());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>priority</column-name><column-value><![CDATA[");
561                    sb.append(getPriority());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>alert</column-name><column-value><![CDATA[");
565                    sb.append(getAlert());
566                    sb.append("]]></column-value></column>");
567    
568                    sb.append("</model>");
569    
570                    return sb.toString();
571            }
572    
573            private String _uuid;
574            private long _entryId;
575            private long _companyId;
576            private long _userId;
577            private String _userUuid;
578            private String _userName;
579            private Date _createDate;
580            private Date _modifiedDate;
581            private long _classNameId;
582            private long _classPK;
583            private String _title;
584            private String _content;
585            private String _url;
586            private String _type;
587            private Date _displayDate;
588            private Date _expirationDate;
589            private int _priority;
590            private boolean _alert;
591            private transient ExpandoBridge _expandoBridge;
592    }