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.ratings.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.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.ratings.model.RatingsEntry;
029    import com.liferay.portlet.ratings.model.RatingsEntryModel;
030    import com.liferay.portlet.ratings.model.RatingsEntrySoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the RatingsEntry service. Represents a row in the "RatingsEntry" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.ratings.model.RatingsEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link RatingsEntryImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a ratings entry model instance should use the {@link com.liferay.portlet.ratings.model.RatingsEntry} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see RatingsEntryImpl
055     * @see com.liferay.portlet.ratings.model.RatingsEntry
056     * @see com.liferay.portlet.ratings.model.RatingsEntryModel
057     * @generated
058     */
059    public class RatingsEntryModelImpl extends BaseModelImpl<RatingsEntry>
060            implements RatingsEntryModel {
061            public static final String TABLE_NAME = "RatingsEntry";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "entryId", new Integer(Types.BIGINT) },
064                            { "companyId", new Integer(Types.BIGINT) },
065                            { "userId", new Integer(Types.BIGINT) },
066                            { "userName", new Integer(Types.VARCHAR) },
067                            { "createDate", new Integer(Types.TIMESTAMP) },
068                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
069                            { "classNameId", new Integer(Types.BIGINT) },
070                            { "classPK", new Integer(Types.BIGINT) },
071                            { "score", new Integer(Types.DOUBLE) }
072                    };
073            public static final String TABLE_SQL_CREATE = "create table RatingsEntry (entryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,score DOUBLE)";
074            public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
075            public static final String DATA_SOURCE = "liferayDataSource";
076            public static final String SESSION_FACTORY = "liferaySessionFactory";
077            public static final String TX_MANAGER = "liferayTransactionManager";
078            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
080                            true);
081            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
083                            true);
084    
085            /**
086             * Converts the soap model instance into a normal model instance.
087             *
088             * @param soapModel the soap model instance to convert
089             * @return the normal model instance
090             */
091            public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
092                    RatingsEntry model = new RatingsEntryImpl();
093    
094                    model.setEntryId(soapModel.getEntryId());
095                    model.setCompanyId(soapModel.getCompanyId());
096                    model.setUserId(soapModel.getUserId());
097                    model.setUserName(soapModel.getUserName());
098                    model.setCreateDate(soapModel.getCreateDate());
099                    model.setModifiedDate(soapModel.getModifiedDate());
100                    model.setClassNameId(soapModel.getClassNameId());
101                    model.setClassPK(soapModel.getClassPK());
102                    model.setScore(soapModel.getScore());
103    
104                    return model;
105            }
106    
107            /**
108             * Converts the soap model instances into normal model instances.
109             *
110             * @param soapModels the soap model instances to convert
111             * @return the normal model instances
112             */
113            public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
114                    List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
115    
116                    for (RatingsEntrySoap soapModel : soapModels) {
117                            models.add(toModel(soapModel));
118                    }
119    
120                    return models;
121            }
122    
123            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
124                                    "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
125    
126            public RatingsEntryModelImpl() {
127            }
128    
129            public long getPrimaryKey() {
130                    return _entryId;
131            }
132    
133            public void setPrimaryKey(long pk) {
134                    setEntryId(pk);
135            }
136    
137            public Serializable getPrimaryKeyObj() {
138                    return new Long(_entryId);
139            }
140    
141            public long getEntryId() {
142                    return _entryId;
143            }
144    
145            public void setEntryId(long entryId) {
146                    _entryId = entryId;
147            }
148    
149            public long getCompanyId() {
150                    return _companyId;
151            }
152    
153            public void setCompanyId(long companyId) {
154                    _companyId = companyId;
155            }
156    
157            public long getUserId() {
158                    return _userId;
159            }
160    
161            public void setUserId(long userId) {
162                    if (!_setOriginalUserId) {
163                            _setOriginalUserId = true;
164    
165                            _originalUserId = _userId;
166                    }
167    
168                    _userId = userId;
169            }
170    
171            public String getUserUuid() throws SystemException {
172                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
173            }
174    
175            public void setUserUuid(String userUuid) {
176                    _userUuid = userUuid;
177            }
178    
179            public long getOriginalUserId() {
180                    return _originalUserId;
181            }
182    
183            public String getUserName() {
184                    if (_userName == null) {
185                            return StringPool.BLANK;
186                    }
187                    else {
188                            return _userName;
189                    }
190            }
191    
192            public void setUserName(String userName) {
193                    _userName = userName;
194            }
195    
196            public Date getCreateDate() {
197                    return _createDate;
198            }
199    
200            public void setCreateDate(Date createDate) {
201                    _createDate = createDate;
202            }
203    
204            public Date getModifiedDate() {
205                    return _modifiedDate;
206            }
207    
208            public void setModifiedDate(Date modifiedDate) {
209                    _modifiedDate = modifiedDate;
210            }
211    
212            public String getClassName() {
213                    if (getClassNameId() <= 0) {
214                            return StringPool.BLANK;
215                    }
216    
217                    return PortalUtil.getClassName(getClassNameId());
218            }
219    
220            public long getClassNameId() {
221                    return _classNameId;
222            }
223    
224            public void setClassNameId(long classNameId) {
225                    if (!_setOriginalClassNameId) {
226                            _setOriginalClassNameId = true;
227    
228                            _originalClassNameId = _classNameId;
229                    }
230    
231                    _classNameId = classNameId;
232            }
233    
234            public long getOriginalClassNameId() {
235                    return _originalClassNameId;
236            }
237    
238            public long getClassPK() {
239                    return _classPK;
240            }
241    
242            public void setClassPK(long classPK) {
243                    if (!_setOriginalClassPK) {
244                            _setOriginalClassPK = true;
245    
246                            _originalClassPK = _classPK;
247                    }
248    
249                    _classPK = classPK;
250            }
251    
252            public long getOriginalClassPK() {
253                    return _originalClassPK;
254            }
255    
256            public double getScore() {
257                    return _score;
258            }
259    
260            public void setScore(double score) {
261                    _score = score;
262            }
263    
264            public RatingsEntry toEscapedModel() {
265                    if (isEscapedModel()) {
266                            return (RatingsEntry)this;
267                    }
268                    else {
269                            return (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
270                                    new Class[] { RatingsEntry.class },
271                                    new AutoEscapeBeanHandler(this));
272                    }
273            }
274    
275            public ExpandoBridge getExpandoBridge() {
276                    if (_expandoBridge == null) {
277                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
278                                            RatingsEntry.class.getName(), getPrimaryKey());
279                    }
280    
281                    return _expandoBridge;
282            }
283    
284            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
285                    getExpandoBridge().setAttributes(serviceContext);
286            }
287    
288            public Object clone() {
289                    RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
290    
291                    ratingsEntryImpl.setEntryId(getEntryId());
292    
293                    ratingsEntryImpl.setCompanyId(getCompanyId());
294    
295                    ratingsEntryImpl.setUserId(getUserId());
296    
297                    RatingsEntryModelImpl ratingsEntryModelImpl = ratingsEntryImpl;
298    
299                    ratingsEntryModelImpl._originalUserId = ratingsEntryModelImpl._userId;
300    
301                    ratingsEntryModelImpl._setOriginalUserId = false;
302                    ratingsEntryImpl.setUserName(getUserName());
303    
304                    ratingsEntryImpl.setCreateDate(getCreateDate());
305    
306                    ratingsEntryImpl.setModifiedDate(getModifiedDate());
307    
308                    ratingsEntryImpl.setClassNameId(getClassNameId());
309    
310                    ratingsEntryModelImpl._originalClassNameId = ratingsEntryModelImpl._classNameId;
311    
312                    ratingsEntryModelImpl._setOriginalClassNameId = false;
313                    ratingsEntryImpl.setClassPK(getClassPK());
314    
315                    ratingsEntryModelImpl._originalClassPK = ratingsEntryModelImpl._classPK;
316    
317                    ratingsEntryModelImpl._setOriginalClassPK = false;
318                    ratingsEntryImpl.setScore(getScore());
319    
320                    return ratingsEntryImpl;
321            }
322    
323            public int compareTo(RatingsEntry ratingsEntry) {
324                    long pk = ratingsEntry.getPrimaryKey();
325    
326                    if (getPrimaryKey() < pk) {
327                            return -1;
328                    }
329                    else if (getPrimaryKey() > pk) {
330                            return 1;
331                    }
332                    else {
333                            return 0;
334                    }
335            }
336    
337            public boolean equals(Object obj) {
338                    if (obj == null) {
339                            return false;
340                    }
341    
342                    RatingsEntry ratingsEntry = null;
343    
344                    try {
345                            ratingsEntry = (RatingsEntry)obj;
346                    }
347                    catch (ClassCastException cce) {
348                            return false;
349                    }
350    
351                    long pk = ratingsEntry.getPrimaryKey();
352    
353                    if (getPrimaryKey() == pk) {
354                            return true;
355                    }
356                    else {
357                            return false;
358                    }
359            }
360    
361            public int hashCode() {
362                    return (int)getPrimaryKey();
363            }
364    
365            public String toString() {
366                    StringBundler sb = new StringBundler(19);
367    
368                    sb.append("{entryId=");
369                    sb.append(getEntryId());
370                    sb.append(", companyId=");
371                    sb.append(getCompanyId());
372                    sb.append(", userId=");
373                    sb.append(getUserId());
374                    sb.append(", userName=");
375                    sb.append(getUserName());
376                    sb.append(", createDate=");
377                    sb.append(getCreateDate());
378                    sb.append(", modifiedDate=");
379                    sb.append(getModifiedDate());
380                    sb.append(", classNameId=");
381                    sb.append(getClassNameId());
382                    sb.append(", classPK=");
383                    sb.append(getClassPK());
384                    sb.append(", score=");
385                    sb.append(getScore());
386                    sb.append("}");
387    
388                    return sb.toString();
389            }
390    
391            public String toXmlString() {
392                    StringBundler sb = new StringBundler(31);
393    
394                    sb.append("<model><model-name>");
395                    sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
396                    sb.append("</model-name>");
397    
398                    sb.append(
399                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
400                    sb.append(getEntryId());
401                    sb.append("]]></column-value></column>");
402                    sb.append(
403                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
404                    sb.append(getCompanyId());
405                    sb.append("]]></column-value></column>");
406                    sb.append(
407                            "<column><column-name>userId</column-name><column-value><![CDATA[");
408                    sb.append(getUserId());
409                    sb.append("]]></column-value></column>");
410                    sb.append(
411                            "<column><column-name>userName</column-name><column-value><![CDATA[");
412                    sb.append(getUserName());
413                    sb.append("]]></column-value></column>");
414                    sb.append(
415                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
416                    sb.append(getCreateDate());
417                    sb.append("]]></column-value></column>");
418                    sb.append(
419                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
420                    sb.append(getModifiedDate());
421                    sb.append("]]></column-value></column>");
422                    sb.append(
423                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
424                    sb.append(getClassNameId());
425                    sb.append("]]></column-value></column>");
426                    sb.append(
427                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
428                    sb.append(getClassPK());
429                    sb.append("]]></column-value></column>");
430                    sb.append(
431                            "<column><column-name>score</column-name><column-value><![CDATA[");
432                    sb.append(getScore());
433                    sb.append("]]></column-value></column>");
434    
435                    sb.append("</model>");
436    
437                    return sb.toString();
438            }
439    
440            private long _entryId;
441            private long _companyId;
442            private long _userId;
443            private String _userUuid;
444            private long _originalUserId;
445            private boolean _setOriginalUserId;
446            private String _userName;
447            private Date _createDate;
448            private Date _modifiedDate;
449            private long _classNameId;
450            private long _originalClassNameId;
451            private boolean _setOriginalClassNameId;
452            private long _classPK;
453            private long _originalClassPK;
454            private boolean _setOriginalClassPK;
455            private double _score;
456            private transient ExpandoBridge _expandoBridge;
457    }