1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.ratings.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.kernel.util.StringPool;
23  import com.liferay.portal.model.impl.BaseModelImpl;
24  import com.liferay.portal.service.ServiceContext;
25  import com.liferay.portal.util.PortalUtil;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29  import com.liferay.portlet.ratings.model.RatingsEntry;
30  import com.liferay.portlet.ratings.model.RatingsEntrySoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="RatingsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This interface is a model that represents the RatingsEntry table in the
52   * database.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       RatingsEntryImpl
57   * @see       com.liferay.portlet.ratings.model.RatingsEntry
58   * @see       com.liferay.portlet.ratings.model.RatingsEntryModel
59   * @generated
60   */
61  public class RatingsEntryModelImpl extends BaseModelImpl<RatingsEntry> {
62      public static final String TABLE_NAME = "RatingsEntry";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "entryId", new Integer(Types.BIGINT) },
65              { "companyId", new Integer(Types.BIGINT) },
66              { "userId", new Integer(Types.BIGINT) },
67              { "userName", new Integer(Types.VARCHAR) },
68              { "createDate", new Integer(Types.TIMESTAMP) },
69              { "modifiedDate", new Integer(Types.TIMESTAMP) },
70              { "classNameId", new Integer(Types.BIGINT) },
71              { "classPK", new Integer(Types.BIGINT) },
72              { "score", new Integer(Types.DOUBLE) }
73          };
74      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)";
75      public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
81              true);
82      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
84              true);
85  
86      public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
87          RatingsEntry model = new RatingsEntryImpl();
88  
89          model.setEntryId(soapModel.getEntryId());
90          model.setCompanyId(soapModel.getCompanyId());
91          model.setUserId(soapModel.getUserId());
92          model.setUserName(soapModel.getUserName());
93          model.setCreateDate(soapModel.getCreateDate());
94          model.setModifiedDate(soapModel.getModifiedDate());
95          model.setClassNameId(soapModel.getClassNameId());
96          model.setClassPK(soapModel.getClassPK());
97          model.setScore(soapModel.getScore());
98  
99          return model;
100     }
101 
102     public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
103         List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
104 
105         for (RatingsEntrySoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
114 
115     public RatingsEntryModelImpl() {
116     }
117 
118     public long getPrimaryKey() {
119         return _entryId;
120     }
121 
122     public void setPrimaryKey(long pk) {
123         setEntryId(pk);
124     }
125 
126     public Serializable getPrimaryKeyObj() {
127         return new Long(_entryId);
128     }
129 
130     public long getEntryId() {
131         return _entryId;
132     }
133 
134     public void setEntryId(long entryId) {
135         _entryId = entryId;
136     }
137 
138     public long getCompanyId() {
139         return _companyId;
140     }
141 
142     public void setCompanyId(long companyId) {
143         _companyId = companyId;
144     }
145 
146     public long getUserId() {
147         return _userId;
148     }
149 
150     public void setUserId(long userId) {
151         _userId = userId;
152 
153         if (!_setOriginalUserId) {
154             _setOriginalUserId = true;
155 
156             _originalUserId = userId;
157         }
158     }
159 
160     public String getUserUuid() throws SystemException {
161         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
162     }
163 
164     public void setUserUuid(String userUuid) {
165         _userUuid = userUuid;
166     }
167 
168     public long getOriginalUserId() {
169         return _originalUserId;
170     }
171 
172     public String getUserName() {
173         return GetterUtil.getString(_userName);
174     }
175 
176     public void setUserName(String userName) {
177         _userName = userName;
178     }
179 
180     public Date getCreateDate() {
181         return _createDate;
182     }
183 
184     public void setCreateDate(Date createDate) {
185         _createDate = createDate;
186     }
187 
188     public Date getModifiedDate() {
189         return _modifiedDate;
190     }
191 
192     public void setModifiedDate(Date modifiedDate) {
193         _modifiedDate = modifiedDate;
194     }
195 
196     public String getClassName() {
197         if (getClassNameId() <= 0) {
198             return StringPool.BLANK;
199         }
200 
201         return PortalUtil.getClassName(getClassNameId());
202     }
203 
204     public long getClassNameId() {
205         return _classNameId;
206     }
207 
208     public void setClassNameId(long classNameId) {
209         _classNameId = classNameId;
210 
211         if (!_setOriginalClassNameId) {
212             _setOriginalClassNameId = true;
213 
214             _originalClassNameId = classNameId;
215         }
216     }
217 
218     public long getOriginalClassNameId() {
219         return _originalClassNameId;
220     }
221 
222     public long getClassPK() {
223         return _classPK;
224     }
225 
226     public void setClassPK(long classPK) {
227         _classPK = classPK;
228 
229         if (!_setOriginalClassPK) {
230             _setOriginalClassPK = true;
231 
232             _originalClassPK = classPK;
233         }
234     }
235 
236     public long getOriginalClassPK() {
237         return _originalClassPK;
238     }
239 
240     public double getScore() {
241         return _score;
242     }
243 
244     public void setScore(double score) {
245         _score = score;
246     }
247 
248     public RatingsEntry toEscapedModel() {
249         if (isEscapedModel()) {
250             return (RatingsEntry)this;
251         }
252         else {
253             RatingsEntry model = new RatingsEntryImpl();
254 
255             model.setNew(isNew());
256             model.setEscapedModel(true);
257 
258             model.setEntryId(getEntryId());
259             model.setCompanyId(getCompanyId());
260             model.setUserId(getUserId());
261             model.setUserName(HtmlUtil.escape(getUserName()));
262             model.setCreateDate(getCreateDate());
263             model.setModifiedDate(getModifiedDate());
264             model.setClassNameId(getClassNameId());
265             model.setClassPK(getClassPK());
266             model.setScore(getScore());
267 
268             model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
269                     new Class[] { RatingsEntry.class },
270                     new ReadOnlyBeanHandler(model));
271 
272             return model;
273         }
274     }
275 
276     public ExpandoBridge getExpandoBridge() {
277         if (_expandoBridge == null) {
278             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
279                     RatingsEntry.class.getName(), getPrimaryKey());
280         }
281 
282         return _expandoBridge;
283     }
284 
285     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
286         getExpandoBridge().setAttributes(serviceContext);
287     }
288 
289     public Object clone() {
290         RatingsEntryImpl clone = new RatingsEntryImpl();
291 
292         clone.setEntryId(getEntryId());
293         clone.setCompanyId(getCompanyId());
294         clone.setUserId(getUserId());
295         clone.setUserName(getUserName());
296         clone.setCreateDate(getCreateDate());
297         clone.setModifiedDate(getModifiedDate());
298         clone.setClassNameId(getClassNameId());
299         clone.setClassPK(getClassPK());
300         clone.setScore(getScore());
301 
302         return clone;
303     }
304 
305     public int compareTo(RatingsEntry ratingsEntry) {
306         long pk = ratingsEntry.getPrimaryKey();
307 
308         if (getPrimaryKey() < pk) {
309             return -1;
310         }
311         else if (getPrimaryKey() > pk) {
312             return 1;
313         }
314         else {
315             return 0;
316         }
317     }
318 
319     public boolean equals(Object obj) {
320         if (obj == null) {
321             return false;
322         }
323 
324         RatingsEntry ratingsEntry = null;
325 
326         try {
327             ratingsEntry = (RatingsEntry)obj;
328         }
329         catch (ClassCastException cce) {
330             return false;
331         }
332 
333         long pk = ratingsEntry.getPrimaryKey();
334 
335         if (getPrimaryKey() == pk) {
336             return true;
337         }
338         else {
339             return false;
340         }
341     }
342 
343     public int hashCode() {
344         return (int)getPrimaryKey();
345     }
346 
347     public String toString() {
348         StringBundler sb = new StringBundler(19);
349 
350         sb.append("{entryId=");
351         sb.append(getEntryId());
352         sb.append(", companyId=");
353         sb.append(getCompanyId());
354         sb.append(", userId=");
355         sb.append(getUserId());
356         sb.append(", userName=");
357         sb.append(getUserName());
358         sb.append(", createDate=");
359         sb.append(getCreateDate());
360         sb.append(", modifiedDate=");
361         sb.append(getModifiedDate());
362         sb.append(", classNameId=");
363         sb.append(getClassNameId());
364         sb.append(", classPK=");
365         sb.append(getClassPK());
366         sb.append(", score=");
367         sb.append(getScore());
368         sb.append("}");
369 
370         return sb.toString();
371     }
372 
373     public String toXmlString() {
374         StringBundler sb = new StringBundler(31);
375 
376         sb.append("<model><model-name>");
377         sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
378         sb.append("</model-name>");
379 
380         sb.append(
381             "<column><column-name>entryId</column-name><column-value><![CDATA[");
382         sb.append(getEntryId());
383         sb.append("]]></column-value></column>");
384         sb.append(
385             "<column><column-name>companyId</column-name><column-value><![CDATA[");
386         sb.append(getCompanyId());
387         sb.append("]]></column-value></column>");
388         sb.append(
389             "<column><column-name>userId</column-name><column-value><![CDATA[");
390         sb.append(getUserId());
391         sb.append("]]></column-value></column>");
392         sb.append(
393             "<column><column-name>userName</column-name><column-value><![CDATA[");
394         sb.append(getUserName());
395         sb.append("]]></column-value></column>");
396         sb.append(
397             "<column><column-name>createDate</column-name><column-value><![CDATA[");
398         sb.append(getCreateDate());
399         sb.append("]]></column-value></column>");
400         sb.append(
401             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
402         sb.append(getModifiedDate());
403         sb.append("]]></column-value></column>");
404         sb.append(
405             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
406         sb.append(getClassNameId());
407         sb.append("]]></column-value></column>");
408         sb.append(
409             "<column><column-name>classPK</column-name><column-value><![CDATA[");
410         sb.append(getClassPK());
411         sb.append("]]></column-value></column>");
412         sb.append(
413             "<column><column-name>score</column-name><column-value><![CDATA[");
414         sb.append(getScore());
415         sb.append("]]></column-value></column>");
416 
417         sb.append("</model>");
418 
419         return sb.toString();
420     }
421 
422     private long _entryId;
423     private long _companyId;
424     private long _userId;
425     private String _userUuid;
426     private long _originalUserId;
427     private boolean _setOriginalUserId;
428     private String _userName;
429     private Date _createDate;
430     private Date _modifiedDate;
431     private long _classNameId;
432     private long _originalClassNameId;
433     private boolean _setOriginalClassNameId;
434     private long _classPK;
435     private long _originalClassPK;
436     private boolean _setOriginalClassPK;
437     private double _score;
438     private transient ExpandoBridge _expandoBridge;
439 }