001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.ratings.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.impl.BaseModelImpl;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.portlet.ratings.model.RatingsStats;
029:
030: import java.io.Serializable;
031:
032: import java.lang.reflect.Proxy;
033:
034: import java.sql.Types;
035:
036: /**
037: * <a href="RatingsStatsModelImpl.java.html"><b><i>View Source</i></b></a>
038: *
039: * <p>
040: * ServiceBuilder generated this class. Modifications in this class will be
041: * overwritten the next time is generated.
042: * </p>
043: *
044: * <p>
045: * This class is a model that represents the <code>RatingsStats</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portlet.ratings.service.model.RatingsStats
052: * @see com.liferay.portlet.ratings.service.model.RatingsStatsModel
053: * @see com.liferay.portlet.ratings.service.model.impl.RatingsStatsImpl
054: *
055: */
056: public class RatingsStatsModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "RatingsStats";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "statsId", new Integer(Types.BIGINT) },
060:
061: { "classNameId", new Integer(Types.BIGINT) },
062:
063: { "classPK", new Integer(Types.BIGINT) },
064:
065: { "totalEntries", new Integer(Types.INTEGER) },
066:
067: { "totalScore", new Integer(Types.DOUBLE) },
068:
069: { "averageScore", new Integer(Types.DOUBLE) } };
070: 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)";
071: public static final String TABLE_SQL_DROP = "drop table RatingsStats";
072: public static final boolean CACHE_ENABLED = GetterUtil
073: .getBoolean(
074: PropsUtil
075: .get("value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
076: true);
077: public static final long LOCK_EXPIRATION_TIME = GetterUtil
078: .getLong(PropsUtil
079: .get("lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
080:
081: public RatingsStatsModelImpl() {
082: }
083:
084: public long getPrimaryKey() {
085: return _statsId;
086: }
087:
088: public void setPrimaryKey(long pk) {
089: setStatsId(pk);
090: }
091:
092: public Serializable getPrimaryKeyObj() {
093: return new Long(_statsId);
094: }
095:
096: public long getStatsId() {
097: return _statsId;
098: }
099:
100: public void setStatsId(long statsId) {
101: if (statsId != _statsId) {
102: _statsId = statsId;
103: }
104: }
105:
106: public long getClassNameId() {
107: return _classNameId;
108: }
109:
110: public void setClassNameId(long classNameId) {
111: if (classNameId != _classNameId) {
112: _classNameId = classNameId;
113: }
114: }
115:
116: public long getClassPK() {
117: return _classPK;
118: }
119:
120: public void setClassPK(long classPK) {
121: if (classPK != _classPK) {
122: _classPK = classPK;
123: }
124: }
125:
126: public int getTotalEntries() {
127: return _totalEntries;
128: }
129:
130: public void setTotalEntries(int totalEntries) {
131: if (totalEntries != _totalEntries) {
132: _totalEntries = totalEntries;
133: }
134: }
135:
136: public double getTotalScore() {
137: return _totalScore;
138: }
139:
140: public void setTotalScore(double totalScore) {
141: if (totalScore != _totalScore) {
142: _totalScore = totalScore;
143: }
144: }
145:
146: public double getAverageScore() {
147: return _averageScore;
148: }
149:
150: public void setAverageScore(double averageScore) {
151: if (averageScore != _averageScore) {
152: _averageScore = averageScore;
153: }
154: }
155:
156: public RatingsStats toEscapedModel() {
157: if (isEscapedModel()) {
158: return (RatingsStats) this ;
159: } else {
160: RatingsStats model = new RatingsStatsImpl();
161:
162: model.setEscapedModel(true);
163:
164: model.setStatsId(getStatsId());
165: model.setClassNameId(getClassNameId());
166: model.setClassPK(getClassPK());
167: model.setTotalEntries(getTotalEntries());
168: model.setTotalScore(getTotalScore());
169: model.setAverageScore(getAverageScore());
170:
171: model = (RatingsStats) Proxy.newProxyInstance(
172: RatingsStats.class.getClassLoader(),
173: new Class[] { RatingsStats.class },
174: new ReadOnlyBeanHandler(model));
175:
176: return model;
177: }
178: }
179:
180: public Object clone() {
181: RatingsStatsImpl clone = new RatingsStatsImpl();
182:
183: clone.setStatsId(getStatsId());
184: clone.setClassNameId(getClassNameId());
185: clone.setClassPK(getClassPK());
186: clone.setTotalEntries(getTotalEntries());
187: clone.setTotalScore(getTotalScore());
188: clone.setAverageScore(getAverageScore());
189:
190: return clone;
191: }
192:
193: public int compareTo(Object obj) {
194: if (obj == null) {
195: return -1;
196: }
197:
198: RatingsStatsImpl ratingsStats = (RatingsStatsImpl) obj;
199:
200: long pk = ratingsStats.getPrimaryKey();
201:
202: if (getPrimaryKey() < pk) {
203: return -1;
204: } else if (getPrimaryKey() > pk) {
205: return 1;
206: } else {
207: return 0;
208: }
209: }
210:
211: public boolean equals(Object obj) {
212: if (obj == null) {
213: return false;
214: }
215:
216: RatingsStatsImpl ratingsStats = null;
217:
218: try {
219: ratingsStats = (RatingsStatsImpl) obj;
220: } catch (ClassCastException cce) {
221: return false;
222: }
223:
224: long pk = ratingsStats.getPrimaryKey();
225:
226: if (getPrimaryKey() == pk) {
227: return true;
228: } else {
229: return false;
230: }
231: }
232:
233: public int hashCode() {
234: return (int) getPrimaryKey();
235: }
236:
237: private long _statsId;
238: private long _classNameId;
239: private long _classPK;
240: private int _totalEntries;
241: private double _totalScore;
242: private double _averageScore;
243: }
|