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