1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.kernel.util.StringPool;
30  import com.liferay.portal.model.impl.BaseModelImpl;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.ratings.model.RatingsEntry;
34  import com.liferay.portlet.ratings.model.RatingsEntrySoap;
35  
36  import java.io.Serializable;
37  
38  import java.lang.reflect.Proxy;
39  
40  import java.sql.Types;
41  
42  import java.util.ArrayList;
43  import java.util.Date;
44  import java.util.List;
45  
46  /**
47   * <a href="RatingsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the RatingsEntry table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       RatingsEntryImpl
61   * @see       com.liferay.portlet.ratings.model.RatingsEntry
62   * @see       com.liferay.portlet.ratings.model.RatingsEntryModel
63   * @generated
64   */
65  public class RatingsEntryModelImpl extends BaseModelImpl<RatingsEntry> {
66      public static final String TABLE_NAME = "RatingsEntry";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "entryId", new Integer(Types.BIGINT) },
69              { "companyId", new Integer(Types.BIGINT) },
70              { "userId", new Integer(Types.BIGINT) },
71              { "userName", new Integer(Types.VARCHAR) },
72              { "createDate", new Integer(Types.TIMESTAMP) },
73              { "modifiedDate", new Integer(Types.TIMESTAMP) },
74              { "classNameId", new Integer(Types.BIGINT) },
75              { "classPK", new Integer(Types.BIGINT) },
76              { "score", new Integer(Types.DOUBLE) }
77          };
78      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)";
79      public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
80      public static final String DATA_SOURCE = "liferayDataSource";
81      public static final String SESSION_FACTORY = "liferaySessionFactory";
82      public static final String TX_MANAGER = "liferayTransactionManager";
83      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
85              true);
86      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
88              true);
89  
90      public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
91          RatingsEntry model = new RatingsEntryImpl();
92  
93          model.setEntryId(soapModel.getEntryId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setUserId(soapModel.getUserId());
96          model.setUserName(soapModel.getUserName());
97          model.setCreateDate(soapModel.getCreateDate());
98          model.setModifiedDate(soapModel.getModifiedDate());
99          model.setClassNameId(soapModel.getClassNameId());
100         model.setClassPK(soapModel.getClassPK());
101         model.setScore(soapModel.getScore());
102 
103         return model;
104     }
105 
106     public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
107         List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
108 
109         for (RatingsEntrySoap soapModel : soapModels) {
110             models.add(toModel(soapModel));
111         }
112 
113         return models;
114     }
115 
116     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
117                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
118 
119     public RatingsEntryModelImpl() {
120     }
121 
122     public long getPrimaryKey() {
123         return _entryId;
124     }
125 
126     public void setPrimaryKey(long pk) {
127         setEntryId(pk);
128     }
129 
130     public Serializable getPrimaryKeyObj() {
131         return new Long(_entryId);
132     }
133 
134     public long getEntryId() {
135         return _entryId;
136     }
137 
138     public void setEntryId(long entryId) {
139         _entryId = entryId;
140     }
141 
142     public long getCompanyId() {
143         return _companyId;
144     }
145 
146     public void setCompanyId(long companyId) {
147         _companyId = companyId;
148     }
149 
150     public long getUserId() {
151         return _userId;
152     }
153 
154     public void setUserId(long userId) {
155         _userId = userId;
156 
157         if (!_setOriginalUserId) {
158             _setOriginalUserId = true;
159 
160             _originalUserId = userId;
161         }
162     }
163 
164     public String getUserUuid() throws SystemException {
165         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
166     }
167 
168     public void setUserUuid(String userUuid) {
169         _userUuid = userUuid;
170     }
171 
172     public long getOriginalUserId() {
173         return _originalUserId;
174     }
175 
176     public String getUserName() {
177         return GetterUtil.getString(_userName);
178     }
179 
180     public void setUserName(String userName) {
181         _userName = userName;
182     }
183 
184     public Date getCreateDate() {
185         return _createDate;
186     }
187 
188     public void setCreateDate(Date createDate) {
189         _createDate = createDate;
190     }
191 
192     public Date getModifiedDate() {
193         return _modifiedDate;
194     }
195 
196     public void setModifiedDate(Date modifiedDate) {
197         _modifiedDate = modifiedDate;
198     }
199 
200     public String getClassName() {
201         if (getClassNameId() <= 0) {
202             return StringPool.BLANK;
203         }
204 
205         return PortalUtil.getClassName(getClassNameId());
206     }
207 
208     public long getClassNameId() {
209         return _classNameId;
210     }
211 
212     public void setClassNameId(long classNameId) {
213         _classNameId = classNameId;
214 
215         if (!_setOriginalClassNameId) {
216             _setOriginalClassNameId = true;
217 
218             _originalClassNameId = classNameId;
219         }
220     }
221 
222     public long getOriginalClassNameId() {
223         return _originalClassNameId;
224     }
225 
226     public long getClassPK() {
227         return _classPK;
228     }
229 
230     public void setClassPK(long classPK) {
231         _classPK = classPK;
232 
233         if (!_setOriginalClassPK) {
234             _setOriginalClassPK = true;
235 
236             _originalClassPK = classPK;
237         }
238     }
239 
240     public long getOriginalClassPK() {
241         return _originalClassPK;
242     }
243 
244     public double getScore() {
245         return _score;
246     }
247 
248     public void setScore(double score) {
249         _score = score;
250     }
251 
252     public RatingsEntry toEscapedModel() {
253         if (isEscapedModel()) {
254             return (RatingsEntry)this;
255         }
256         else {
257             RatingsEntry model = new RatingsEntryImpl();
258 
259             model.setNew(isNew());
260             model.setEscapedModel(true);
261 
262             model.setEntryId(getEntryId());
263             model.setCompanyId(getCompanyId());
264             model.setUserId(getUserId());
265             model.setUserName(HtmlUtil.escape(getUserName()));
266             model.setCreateDate(getCreateDate());
267             model.setModifiedDate(getModifiedDate());
268             model.setClassNameId(getClassNameId());
269             model.setClassPK(getClassPK());
270             model.setScore(getScore());
271 
272             model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
273                     new Class[] { RatingsEntry.class },
274                     new ReadOnlyBeanHandler(model));
275 
276             return model;
277         }
278     }
279 
280     public Object clone() {
281         RatingsEntryImpl clone = new RatingsEntryImpl();
282 
283         clone.setEntryId(getEntryId());
284         clone.setCompanyId(getCompanyId());
285         clone.setUserId(getUserId());
286         clone.setUserName(getUserName());
287         clone.setCreateDate(getCreateDate());
288         clone.setModifiedDate(getModifiedDate());
289         clone.setClassNameId(getClassNameId());
290         clone.setClassPK(getClassPK());
291         clone.setScore(getScore());
292 
293         return clone;
294     }
295 
296     public int compareTo(RatingsEntry ratingsEntry) {
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         RatingsEntry ratingsEntry = null;
316 
317         try {
318             ratingsEntry = (RatingsEntry)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     public String toString() {
339         StringBuilder sb = new StringBuilder();
340 
341         sb.append("{entryId=");
342         sb.append(getEntryId());
343         sb.append(", companyId=");
344         sb.append(getCompanyId());
345         sb.append(", userId=");
346         sb.append(getUserId());
347         sb.append(", userName=");
348         sb.append(getUserName());
349         sb.append(", createDate=");
350         sb.append(getCreateDate());
351         sb.append(", modifiedDate=");
352         sb.append(getModifiedDate());
353         sb.append(", classNameId=");
354         sb.append(getClassNameId());
355         sb.append(", classPK=");
356         sb.append(getClassPK());
357         sb.append(", score=");
358         sb.append(getScore());
359         sb.append("}");
360 
361         return sb.toString();
362     }
363 
364     public String toXmlString() {
365         StringBuilder sb = new StringBuilder();
366 
367         sb.append("<model><model-name>");
368         sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
369         sb.append("</model-name>");
370 
371         sb.append(
372             "<column><column-name>entryId</column-name><column-value><![CDATA[");
373         sb.append(getEntryId());
374         sb.append("]]></column-value></column>");
375         sb.append(
376             "<column><column-name>companyId</column-name><column-value><![CDATA[");
377         sb.append(getCompanyId());
378         sb.append("]]></column-value></column>");
379         sb.append(
380             "<column><column-name>userId</column-name><column-value><![CDATA[");
381         sb.append(getUserId());
382         sb.append("]]></column-value></column>");
383         sb.append(
384             "<column><column-name>userName</column-name><column-value><![CDATA[");
385         sb.append(getUserName());
386         sb.append("]]></column-value></column>");
387         sb.append(
388             "<column><column-name>createDate</column-name><column-value><![CDATA[");
389         sb.append(getCreateDate());
390         sb.append("]]></column-value></column>");
391         sb.append(
392             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
393         sb.append(getModifiedDate());
394         sb.append("]]></column-value></column>");
395         sb.append(
396             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
397         sb.append(getClassNameId());
398         sb.append("]]></column-value></column>");
399         sb.append(
400             "<column><column-name>classPK</column-name><column-value><![CDATA[");
401         sb.append(getClassPK());
402         sb.append("]]></column-value></column>");
403         sb.append(
404             "<column><column-name>score</column-name><column-value><![CDATA[");
405         sb.append(getScore());
406         sb.append("]]></column-value></column>");
407 
408         sb.append("</model>");
409 
410         return sb.toString();
411     }
412 
413     private long _entryId;
414     private long _companyId;
415     private long _userId;
416     private String _userUuid;
417     private long _originalUserId;
418     private boolean _setOriginalUserId;
419     private String _userName;
420     private Date _createDate;
421     private Date _modifiedDate;
422     private long _classNameId;
423     private long _originalClassNameId;
424     private boolean _setOriginalClassNameId;
425     private long _classPK;
426     private long _originalClassPK;
427     private boolean _setOriginalClassPK;
428     private double _score;
429 }