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