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