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.HtmlUtil;
28 import com.liferay.portal.kernel.util.StringPool;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30 import com.liferay.portal.util.PortalUtil;
31
32 import com.liferay.portlet.expando.model.ExpandoBridge;
33 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
34 import com.liferay.portlet.ratings.model.RatingsEntry;
35 import com.liferay.portlet.ratings.model.RatingsEntrySoap;
36
37 import java.io.Serializable;
38
39 import java.lang.reflect.Proxy;
40
41 import java.sql.Types;
42
43 import java.util.ArrayList;
44 import java.util.Date;
45 import java.util.List;
46
47
67 public class RatingsEntryModelImpl extends BaseModelImpl {
68 public static final String TABLE_NAME = "RatingsEntry";
69 public static final Object[][] TABLE_COLUMNS = {
70 { "entryId", new Integer(Types.BIGINT) },
71
72
73 { "companyId", new Integer(Types.BIGINT) },
74
75
76 { "userId", new Integer(Types.BIGINT) },
77
78
79 { "userName", new Integer(Types.VARCHAR) },
80
81
82 { "createDate", new Integer(Types.TIMESTAMP) },
83
84
85 { "modifiedDate", new Integer(Types.TIMESTAMP) },
86
87
88 { "classNameId", new Integer(Types.BIGINT) },
89
90
91 { "classPK", new Integer(Types.BIGINT) },
92
93
94 { "score", new Integer(Types.DOUBLE) }
95 };
96 public static final String TABLE_SQL_CREATE = "create table RatingsEntry (entryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,score DOUBLE)";
97 public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
98 public static final String DATA_SOURCE = "liferayDataSource";
99 public static final String SESSION_FACTORY = "liferaySessionFactory";
100 public static final String TX_MANAGER = "liferayTransactionManager";
101 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
102 "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
103 true);
104
105 public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
106 RatingsEntry model = new RatingsEntryImpl();
107
108 model.setEntryId(soapModel.getEntryId());
109 model.setCompanyId(soapModel.getCompanyId());
110 model.setUserId(soapModel.getUserId());
111 model.setUserName(soapModel.getUserName());
112 model.setCreateDate(soapModel.getCreateDate());
113 model.setModifiedDate(soapModel.getModifiedDate());
114 model.setClassNameId(soapModel.getClassNameId());
115 model.setClassPK(soapModel.getClassPK());
116 model.setScore(soapModel.getScore());
117
118 return model;
119 }
120
121 public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
122 List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
123
124 for (RatingsEntrySoap soapModel : soapModels) {
125 models.add(toModel(soapModel));
126 }
127
128 return models;
129 }
130
131 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
132 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
133
134 public RatingsEntryModelImpl() {
135 }
136
137 public long getPrimaryKey() {
138 return _entryId;
139 }
140
141 public void setPrimaryKey(long pk) {
142 setEntryId(pk);
143 }
144
145 public Serializable getPrimaryKeyObj() {
146 return new Long(_entryId);
147 }
148
149 public long getEntryId() {
150 return _entryId;
151 }
152
153 public void setEntryId(long entryId) {
154 if (entryId != _entryId) {
155 _entryId = entryId;
156 }
157 }
158
159 public long getCompanyId() {
160 return _companyId;
161 }
162
163 public void setCompanyId(long companyId) {
164 if (companyId != _companyId) {
165 _companyId = companyId;
166 }
167 }
168
169 public long getUserId() {
170 return _userId;
171 }
172
173 public void setUserId(long userId) {
174 if (userId != _userId) {
175 _userId = userId;
176 }
177 }
178
179 public String getUserName() {
180 return GetterUtil.getString(_userName);
181 }
182
183 public void setUserName(String userName) {
184 if (((userName == null) && (_userName != null)) ||
185 ((userName != null) && (_userName == null)) ||
186 ((userName != null) && (_userName != null) &&
187 !userName.equals(_userName))) {
188 _userName = userName;
189 }
190 }
191
192 public Date getCreateDate() {
193 return _createDate;
194 }
195
196 public void setCreateDate(Date createDate) {
197 if (((createDate == null) && (_createDate != null)) ||
198 ((createDate != null) && (_createDate == null)) ||
199 ((createDate != null) && (_createDate != null) &&
200 !createDate.equals(_createDate))) {
201 _createDate = createDate;
202 }
203 }
204
205 public Date getModifiedDate() {
206 return _modifiedDate;
207 }
208
209 public void setModifiedDate(Date modifiedDate) {
210 if (((modifiedDate == null) && (_modifiedDate != null)) ||
211 ((modifiedDate != null) && (_modifiedDate == null)) ||
212 ((modifiedDate != null) && (_modifiedDate != null) &&
213 !modifiedDate.equals(_modifiedDate))) {
214 _modifiedDate = modifiedDate;
215 }
216 }
217
218 public String getClassName() {
219 if (getClassNameId() <= 0) {
220 return StringPool.BLANK;
221 }
222
223 return PortalUtil.getClassName(getClassNameId());
224 }
225
226 public long getClassNameId() {
227 return _classNameId;
228 }
229
230 public void setClassNameId(long classNameId) {
231 if (classNameId != _classNameId) {
232 _classNameId = classNameId;
233 }
234 }
235
236 public long getClassPK() {
237 return _classPK;
238 }
239
240 public void setClassPK(long classPK) {
241 if (classPK != _classPK) {
242 _classPK = classPK;
243 }
244 }
245
246 public double getScore() {
247 return _score;
248 }
249
250 public void setScore(double score) {
251 if (score != _score) {
252 _score = score;
253 }
254 }
255
256 public RatingsEntry toEscapedModel() {
257 if (isEscapedModel()) {
258 return (RatingsEntry)this;
259 }
260 else {
261 RatingsEntry model = new RatingsEntryImpl();
262
263 model.setNew(isNew());
264 model.setEscapedModel(true);
265
266 model.setEntryId(getEntryId());
267 model.setCompanyId(getCompanyId());
268 model.setUserId(getUserId());
269 model.setUserName(HtmlUtil.escape(getUserName()));
270 model.setCreateDate(getCreateDate());
271 model.setModifiedDate(getModifiedDate());
272 model.setClassNameId(getClassNameId());
273 model.setClassPK(getClassPK());
274 model.setScore(getScore());
275
276 model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
277 new Class[] { RatingsEntry.class },
278 new ReadOnlyBeanHandler(model));
279
280 return model;
281 }
282 }
283
284 public ExpandoBridge getExpandoBridge() {
285 if (_expandoBridge == null) {
286 _expandoBridge = new ExpandoBridgeImpl(RatingsEntry.class.getName(),
287 getPrimaryKey());
288 }
289
290 return _expandoBridge;
291 }
292
293 public Object clone() {
294 RatingsEntryImpl clone = new RatingsEntryImpl();
295
296 clone.setEntryId(getEntryId());
297 clone.setCompanyId(getCompanyId());
298 clone.setUserId(getUserId());
299 clone.setUserName(getUserName());
300 clone.setCreateDate(getCreateDate());
301 clone.setModifiedDate(getModifiedDate());
302 clone.setClassNameId(getClassNameId());
303 clone.setClassPK(getClassPK());
304 clone.setScore(getScore());
305
306 return clone;
307 }
308
309 public int compareTo(Object obj) {
310 if (obj == null) {
311 return -1;
312 }
313
314 RatingsEntryImpl ratingsEntry = (RatingsEntryImpl)obj;
315
316 long pk = ratingsEntry.getPrimaryKey();
317
318 if (getPrimaryKey() < pk) {
319 return -1;
320 }
321 else if (getPrimaryKey() > pk) {
322 return 1;
323 }
324 else {
325 return 0;
326 }
327 }
328
329 public boolean equals(Object obj) {
330 if (obj == null) {
331 return false;
332 }
333
334 RatingsEntryImpl ratingsEntry = null;
335
336 try {
337 ratingsEntry = (RatingsEntryImpl)obj;
338 }
339 catch (ClassCastException cce) {
340 return false;
341 }
342
343 long pk = ratingsEntry.getPrimaryKey();
344
345 if (getPrimaryKey() == pk) {
346 return true;
347 }
348 else {
349 return false;
350 }
351 }
352
353 public int hashCode() {
354 return (int)getPrimaryKey();
355 }
356
357 private long _entryId;
358 private long _companyId;
359 private long _userId;
360 private String _userName;
361 private Date _createDate;
362 private Date _modifiedDate;
363 private long _classNameId;
364 private long _classPK;
365 private double _score;
366 private transient ExpandoBridge _expandoBridge;
367 }