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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    import com.liferay.portal.util.PortalUtil;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    import com.liferay.portlet.ratings.model.RatingsStats;
028    import com.liferay.portlet.ratings.model.RatingsStatsModel;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    /**
037     * The base model implementation for the RatingsStats service. Represents a row in the "RatingsStats" database table, with each column mapped to a property of this class.
038     *
039     * <p>
040     * This implementation and its corresponding interface {@link com.liferay.portlet.ratings.model.RatingsStatsModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link RatingsStatsImpl}.
041     * </p>
042     *
043     * <p>
044     * Never modify or reference this class directly. All methods that expect a ratings stats model instance should use the {@link com.liferay.portlet.ratings.model.RatingsStats} interface instead.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see RatingsStatsImpl
049     * @see com.liferay.portlet.ratings.model.RatingsStats
050     * @see com.liferay.portlet.ratings.model.RatingsStatsModel
051     * @generated
052     */
053    public class RatingsStatsModelImpl extends BaseModelImpl<RatingsStats>
054            implements RatingsStatsModel {
055            public static final String TABLE_NAME = "RatingsStats";
056            public static final Object[][] TABLE_COLUMNS = {
057                            { "statsId", new Integer(Types.BIGINT) },
058                            { "classNameId", new Integer(Types.BIGINT) },
059                            { "classPK", new Integer(Types.BIGINT) },
060                            { "totalEntries", new Integer(Types.INTEGER) },
061                            { "totalScore", new Integer(Types.DOUBLE) },
062                            { "averageScore", new Integer(Types.DOUBLE) }
063                    };
064            public static final String TABLE_SQL_CREATE = "create table RatingsStats (statsId LONG not null primary key,classNameId LONG,classPK LONG,totalEntries INTEGER,totalScore DOUBLE,averageScore DOUBLE)";
065            public static final String TABLE_SQL_DROP = "drop table RatingsStats";
066            public static final String DATA_SOURCE = "liferayDataSource";
067            public static final String SESSION_FACTORY = "liferaySessionFactory";
068            public static final String TX_MANAGER = "liferayTransactionManager";
069            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
071                            true);
072            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
074                            true);
075            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
076                                    "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
077    
078            public RatingsStatsModelImpl() {
079            }
080    
081            public long getPrimaryKey() {
082                    return _statsId;
083            }
084    
085            public void setPrimaryKey(long pk) {
086                    setStatsId(pk);
087            }
088    
089            public Serializable getPrimaryKeyObj() {
090                    return new Long(_statsId);
091            }
092    
093            public long getStatsId() {
094                    return _statsId;
095            }
096    
097            public void setStatsId(long statsId) {
098                    _statsId = statsId;
099            }
100    
101            public String getClassName() {
102                    if (getClassNameId() <= 0) {
103                            return StringPool.BLANK;
104                    }
105    
106                    return PortalUtil.getClassName(getClassNameId());
107            }
108    
109            public long getClassNameId() {
110                    return _classNameId;
111            }
112    
113            public void setClassNameId(long classNameId) {
114                    if (!_setOriginalClassNameId) {
115                            _setOriginalClassNameId = true;
116    
117                            _originalClassNameId = _classNameId;
118                    }
119    
120                    _classNameId = classNameId;
121            }
122    
123            public long getOriginalClassNameId() {
124                    return _originalClassNameId;
125            }
126    
127            public long getClassPK() {
128                    return _classPK;
129            }
130    
131            public void setClassPK(long classPK) {
132                    if (!_setOriginalClassPK) {
133                            _setOriginalClassPK = true;
134    
135                            _originalClassPK = _classPK;
136                    }
137    
138                    _classPK = classPK;
139            }
140    
141            public long getOriginalClassPK() {
142                    return _originalClassPK;
143            }
144    
145            public int getTotalEntries() {
146                    return _totalEntries;
147            }
148    
149            public void setTotalEntries(int totalEntries) {
150                    _totalEntries = totalEntries;
151            }
152    
153            public double getTotalScore() {
154                    return _totalScore;
155            }
156    
157            public void setTotalScore(double totalScore) {
158                    _totalScore = totalScore;
159            }
160    
161            public double getAverageScore() {
162                    return _averageScore;
163            }
164    
165            public void setAverageScore(double averageScore) {
166                    _averageScore = averageScore;
167            }
168    
169            public RatingsStats toEscapedModel() {
170                    if (isEscapedModel()) {
171                            return (RatingsStats)this;
172                    }
173                    else {
174                            return (RatingsStats)Proxy.newProxyInstance(RatingsStats.class.getClassLoader(),
175                                    new Class[] { RatingsStats.class },
176                                    new AutoEscapeBeanHandler(this));
177                    }
178            }
179    
180            public ExpandoBridge getExpandoBridge() {
181                    if (_expandoBridge == null) {
182                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
183                                            RatingsStats.class.getName(), getPrimaryKey());
184                    }
185    
186                    return _expandoBridge;
187            }
188    
189            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
190                    getExpandoBridge().setAttributes(serviceContext);
191            }
192    
193            public Object clone() {
194                    RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
195    
196                    ratingsStatsImpl.setStatsId(getStatsId());
197    
198                    ratingsStatsImpl.setClassNameId(getClassNameId());
199    
200                    RatingsStatsModelImpl ratingsStatsModelImpl = ratingsStatsImpl;
201    
202                    ratingsStatsModelImpl._originalClassNameId = ratingsStatsModelImpl._classNameId;
203    
204                    ratingsStatsModelImpl._setOriginalClassNameId = false;
205                    ratingsStatsImpl.setClassPK(getClassPK());
206    
207                    ratingsStatsModelImpl._originalClassPK = ratingsStatsModelImpl._classPK;
208    
209                    ratingsStatsModelImpl._setOriginalClassPK = false;
210                    ratingsStatsImpl.setTotalEntries(getTotalEntries());
211    
212                    ratingsStatsImpl.setTotalScore(getTotalScore());
213    
214                    ratingsStatsImpl.setAverageScore(getAverageScore());
215    
216                    return ratingsStatsImpl;
217            }
218    
219            public int compareTo(RatingsStats ratingsStats) {
220                    long pk = ratingsStats.getPrimaryKey();
221    
222                    if (getPrimaryKey() < pk) {
223                            return -1;
224                    }
225                    else if (getPrimaryKey() > pk) {
226                            return 1;
227                    }
228                    else {
229                            return 0;
230                    }
231            }
232    
233            public boolean equals(Object obj) {
234                    if (obj == null) {
235                            return false;
236                    }
237    
238                    RatingsStats ratingsStats = null;
239    
240                    try {
241                            ratingsStats = (RatingsStats)obj;
242                    }
243                    catch (ClassCastException cce) {
244                            return false;
245                    }
246    
247                    long pk = ratingsStats.getPrimaryKey();
248    
249                    if (getPrimaryKey() == pk) {
250                            return true;
251                    }
252                    else {
253                            return false;
254                    }
255            }
256    
257            public int hashCode() {
258                    return (int)getPrimaryKey();
259            }
260    
261            public String toString() {
262                    StringBundler sb = new StringBundler(13);
263    
264                    sb.append("{statsId=");
265                    sb.append(getStatsId());
266                    sb.append(", classNameId=");
267                    sb.append(getClassNameId());
268                    sb.append(", classPK=");
269                    sb.append(getClassPK());
270                    sb.append(", totalEntries=");
271                    sb.append(getTotalEntries());
272                    sb.append(", totalScore=");
273                    sb.append(getTotalScore());
274                    sb.append(", averageScore=");
275                    sb.append(getAverageScore());
276                    sb.append("}");
277    
278                    return sb.toString();
279            }
280    
281            public String toXmlString() {
282                    StringBundler sb = new StringBundler(22);
283    
284                    sb.append("<model><model-name>");
285                    sb.append("com.liferay.portlet.ratings.model.RatingsStats");
286                    sb.append("</model-name>");
287    
288                    sb.append(
289                            "<column><column-name>statsId</column-name><column-value><![CDATA[");
290                    sb.append(getStatsId());
291                    sb.append("]]></column-value></column>");
292                    sb.append(
293                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
294                    sb.append(getClassNameId());
295                    sb.append("]]></column-value></column>");
296                    sb.append(
297                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
298                    sb.append(getClassPK());
299                    sb.append("]]></column-value></column>");
300                    sb.append(
301                            "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
302                    sb.append(getTotalEntries());
303                    sb.append("]]></column-value></column>");
304                    sb.append(
305                            "<column><column-name>totalScore</column-name><column-value><![CDATA[");
306                    sb.append(getTotalScore());
307                    sb.append("]]></column-value></column>");
308                    sb.append(
309                            "<column><column-name>averageScore</column-name><column-value><![CDATA[");
310                    sb.append(getAverageScore());
311                    sb.append("]]></column-value></column>");
312    
313                    sb.append("</model>");
314    
315                    return sb.toString();
316            }
317    
318            private long _statsId;
319            private long _classNameId;
320            private long _originalClassNameId;
321            private boolean _setOriginalClassNameId;
322            private long _classPK;
323            private long _originalClassPK;
324            private boolean _setOriginalClassPK;
325            private int _totalEntries;
326            private double _totalScore;
327            private double _averageScore;
328            private transient ExpandoBridge _expandoBridge;
329    }