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