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