1
22
23 package com.liferay.portlet.ratings.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.StringPool;
28 import com.liferay.portal.model.impl.BaseModelImpl;
29 import com.liferay.portal.util.PortalUtil;
30
31 import com.liferay.portlet.ratings.model.RatingsStats;
32 import com.liferay.portlet.ratings.model.RatingsStatsSoap;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.List;
42
43
63 public class RatingsStatsModelImpl extends BaseModelImpl {
64 public static final String TABLE_NAME = "RatingsStats";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "statsId", new Integer(Types.BIGINT) },
67
68
69 { "classNameId", new Integer(Types.BIGINT) },
70
71
72 { "classPK", new Integer(Types.BIGINT) },
73
74
75 { "totalEntries", new Integer(Types.INTEGER) },
76
77
78 { "totalScore", new Integer(Types.DOUBLE) },
79
80
81 { "averageScore", new Integer(Types.DOUBLE) }
82 };
83 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)";
84 public static final String TABLE_SQL_DROP = "drop table RatingsStats";
85 public static final String DATA_SOURCE = "liferayDataSource";
86 public static final String SESSION_FACTORY = "liferaySessionFactory";
87 public static final String TX_MANAGER = "liferayTransactionManager";
88 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89 "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
90 true);
91
92 public static RatingsStats toModel(RatingsStatsSoap soapModel) {
93 RatingsStats model = new RatingsStatsImpl();
94
95 model.setStatsId(soapModel.getStatsId());
96 model.setClassNameId(soapModel.getClassNameId());
97 model.setClassPK(soapModel.getClassPK());
98 model.setTotalEntries(soapModel.getTotalEntries());
99 model.setTotalScore(soapModel.getTotalScore());
100 model.setAverageScore(soapModel.getAverageScore());
101
102 return model;
103 }
104
105 public static List<RatingsStats> toModels(RatingsStatsSoap[] soapModels) {
106 List<RatingsStats> models = new ArrayList<RatingsStats>(soapModels.length);
107
108 for (RatingsStatsSoap soapModel : soapModels) {
109 models.add(toModel(soapModel));
110 }
111
112 return models;
113 }
114
115 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
116 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
117
118 public RatingsStatsModelImpl() {
119 }
120
121 public long getPrimaryKey() {
122 return _statsId;
123 }
124
125 public void setPrimaryKey(long pk) {
126 setStatsId(pk);
127 }
128
129 public Serializable getPrimaryKeyObj() {
130 return new Long(_statsId);
131 }
132
133 public long getStatsId() {
134 return _statsId;
135 }
136
137 public void setStatsId(long statsId) {
138 if (statsId != _statsId) {
139 _statsId = statsId;
140 }
141 }
142
143 public String getClassName() {
144 if (getClassNameId() <= 0) {
145 return StringPool.BLANK;
146 }
147
148 return PortalUtil.getClassName(getClassNameId());
149 }
150
151 public long getClassNameId() {
152 return _classNameId;
153 }
154
155 public void setClassNameId(long classNameId) {
156 if (classNameId != _classNameId) {
157 _classNameId = classNameId;
158 }
159 }
160
161 public long getClassPK() {
162 return _classPK;
163 }
164
165 public void setClassPK(long classPK) {
166 if (classPK != _classPK) {
167 _classPK = classPK;
168 }
169 }
170
171 public int getTotalEntries() {
172 return _totalEntries;
173 }
174
175 public void setTotalEntries(int totalEntries) {
176 if (totalEntries != _totalEntries) {
177 _totalEntries = totalEntries;
178 }
179 }
180
181 public double getTotalScore() {
182 return _totalScore;
183 }
184
185 public void setTotalScore(double totalScore) {
186 if (totalScore != _totalScore) {
187 _totalScore = totalScore;
188 }
189 }
190
191 public double getAverageScore() {
192 return _averageScore;
193 }
194
195 public void setAverageScore(double averageScore) {
196 if (averageScore != _averageScore) {
197 _averageScore = averageScore;
198 }
199 }
200
201 public RatingsStats toEscapedModel() {
202 if (isEscapedModel()) {
203 return (RatingsStats)this;
204 }
205 else {
206 RatingsStats model = new RatingsStatsImpl();
207
208 model.setNew(isNew());
209 model.setEscapedModel(true);
210
211 model.setStatsId(getStatsId());
212 model.setClassNameId(getClassNameId());
213 model.setClassPK(getClassPK());
214 model.setTotalEntries(getTotalEntries());
215 model.setTotalScore(getTotalScore());
216 model.setAverageScore(getAverageScore());
217
218 model = (RatingsStats)Proxy.newProxyInstance(RatingsStats.class.getClassLoader(),
219 new Class[] { RatingsStats.class },
220 new ReadOnlyBeanHandler(model));
221
222 return model;
223 }
224 }
225
226 public Object clone() {
227 RatingsStatsImpl clone = new RatingsStatsImpl();
228
229 clone.setStatsId(getStatsId());
230 clone.setClassNameId(getClassNameId());
231 clone.setClassPK(getClassPK());
232 clone.setTotalEntries(getTotalEntries());
233 clone.setTotalScore(getTotalScore());
234 clone.setAverageScore(getAverageScore());
235
236 return clone;
237 }
238
239 public int compareTo(Object obj) {
240 if (obj == null) {
241 return -1;
242 }
243
244 RatingsStatsImpl ratingsStats = (RatingsStatsImpl)obj;
245
246 long pk = ratingsStats.getPrimaryKey();
247
248 if (getPrimaryKey() < pk) {
249 return -1;
250 }
251 else if (getPrimaryKey() > pk) {
252 return 1;
253 }
254 else {
255 return 0;
256 }
257 }
258
259 public boolean equals(Object obj) {
260 if (obj == null) {
261 return false;
262 }
263
264 RatingsStatsImpl ratingsStats = null;
265
266 try {
267 ratingsStats = (RatingsStatsImpl)obj;
268 }
269 catch (ClassCastException cce) {
270 return false;
271 }
272
273 long pk = ratingsStats.getPrimaryKey();
274
275 if (getPrimaryKey() == pk) {
276 return true;
277 }
278 else {
279 return false;
280 }
281 }
282
283 public int hashCode() {
284 return (int)getPrimaryKey();
285 }
286
287 private long _statsId;
288 private long _classNameId;
289 private long _classPK;
290 private int _totalEntries;
291 private double _totalScore;
292 private double _averageScore;
293 }