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