1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.ratings.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.kernel.util.StringPool;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PortalUtil;
28  
29  import com.liferay.portlet.ratings.model.RatingsEntry;
30  import com.liferay.portlet.ratings.model.RatingsEntrySoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
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.model.RatingsEntry
58   * @see com.liferay.portlet.ratings.model.RatingsEntryModel
59   * @see com.liferay.portlet.ratings.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 String DATA_SOURCE = "liferayDataSource";
94      public static final String SESSION_FACTORY = "liferaySessionFactory";
95      public static final String TX_MANAGER = "liferayTransactionManager";
96      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.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(com.liferay.portal.util.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         if (getClassNameId() <= 0) {
215             return StringPool.BLANK;
216         }
217 
218         return PortalUtil.getClassName(getClassNameId());
219     }
220 
221     public long getClassNameId() {
222         return _classNameId;
223     }
224 
225     public void setClassNameId(long classNameId) {
226         if (classNameId != _classNameId) {
227             _classNameId = classNameId;
228         }
229     }
230 
231     public long getClassPK() {
232         return _classPK;
233     }
234 
235     public void setClassPK(long classPK) {
236         if (classPK != _classPK) {
237             _classPK = classPK;
238         }
239     }
240 
241     public double getScore() {
242         return _score;
243     }
244 
245     public void setScore(double score) {
246         if (score != _score) {
247             _score = score;
248         }
249     }
250 
251     public RatingsEntry toEscapedModel() {
252         if (isEscapedModel()) {
253             return (RatingsEntry)this;
254         }
255         else {
256             RatingsEntry model = new RatingsEntryImpl();
257 
258             model.setNew(isNew());
259             model.setEscapedModel(true);
260 
261             model.setEntryId(getEntryId());
262             model.setCompanyId(getCompanyId());
263             model.setUserId(getUserId());
264             model.setUserName(HtmlUtil.escape(getUserName()));
265             model.setCreateDate(getCreateDate());
266             model.setModifiedDate(getModifiedDate());
267             model.setClassNameId(getClassNameId());
268             model.setClassPK(getClassPK());
269             model.setScore(getScore());
270 
271             model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
272                     new Class[] { RatingsEntry.class },
273                     new ReadOnlyBeanHandler(model));
274 
275             return model;
276         }
277     }
278 
279     public Object clone() {
280         RatingsEntryImpl clone = new RatingsEntryImpl();
281 
282         clone.setEntryId(getEntryId());
283         clone.setCompanyId(getCompanyId());
284         clone.setUserId(getUserId());
285         clone.setUserName(getUserName());
286         clone.setCreateDate(getCreateDate());
287         clone.setModifiedDate(getModifiedDate());
288         clone.setClassNameId(getClassNameId());
289         clone.setClassPK(getClassPK());
290         clone.setScore(getScore());
291 
292         return clone;
293     }
294 
295     public int compareTo(Object obj) {
296         if (obj == null) {
297             return -1;
298         }
299 
300         RatingsEntryImpl ratingsEntry = (RatingsEntryImpl)obj;
301 
302         long pk = ratingsEntry.getPrimaryKey();
303 
304         if (getPrimaryKey() < pk) {
305             return -1;
306         }
307         else if (getPrimaryKey() > pk) {
308             return 1;
309         }
310         else {
311             return 0;
312         }
313     }
314 
315     public boolean equals(Object obj) {
316         if (obj == null) {
317             return false;
318         }
319 
320         RatingsEntryImpl ratingsEntry = null;
321 
322         try {
323             ratingsEntry = (RatingsEntryImpl)obj;
324         }
325         catch (ClassCastException cce) {
326             return false;
327         }
328 
329         long pk = ratingsEntry.getPrimaryKey();
330 
331         if (getPrimaryKey() == pk) {
332             return true;
333         }
334         else {
335             return false;
336         }
337     }
338 
339     public int hashCode() {
340         return (int)getPrimaryKey();
341     }
342 
343     private long _entryId;
344     private long _companyId;
345     private long _userId;
346     private String _userName;
347     private Date _createDate;
348     private Date _modifiedDate;
349     private long _classNameId;
350     private long _classPK;
351     private double _score;
352 }