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.kernel.util.StringPool;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
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.model.RatingsEntry
61   * @see com.liferay.portlet.ratings.model.RatingsEntryModel
62   * @see com.liferay.portlet.ratings.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 String DATA_SOURCE = "liferayDataSource";
97      public static final String SESSION_FACTORY = "liferaySessionFactory";
98      public static final String TX_MANAGER = "liferayTransactionManager";
99      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100                 "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
101             true);
102 
103     public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
104         RatingsEntry model = new RatingsEntryImpl();
105 
106         model.setEntryId(soapModel.getEntryId());
107         model.setCompanyId(soapModel.getCompanyId());
108         model.setUserId(soapModel.getUserId());
109         model.setUserName(soapModel.getUserName());
110         model.setCreateDate(soapModel.getCreateDate());
111         model.setModifiedDate(soapModel.getModifiedDate());
112         model.setClassNameId(soapModel.getClassNameId());
113         model.setClassPK(soapModel.getClassPK());
114         model.setScore(soapModel.getScore());
115 
116         return model;
117     }
118 
119     public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
120         List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
121 
122         for (RatingsEntrySoap soapModel : soapModels) {
123             models.add(toModel(soapModel));
124         }
125 
126         return models;
127     }
128 
129     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
131 
132     public RatingsEntryModelImpl() {
133     }
134 
135     public long getPrimaryKey() {
136         return _entryId;
137     }
138 
139     public void setPrimaryKey(long pk) {
140         setEntryId(pk);
141     }
142 
143     public Serializable getPrimaryKeyObj() {
144         return new Long(_entryId);
145     }
146 
147     public long getEntryId() {
148         return _entryId;
149     }
150 
151     public void setEntryId(long entryId) {
152         if (entryId != _entryId) {
153             _entryId = entryId;
154         }
155     }
156 
157     public long getCompanyId() {
158         return _companyId;
159     }
160 
161     public void setCompanyId(long companyId) {
162         if (companyId != _companyId) {
163             _companyId = companyId;
164         }
165     }
166 
167     public long getUserId() {
168         return _userId;
169     }
170 
171     public void setUserId(long userId) {
172         if (userId != _userId) {
173             _userId = userId;
174         }
175     }
176 
177     public String getUserName() {
178         return GetterUtil.getString(_userName);
179     }
180 
181     public void setUserName(String userName) {
182         if (((userName == null) && (_userName != null)) ||
183                 ((userName != null) && (_userName == null)) ||
184                 ((userName != null) && (_userName != null) &&
185                 !userName.equals(_userName))) {
186             _userName = userName;
187         }
188     }
189 
190     public Date getCreateDate() {
191         return _createDate;
192     }
193 
194     public void setCreateDate(Date createDate) {
195         if (((createDate == null) && (_createDate != null)) ||
196                 ((createDate != null) && (_createDate == null)) ||
197                 ((createDate != null) && (_createDate != null) &&
198                 !createDate.equals(_createDate))) {
199             _createDate = createDate;
200         }
201     }
202 
203     public Date getModifiedDate() {
204         return _modifiedDate;
205     }
206 
207     public void setModifiedDate(Date modifiedDate) {
208         if (((modifiedDate == null) && (_modifiedDate != null)) ||
209                 ((modifiedDate != null) && (_modifiedDate == null)) ||
210                 ((modifiedDate != null) && (_modifiedDate != null) &&
211                 !modifiedDate.equals(_modifiedDate))) {
212             _modifiedDate = modifiedDate;
213         }
214     }
215 
216     public String getClassName() {
217         if (getClassNameId() <= 0) {
218             return StringPool.BLANK;
219         }
220 
221         return PortalUtil.getClassName(getClassNameId());
222     }
223 
224     public long getClassNameId() {
225         return _classNameId;
226     }
227 
228     public void setClassNameId(long classNameId) {
229         if (classNameId != _classNameId) {
230             _classNameId = classNameId;
231         }
232     }
233 
234     public long getClassPK() {
235         return _classPK;
236     }
237 
238     public void setClassPK(long classPK) {
239         if (classPK != _classPK) {
240             _classPK = classPK;
241         }
242     }
243 
244     public double getScore() {
245         return _score;
246     }
247 
248     public void setScore(double score) {
249         if (score != _score) {
250             _score = score;
251         }
252     }
253 
254     public RatingsEntry toEscapedModel() {
255         if (isEscapedModel()) {
256             return (RatingsEntry)this;
257         }
258         else {
259             RatingsEntry model = new RatingsEntryImpl();
260 
261             model.setNew(isNew());
262             model.setEscapedModel(true);
263 
264             model.setEntryId(getEntryId());
265             model.setCompanyId(getCompanyId());
266             model.setUserId(getUserId());
267             model.setUserName(HtmlUtil.escape(getUserName()));
268             model.setCreateDate(getCreateDate());
269             model.setModifiedDate(getModifiedDate());
270             model.setClassNameId(getClassNameId());
271             model.setClassPK(getClassPK());
272             model.setScore(getScore());
273 
274             model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
275                     new Class[] { RatingsEntry.class },
276                     new ReadOnlyBeanHandler(model));
277 
278             return model;
279         }
280     }
281 
282     public Object clone() {
283         RatingsEntryImpl clone = new RatingsEntryImpl();
284 
285         clone.setEntryId(getEntryId());
286         clone.setCompanyId(getCompanyId());
287         clone.setUserId(getUserId());
288         clone.setUserName(getUserName());
289         clone.setCreateDate(getCreateDate());
290         clone.setModifiedDate(getModifiedDate());
291         clone.setClassNameId(getClassNameId());
292         clone.setClassPK(getClassPK());
293         clone.setScore(getScore());
294 
295         return clone;
296     }
297 
298     public int compareTo(Object obj) {
299         if (obj == null) {
300             return -1;
301         }
302 
303         RatingsEntryImpl ratingsEntry = (RatingsEntryImpl)obj;
304 
305         long pk = ratingsEntry.getPrimaryKey();
306 
307         if (getPrimaryKey() < pk) {
308             return -1;
309         }
310         else if (getPrimaryKey() > pk) {
311             return 1;
312         }
313         else {
314             return 0;
315         }
316     }
317 
318     public boolean equals(Object obj) {
319         if (obj == null) {
320             return false;
321         }
322 
323         RatingsEntryImpl ratingsEntry = null;
324 
325         try {
326             ratingsEntry = (RatingsEntryImpl)obj;
327         }
328         catch (ClassCastException cce) {
329             return false;
330         }
331 
332         long pk = ratingsEntry.getPrimaryKey();
333 
334         if (getPrimaryKey() == pk) {
335             return true;
336         }
337         else {
338             return false;
339         }
340     }
341 
342     public int hashCode() {
343         return (int)getPrimaryKey();
344     }
345 
346     private long _entryId;
347     private long _companyId;
348     private long _userId;
349     private String _userName;
350     private Date _createDate;
351     private Date _modifiedDate;
352     private long _classNameId;
353     private long _classPK;
354     private double _score;
355 }