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.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                    _userId = userId;
163    
164                    if (!_setOriginalUserId) {
165                            _setOriginalUserId = true;
166    
167                            _originalUserId = userId;
168                    }
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                    _classNameId = classNameId;
226    
227                    if (!_setOriginalClassNameId) {
228                            _setOriginalClassNameId = true;
229    
230                            _originalClassNameId = classNameId;
231                    }
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                    _classPK = classPK;
244    
245                    if (!_setOriginalClassPK) {
246                            _setOriginalClassPK = true;
247    
248                            _originalClassPK = classPK;
249                    }
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 clone = new RatingsEntryImpl();
290    
291                    clone.setEntryId(getEntryId());
292                    clone.setCompanyId(getCompanyId());
293                    clone.setUserId(getUserId());
294                    clone.setUserName(getUserName());
295                    clone.setCreateDate(getCreateDate());
296                    clone.setModifiedDate(getModifiedDate());
297                    clone.setClassNameId(getClassNameId());
298                    clone.setClassPK(getClassPK());
299                    clone.setScore(getScore());
300    
301                    return clone;
302            }
303    
304            public int compareTo(RatingsEntry ratingsEntry) {
305                    long pk = ratingsEntry.getPrimaryKey();
306    
307                    if (getPrimaryKey() < pk) {
308                            return -1;
309                    }
310                    else if (getPrimaryKey() > pk) {
311                            return 1;
312                    }
313                    else {
314                            return 0;
315                    }
316            }
317    
318            public boolean equals(Object obj) {
319                    if (obj == null) {
320                            return false;
321                    }
322    
323                    RatingsEntry ratingsEntry = null;
324    
325                    try {
326                            ratingsEntry = (RatingsEntry)obj;
327                    }
328                    catch (ClassCastException cce) {
329                            return false;
330                    }
331    
332                    long pk = ratingsEntry.getPrimaryKey();
333    
334                    if (getPrimaryKey() == pk) {
335                            return true;
336                    }
337                    else {
338                            return false;
339                    }
340            }
341    
342            public int hashCode() {
343                    return (int)getPrimaryKey();
344            }
345    
346            public String toString() {
347                    StringBundler sb = new StringBundler(19);
348    
349                    sb.append("{entryId=");
350                    sb.append(getEntryId());
351                    sb.append(", companyId=");
352                    sb.append(getCompanyId());
353                    sb.append(", userId=");
354                    sb.append(getUserId());
355                    sb.append(", userName=");
356                    sb.append(getUserName());
357                    sb.append(", createDate=");
358                    sb.append(getCreateDate());
359                    sb.append(", modifiedDate=");
360                    sb.append(getModifiedDate());
361                    sb.append(", classNameId=");
362                    sb.append(getClassNameId());
363                    sb.append(", classPK=");
364                    sb.append(getClassPK());
365                    sb.append(", score=");
366                    sb.append(getScore());
367                    sb.append("}");
368    
369                    return sb.toString();
370            }
371    
372            public String toXmlString() {
373                    StringBundler sb = new StringBundler(31);
374    
375                    sb.append("<model><model-name>");
376                    sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
377                    sb.append("</model-name>");
378    
379                    sb.append(
380                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
381                    sb.append(getEntryId());
382                    sb.append("]]></column-value></column>");
383                    sb.append(
384                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
385                    sb.append(getCompanyId());
386                    sb.append("]]></column-value></column>");
387                    sb.append(
388                            "<column><column-name>userId</column-name><column-value><![CDATA[");
389                    sb.append(getUserId());
390                    sb.append("]]></column-value></column>");
391                    sb.append(
392                            "<column><column-name>userName</column-name><column-value><![CDATA[");
393                    sb.append(getUserName());
394                    sb.append("]]></column-value></column>");
395                    sb.append(
396                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
397                    sb.append(getCreateDate());
398                    sb.append("]]></column-value></column>");
399                    sb.append(
400                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
401                    sb.append(getModifiedDate());
402                    sb.append("]]></column-value></column>");
403                    sb.append(
404                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
405                    sb.append(getClassNameId());
406                    sb.append("]]></column-value></column>");
407                    sb.append(
408                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
409                    sb.append(getClassPK());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>score</column-name><column-value><![CDATA[");
413                    sb.append(getScore());
414                    sb.append("]]></column-value></column>");
415    
416                    sb.append("</model>");
417    
418                    return sb.toString();
419            }
420    
421            private long _entryId;
422            private long _companyId;
423            private long _userId;
424            private String _userUuid;
425            private long _originalUserId;
426            private boolean _setOriginalUserId;
427            private String _userName;
428            private Date _createDate;
429            private Date _modifiedDate;
430            private long _classNameId;
431            private long _originalClassNameId;
432            private boolean _setOriginalClassNameId;
433            private long _classPK;
434            private long _originalClassPK;
435            private boolean _setOriginalClassPK;
436            private double _score;
437            private transient ExpandoBridge _expandoBridge;
438    }