1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.PropsUtil;
29  
30  import com.liferay.portlet.ratings.model.RatingsEntry;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.Date;
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 class is a model that represents the <code>RatingsEntry</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.ratings.service.model.RatingsEntry
58   * @see com.liferay.portlet.ratings.service.model.RatingsEntryModel
59   * @see com.liferay.portlet.ratings.service.model.impl.RatingsEntryImpl
60   *
61   */
62  public class RatingsEntryModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "RatingsEntry";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "entryId", new Integer(Types.BIGINT) },
66              
67  
68              { "companyId", new Integer(Types.BIGINT) },
69              
70  
71              { "userId", new Integer(Types.BIGINT) },
72              
73  
74              { "userName", new Integer(Types.VARCHAR) },
75              
76  
77              { "createDate", new Integer(Types.TIMESTAMP) },
78              
79  
80              { "modifiedDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "classNameId", new Integer(Types.BIGINT) },
84              
85  
86              { "classPK", new Integer(Types.BIGINT) },
87              
88  
89              { "score", new Integer(Types.DOUBLE) }
90          };
91      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)";
92      public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
93      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
94                  "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
95              true);
96      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
97                  "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
98  
99      public RatingsEntryModelImpl() {
100     }
101 
102     public long getPrimaryKey() {
103         return _entryId;
104     }
105 
106     public void setPrimaryKey(long pk) {
107         setEntryId(pk);
108     }
109 
110     public Serializable getPrimaryKeyObj() {
111         return new Long(_entryId);
112     }
113 
114     public long getEntryId() {
115         return _entryId;
116     }
117 
118     public void setEntryId(long entryId) {
119         if (entryId != _entryId) {
120             _entryId = entryId;
121         }
122     }
123 
124     public long getCompanyId() {
125         return _companyId;
126     }
127 
128     public void setCompanyId(long companyId) {
129         if (companyId != _companyId) {
130             _companyId = companyId;
131         }
132     }
133 
134     public long getUserId() {
135         return _userId;
136     }
137 
138     public void setUserId(long userId) {
139         if (userId != _userId) {
140             _userId = userId;
141         }
142     }
143 
144     public String getUserName() {
145         return GetterUtil.getString(_userName);
146     }
147 
148     public void setUserName(String userName) {
149         if (((userName == null) && (_userName != null)) ||
150                 ((userName != null) && (_userName == null)) ||
151                 ((userName != null) && (_userName != null) &&
152                 !userName.equals(_userName))) {
153             _userName = userName;
154         }
155     }
156 
157     public Date getCreateDate() {
158         return _createDate;
159     }
160 
161     public void setCreateDate(Date createDate) {
162         if (((createDate == null) && (_createDate != null)) ||
163                 ((createDate != null) && (_createDate == null)) ||
164                 ((createDate != null) && (_createDate != null) &&
165                 !createDate.equals(_createDate))) {
166             _createDate = createDate;
167         }
168     }
169 
170     public Date getModifiedDate() {
171         return _modifiedDate;
172     }
173 
174     public void setModifiedDate(Date modifiedDate) {
175         if (((modifiedDate == null) && (_modifiedDate != null)) ||
176                 ((modifiedDate != null) && (_modifiedDate == null)) ||
177                 ((modifiedDate != null) && (_modifiedDate != null) &&
178                 !modifiedDate.equals(_modifiedDate))) {
179             _modifiedDate = modifiedDate;
180         }
181     }
182 
183     public long getClassNameId() {
184         return _classNameId;
185     }
186 
187     public void setClassNameId(long classNameId) {
188         if (classNameId != _classNameId) {
189             _classNameId = classNameId;
190         }
191     }
192 
193     public long getClassPK() {
194         return _classPK;
195     }
196 
197     public void setClassPK(long classPK) {
198         if (classPK != _classPK) {
199             _classPK = classPK;
200         }
201     }
202 
203     public double getScore() {
204         return _score;
205     }
206 
207     public void setScore(double score) {
208         if (score != _score) {
209             _score = score;
210         }
211     }
212 
213     public RatingsEntry toEscapedModel() {
214         if (isEscapedModel()) {
215             return (RatingsEntry)this;
216         }
217         else {
218             RatingsEntry model = new RatingsEntryImpl();
219 
220             model.setEscapedModel(true);
221 
222             model.setEntryId(getEntryId());
223             model.setCompanyId(getCompanyId());
224             model.setUserId(getUserId());
225             model.setUserName(Html.escape(getUserName()));
226             model.setCreateDate(getCreateDate());
227             model.setModifiedDate(getModifiedDate());
228             model.setClassNameId(getClassNameId());
229             model.setClassPK(getClassPK());
230             model.setScore(getScore());
231 
232             model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
233                     new Class[] { RatingsEntry.class },
234                     new ReadOnlyBeanHandler(model));
235 
236             return model;
237         }
238     }
239 
240     public Object clone() {
241         RatingsEntryImpl clone = new RatingsEntryImpl();
242 
243         clone.setEntryId(getEntryId());
244         clone.setCompanyId(getCompanyId());
245         clone.setUserId(getUserId());
246         clone.setUserName(getUserName());
247         clone.setCreateDate(getCreateDate());
248         clone.setModifiedDate(getModifiedDate());
249         clone.setClassNameId(getClassNameId());
250         clone.setClassPK(getClassPK());
251         clone.setScore(getScore());
252 
253         return clone;
254     }
255 
256     public int compareTo(Object obj) {
257         if (obj == null) {
258             return -1;
259         }
260 
261         RatingsEntryImpl ratingsEntry = (RatingsEntryImpl)obj;
262 
263         long pk = ratingsEntry.getPrimaryKey();
264 
265         if (getPrimaryKey() < pk) {
266             return -1;
267         }
268         else if (getPrimaryKey() > pk) {
269             return 1;
270         }
271         else {
272             return 0;
273         }
274     }
275 
276     public boolean equals(Object obj) {
277         if (obj == null) {
278             return false;
279         }
280 
281         RatingsEntryImpl ratingsEntry = null;
282 
283         try {
284             ratingsEntry = (RatingsEntryImpl)obj;
285         }
286         catch (ClassCastException cce) {
287             return false;
288         }
289 
290         long pk = ratingsEntry.getPrimaryKey();
291 
292         if (getPrimaryKey() == pk) {
293             return true;
294         }
295         else {
296             return false;
297         }
298     }
299 
300     public int hashCode() {
301         return (int)getPrimaryKey();
302     }
303 
304     private long _entryId;
305     private long _companyId;
306     private long _userId;
307     private String _userName;
308     private Date _createDate;
309     private Date _modifiedDate;
310     private long _classNameId;
311     private long _classPK;
312     private double _score;
313 }