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.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                    _classNameId = classNameId;
115    
116                    if (!_setOriginalClassNameId) {
117                            _setOriginalClassNameId = true;
118    
119                            _originalClassNameId = classNameId;
120                    }
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                    _classPK = classPK;
133    
134                    if (!_setOriginalClassPK) {
135                            _setOriginalClassPK = true;
136    
137                            _originalClassPK = classPK;
138                    }
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 clone = new RatingsStatsImpl();
195    
196                    clone.setStatsId(getStatsId());
197                    clone.setClassNameId(getClassNameId());
198                    clone.setClassPK(getClassPK());
199                    clone.setTotalEntries(getTotalEntries());
200                    clone.setTotalScore(getTotalScore());
201                    clone.setAverageScore(getAverageScore());
202    
203                    return clone;
204            }
205    
206            public int compareTo(RatingsStats ratingsStats) {
207                    long pk = ratingsStats.getPrimaryKey();
208    
209                    if (getPrimaryKey() < pk) {
210                            return -1;
211                    }
212                    else if (getPrimaryKey() > pk) {
213                            return 1;
214                    }
215                    else {
216                            return 0;
217                    }
218            }
219    
220            public boolean equals(Object obj) {
221                    if (obj == null) {
222                            return false;
223                    }
224    
225                    RatingsStats ratingsStats = null;
226    
227                    try {
228                            ratingsStats = (RatingsStats)obj;
229                    }
230                    catch (ClassCastException cce) {
231                            return false;
232                    }
233    
234                    long pk = ratingsStats.getPrimaryKey();
235    
236                    if (getPrimaryKey() == pk) {
237                            return true;
238                    }
239                    else {
240                            return false;
241                    }
242            }
243    
244            public int hashCode() {
245                    return (int)getPrimaryKey();
246            }
247    
248            public String toString() {
249                    StringBundler sb = new StringBundler(13);
250    
251                    sb.append("{statsId=");
252                    sb.append(getStatsId());
253                    sb.append(", classNameId=");
254                    sb.append(getClassNameId());
255                    sb.append(", classPK=");
256                    sb.append(getClassPK());
257                    sb.append(", totalEntries=");
258                    sb.append(getTotalEntries());
259                    sb.append(", totalScore=");
260                    sb.append(getTotalScore());
261                    sb.append(", averageScore=");
262                    sb.append(getAverageScore());
263                    sb.append("}");
264    
265                    return sb.toString();
266            }
267    
268            public String toXmlString() {
269                    StringBundler sb = new StringBundler(22);
270    
271                    sb.append("<model><model-name>");
272                    sb.append("com.liferay.portlet.ratings.model.RatingsStats");
273                    sb.append("</model-name>");
274    
275                    sb.append(
276                            "<column><column-name>statsId</column-name><column-value><![CDATA[");
277                    sb.append(getStatsId());
278                    sb.append("]]></column-value></column>");
279                    sb.append(
280                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
281                    sb.append(getClassNameId());
282                    sb.append("]]></column-value></column>");
283                    sb.append(
284                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
285                    sb.append(getClassPK());
286                    sb.append("]]></column-value></column>");
287                    sb.append(
288                            "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
289                    sb.append(getTotalEntries());
290                    sb.append("]]></column-value></column>");
291                    sb.append(
292                            "<column><column-name>totalScore</column-name><column-value><![CDATA[");
293                    sb.append(getTotalScore());
294                    sb.append("]]></column-value></column>");
295                    sb.append(
296                            "<column><column-name>averageScore</column-name><column-value><![CDATA[");
297                    sb.append(getAverageScore());
298                    sb.append("]]></column-value></column>");
299    
300                    sb.append("</model>");
301    
302                    return sb.toString();
303            }
304    
305            private long _statsId;
306            private long _classNameId;
307            private long _originalClassNameId;
308            private boolean _setOriginalClassNameId;
309            private long _classPK;
310            private long _originalClassPK;
311            private boolean _setOriginalClassPK;
312            private int _totalEntries;
313            private double _totalScore;
314            private double _averageScore;
315            private transient ExpandoBridge _expandoBridge;
316    }