001
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.ProxyUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.kernel.util.Validator;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.impl.BaseModelImpl;
025 import com.liferay.portal.service.ServiceContext;
026 import com.liferay.portal.util.PortalUtil;
027
028 import com.liferay.portlet.expando.model.ExpandoBridge;
029 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030 import com.liferay.portlet.ratings.model.RatingsStats;
031 import com.liferay.portlet.ratings.model.RatingsStatsModel;
032
033 import java.io.Serializable;
034
035 import java.sql.Types;
036
037 import java.util.HashMap;
038 import java.util.Map;
039
040
053 public class RatingsStatsModelImpl extends BaseModelImpl<RatingsStats>
054 implements RatingsStatsModel {
055
060 public static final String TABLE_NAME = "RatingsStats";
061 public static final Object[][] TABLE_COLUMNS = {
062 { "statsId", Types.BIGINT },
063 { "classNameId", Types.BIGINT },
064 { "classPK", Types.BIGINT },
065 { "totalEntries", Types.INTEGER },
066 { "totalScore", Types.DOUBLE },
067 { "averageScore", Types.DOUBLE }
068 };
069 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)";
070 public static final String TABLE_SQL_DROP = "drop table RatingsStats";
071 public static final String DATA_SOURCE = "liferayDataSource";
072 public static final String SESSION_FACTORY = "liferaySessionFactory";
073 public static final String TX_MANAGER = "liferayTransactionManager";
074 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075 "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
076 true);
077 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078 "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
079 true);
080 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081 "value.object.column.bitmask.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
082 true);
083 public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
084 public static long CLASSPK_COLUMN_BITMASK = 2L;
085 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
086 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
087
088 public RatingsStatsModelImpl() {
089 }
090
091 public long getPrimaryKey() {
092 return _statsId;
093 }
094
095 public void setPrimaryKey(long primaryKey) {
096 setStatsId(primaryKey);
097 }
098
099 public Serializable getPrimaryKeyObj() {
100 return new Long(_statsId);
101 }
102
103 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
104 setPrimaryKey(((Long)primaryKeyObj).longValue());
105 }
106
107 public Class<?> getModelClass() {
108 return RatingsStats.class;
109 }
110
111 public String getModelClassName() {
112 return RatingsStats.class.getName();
113 }
114
115 @Override
116 public Map<String, Object> getModelAttributes() {
117 Map<String, Object> attributes = new HashMap<String, Object>();
118
119 attributes.put("statsId", getStatsId());
120 attributes.put("classNameId", getClassNameId());
121 attributes.put("classPK", getClassPK());
122 attributes.put("totalEntries", getTotalEntries());
123 attributes.put("totalScore", getTotalScore());
124 attributes.put("averageScore", getAverageScore());
125
126 return attributes;
127 }
128
129 @Override
130 public void setModelAttributes(Map<String, Object> attributes) {
131 Long statsId = (Long)attributes.get("statsId");
132
133 if (statsId != null) {
134 setStatsId(statsId);
135 }
136
137 Long classNameId = (Long)attributes.get("classNameId");
138
139 if (classNameId != null) {
140 setClassNameId(classNameId);
141 }
142
143 Long classPK = (Long)attributes.get("classPK");
144
145 if (classPK != null) {
146 setClassPK(classPK);
147 }
148
149 Integer totalEntries = (Integer)attributes.get("totalEntries");
150
151 if (totalEntries != null) {
152 setTotalEntries(totalEntries);
153 }
154
155 Double totalScore = (Double)attributes.get("totalScore");
156
157 if (totalScore != null) {
158 setTotalScore(totalScore);
159 }
160
161 Double averageScore = (Double)attributes.get("averageScore");
162
163 if (averageScore != null) {
164 setAverageScore(averageScore);
165 }
166 }
167
168 public long getStatsId() {
169 return _statsId;
170 }
171
172 public void setStatsId(long statsId) {
173 _statsId = statsId;
174 }
175
176 public String getClassName() {
177 if (getClassNameId() <= 0) {
178 return StringPool.BLANK;
179 }
180
181 return PortalUtil.getClassName(getClassNameId());
182 }
183
184 public void setClassName(String className) {
185 long classNameId = 0;
186
187 if (Validator.isNotNull(className)) {
188 classNameId = PortalUtil.getClassNameId(className);
189 }
190
191 setClassNameId(classNameId);
192 }
193
194 public long getClassNameId() {
195 return _classNameId;
196 }
197
198 public void setClassNameId(long classNameId) {
199 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
200
201 if (!_setOriginalClassNameId) {
202 _setOriginalClassNameId = true;
203
204 _originalClassNameId = _classNameId;
205 }
206
207 _classNameId = classNameId;
208 }
209
210 public long getOriginalClassNameId() {
211 return _originalClassNameId;
212 }
213
214 public long getClassPK() {
215 return _classPK;
216 }
217
218 public void setClassPK(long classPK) {
219 _columnBitmask |= CLASSPK_COLUMN_BITMASK;
220
221 if (!_setOriginalClassPK) {
222 _setOriginalClassPK = true;
223
224 _originalClassPK = _classPK;
225 }
226
227 _classPK = classPK;
228 }
229
230 public long getOriginalClassPK() {
231 return _originalClassPK;
232 }
233
234 public int getTotalEntries() {
235 return _totalEntries;
236 }
237
238 public void setTotalEntries(int totalEntries) {
239 _totalEntries = totalEntries;
240 }
241
242 public double getTotalScore() {
243 return _totalScore;
244 }
245
246 public void setTotalScore(double totalScore) {
247 _totalScore = totalScore;
248 }
249
250 public double getAverageScore() {
251 return _averageScore;
252 }
253
254 public void setAverageScore(double averageScore) {
255 _averageScore = averageScore;
256 }
257
258 public long getColumnBitmask() {
259 return _columnBitmask;
260 }
261
262 @Override
263 public ExpandoBridge getExpandoBridge() {
264 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
265 RatingsStats.class.getName(), getPrimaryKey());
266 }
267
268 @Override
269 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
270 ExpandoBridge expandoBridge = getExpandoBridge();
271
272 expandoBridge.setAttributes(serviceContext);
273 }
274
275 @Override
276 public RatingsStats toEscapedModel() {
277 if (_escapedModel == null) {
278 _escapedModel = (RatingsStats)ProxyUtil.newProxyInstance(_classLoader,
279 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
280 }
281
282 return _escapedModel;
283 }
284
285 public RatingsStats toUnescapedModel() {
286 return (RatingsStats)this;
287 }
288
289 @Override
290 public Object clone() {
291 RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
292
293 ratingsStatsImpl.setStatsId(getStatsId());
294 ratingsStatsImpl.setClassNameId(getClassNameId());
295 ratingsStatsImpl.setClassPK(getClassPK());
296 ratingsStatsImpl.setTotalEntries(getTotalEntries());
297 ratingsStatsImpl.setTotalScore(getTotalScore());
298 ratingsStatsImpl.setAverageScore(getAverageScore());
299
300 ratingsStatsImpl.resetOriginalValues();
301
302 return ratingsStatsImpl;
303 }
304
305 public int compareTo(RatingsStats ratingsStats) {
306 long primaryKey = ratingsStats.getPrimaryKey();
307
308 if (getPrimaryKey() < primaryKey) {
309 return -1;
310 }
311 else if (getPrimaryKey() > primaryKey) {
312 return 1;
313 }
314 else {
315 return 0;
316 }
317 }
318
319 @Override
320 public boolean equals(Object obj) {
321 if (this == obj) {
322 return true;
323 }
324
325 if (!(obj instanceof RatingsStats)) {
326 return false;
327 }
328
329 RatingsStats ratingsStats = (RatingsStats)obj;
330
331 long primaryKey = ratingsStats.getPrimaryKey();
332
333 if (getPrimaryKey() == primaryKey) {
334 return true;
335 }
336 else {
337 return false;
338 }
339 }
340
341 @Override
342 public int hashCode() {
343 return (int)getPrimaryKey();
344 }
345
346 @Override
347 public void resetOriginalValues() {
348 RatingsStatsModelImpl ratingsStatsModelImpl = this;
349
350 ratingsStatsModelImpl._originalClassNameId = ratingsStatsModelImpl._classNameId;
351
352 ratingsStatsModelImpl._setOriginalClassNameId = false;
353
354 ratingsStatsModelImpl._originalClassPK = ratingsStatsModelImpl._classPK;
355
356 ratingsStatsModelImpl._setOriginalClassPK = false;
357
358 ratingsStatsModelImpl._columnBitmask = 0;
359 }
360
361 @Override
362 public CacheModel<RatingsStats> toCacheModel() {
363 RatingsStatsCacheModel ratingsStatsCacheModel = new RatingsStatsCacheModel();
364
365 ratingsStatsCacheModel.statsId = getStatsId();
366
367 ratingsStatsCacheModel.classNameId = getClassNameId();
368
369 ratingsStatsCacheModel.classPK = getClassPK();
370
371 ratingsStatsCacheModel.totalEntries = getTotalEntries();
372
373 ratingsStatsCacheModel.totalScore = getTotalScore();
374
375 ratingsStatsCacheModel.averageScore = getAverageScore();
376
377 return ratingsStatsCacheModel;
378 }
379
380 @Override
381 public String toString() {
382 StringBundler sb = new StringBundler(13);
383
384 sb.append("{statsId=");
385 sb.append(getStatsId());
386 sb.append(", classNameId=");
387 sb.append(getClassNameId());
388 sb.append(", classPK=");
389 sb.append(getClassPK());
390 sb.append(", totalEntries=");
391 sb.append(getTotalEntries());
392 sb.append(", totalScore=");
393 sb.append(getTotalScore());
394 sb.append(", averageScore=");
395 sb.append(getAverageScore());
396 sb.append("}");
397
398 return sb.toString();
399 }
400
401 public String toXmlString() {
402 StringBundler sb = new StringBundler(22);
403
404 sb.append("<model><model-name>");
405 sb.append("com.liferay.portlet.ratings.model.RatingsStats");
406 sb.append("</model-name>");
407
408 sb.append(
409 "<column><column-name>statsId</column-name><column-value><![CDATA[");
410 sb.append(getStatsId());
411 sb.append("]]></column-value></column>");
412 sb.append(
413 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
414 sb.append(getClassNameId());
415 sb.append("]]></column-value></column>");
416 sb.append(
417 "<column><column-name>classPK</column-name><column-value><![CDATA[");
418 sb.append(getClassPK());
419 sb.append("]]></column-value></column>");
420 sb.append(
421 "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
422 sb.append(getTotalEntries());
423 sb.append("]]></column-value></column>");
424 sb.append(
425 "<column><column-name>totalScore</column-name><column-value><![CDATA[");
426 sb.append(getTotalScore());
427 sb.append("]]></column-value></column>");
428 sb.append(
429 "<column><column-name>averageScore</column-name><column-value><![CDATA[");
430 sb.append(getAverageScore());
431 sb.append("]]></column-value></column>");
432
433 sb.append("</model>");
434
435 return sb.toString();
436 }
437
438 private static ClassLoader _classLoader = RatingsStats.class.getClassLoader();
439 private static Class<?>[] _escapedModelInterfaces = new Class[] {
440 RatingsStats.class
441 };
442 private long _statsId;
443 private long _classNameId;
444 private long _originalClassNameId;
445 private boolean _setOriginalClassNameId;
446 private long _classPK;
447 private long _originalClassPK;
448 private boolean _setOriginalClassPK;
449 private int _totalEntries;
450 private double _totalScore;
451 private double _averageScore;
452 private long _columnBitmask;
453 private RatingsStats _escapedModel;
454 }