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