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