1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  import java.util.Date;
36  
37  /**
38   * <a href="RatingsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>RatingsEntry</code> table in
47   * the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portlet.ratings.service.model.RatingsEntry
53   * @see com.liferay.portlet.ratings.service.model.RatingsEntryModel
54   * @see com.liferay.portlet.ratings.service.model.impl.RatingsEntryImpl
55   *
56   */
57  public class RatingsEntryModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "RatingsEntry";
59      public static Object[][] TABLE_COLUMNS = {
60              { "entryId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "createDate", new Integer(Types.TIMESTAMP) },
65              { "modifiedDate", new Integer(Types.TIMESTAMP) },
66              { "classNameId", new Integer(Types.BIGINT) },
67              { "classPK", new Integer(Types.BIGINT) },
68              { "score", new Integer(Types.DOUBLE) }
69          };
70      public static 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)";
71      public static String TABLE_SQL_DROP = "drop table RatingsEntry";
72      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
73                  "xss.allow.com.liferay.portlet.ratings.model.RatingsEntry"),
74              XSS_ALLOW);
75      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
76                  "xss.allow.com.liferay.portlet.ratings.model.RatingsEntry.userName"),
77              XSS_ALLOW_BY_MODEL);
78      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
79                  "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntryModel"));
80  
81      public RatingsEntryModelImpl() {
82      }
83  
84      public long getPrimaryKey() {
85          return _entryId;
86      }
87  
88      public void setPrimaryKey(long pk) {
89          setEntryId(pk);
90      }
91  
92      public Serializable getPrimaryKeyObj() {
93          return new Long(_entryId);
94      }
95  
96      public long getEntryId() {
97          return _entryId;
98      }
99  
100     public void setEntryId(long entryId) {
101         if (entryId != _entryId) {
102             _entryId = entryId;
103         }
104     }
105 
106     public long getCompanyId() {
107         return _companyId;
108     }
109 
110     public void setCompanyId(long companyId) {
111         if (companyId != _companyId) {
112             _companyId = companyId;
113         }
114     }
115 
116     public long getUserId() {
117         return _userId;
118     }
119 
120     public void setUserId(long userId) {
121         if (userId != _userId) {
122             _userId = userId;
123         }
124     }
125 
126     public String getUserName() {
127         return GetterUtil.getString(_userName);
128     }
129 
130     public void setUserName(String userName) {
131         if (((userName == null) && (_userName != null)) ||
132                 ((userName != null) && (_userName == null)) ||
133                 ((userName != null) && (_userName != null) &&
134                 !userName.equals(_userName))) {
135             if (!XSS_ALLOW_USERNAME) {
136                 userName = XSSUtil.strip(userName);
137             }
138 
139             _userName = userName;
140         }
141     }
142 
143     public Date getCreateDate() {
144         return _createDate;
145     }
146 
147     public void setCreateDate(Date createDate) {
148         if (((createDate == null) && (_createDate != null)) ||
149                 ((createDate != null) && (_createDate == null)) ||
150                 ((createDate != null) && (_createDate != null) &&
151                 !createDate.equals(_createDate))) {
152             _createDate = createDate;
153         }
154     }
155 
156     public Date getModifiedDate() {
157         return _modifiedDate;
158     }
159 
160     public void setModifiedDate(Date modifiedDate) {
161         if (((modifiedDate == null) && (_modifiedDate != null)) ||
162                 ((modifiedDate != null) && (_modifiedDate == null)) ||
163                 ((modifiedDate != null) && (_modifiedDate != null) &&
164                 !modifiedDate.equals(_modifiedDate))) {
165             _modifiedDate = modifiedDate;
166         }
167     }
168 
169     public long getClassNameId() {
170         return _classNameId;
171     }
172 
173     public void setClassNameId(long classNameId) {
174         if (classNameId != _classNameId) {
175             _classNameId = classNameId;
176         }
177     }
178 
179     public long getClassPK() {
180         return _classPK;
181     }
182 
183     public void setClassPK(long classPK) {
184         if (classPK != _classPK) {
185             _classPK = classPK;
186         }
187     }
188 
189     public double getScore() {
190         return _score;
191     }
192 
193     public void setScore(double score) {
194         if (score != _score) {
195             _score = score;
196         }
197     }
198 
199     public Object clone() {
200         RatingsEntryImpl clone = new RatingsEntryImpl();
201         clone.setEntryId(getEntryId());
202         clone.setCompanyId(getCompanyId());
203         clone.setUserId(getUserId());
204         clone.setUserName(getUserName());
205         clone.setCreateDate(getCreateDate());
206         clone.setModifiedDate(getModifiedDate());
207         clone.setClassNameId(getClassNameId());
208         clone.setClassPK(getClassPK());
209         clone.setScore(getScore());
210 
211         return clone;
212     }
213 
214     public int compareTo(Object obj) {
215         if (obj == null) {
216             return -1;
217         }
218 
219         RatingsEntryImpl ratingsEntry = (RatingsEntryImpl)obj;
220         long pk = ratingsEntry.getPrimaryKey();
221 
222         if (getPrimaryKey() < pk) {
223             return -1;
224         }
225         else if (getPrimaryKey() > pk) {
226             return 1;
227         }
228         else {
229             return 0;
230         }
231     }
232 
233     public boolean equals(Object obj) {
234         if (obj == null) {
235             return false;
236         }
237 
238         RatingsEntryImpl ratingsEntry = null;
239 
240         try {
241             ratingsEntry = (RatingsEntryImpl)obj;
242         }
243         catch (ClassCastException cce) {
244             return false;
245         }
246 
247         long pk = ratingsEntry.getPrimaryKey();
248 
249         if (getPrimaryKey() == pk) {
250             return true;
251         }
252         else {
253             return false;
254         }
255     }
256 
257     public int hashCode() {
258         return (int)getPrimaryKey();
259     }
260 
261     private long _entryId;
262     private long _companyId;
263     private long _userId;
264     private String _userName;
265     private Date _createDate;
266     private Date _modifiedDate;
267     private long _classNameId;
268     private long _classPK;
269     private double _score;
270 }