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.expando.model.ExpandoBridge;
30  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
31  import com.liferay.portlet.ratings.model.RatingsEntry;
32  import com.liferay.portlet.ratings.model.RatingsEntrySoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="RatingsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>RatingsEntry</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.ratings.model.RatingsEntry
60   * @see com.liferay.portlet.ratings.model.RatingsEntryModel
61   * @see com.liferay.portlet.ratings.model.impl.RatingsEntryImpl
62   *
63   */
64  public class RatingsEntryModelImpl extends BaseModelImpl<RatingsEntry> {
65      public static final String TABLE_NAME = "RatingsEntry";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "entryId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "classNameId", new Integer(Types.BIGINT) },
86              
87  
88              { "classPK", new Integer(Types.BIGINT) },
89              
90  
91              { "score", new Integer(Types.DOUBLE) }
92          };
93      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)";
94      public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
95      public static final String DATA_SOURCE = "liferayDataSource";
96      public static final String SESSION_FACTORY = "liferaySessionFactory";
97      public static final String TX_MANAGER = "liferayTransactionManager";
98      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
99                  "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
100             true);
101     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
102                 "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
103             true);
104 
105     public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
106         RatingsEntry model = new RatingsEntryImpl();
107 
108         model.setEntryId(soapModel.getEntryId());
109         model.setCompanyId(soapModel.getCompanyId());
110         model.setUserId(soapModel.getUserId());
111         model.setUserName(soapModel.getUserName());
112         model.setCreateDate(soapModel.getCreateDate());
113         model.setModifiedDate(soapModel.getModifiedDate());
114         model.setClassNameId(soapModel.getClassNameId());
115         model.setClassPK(soapModel.getClassPK());
116         model.setScore(soapModel.getScore());
117 
118         return model;
119     }
120 
121     public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
122         List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
123 
124         for (RatingsEntrySoap soapModel : soapModels) {
125             models.add(toModel(soapModel));
126         }
127 
128         return models;
129     }
130 
131     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
132                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
133 
134     public RatingsEntryModelImpl() {
135     }
136 
137     public long getPrimaryKey() {
138         return _entryId;
139     }
140 
141     public void setPrimaryKey(long pk) {
142         setEntryId(pk);
143     }
144 
145     public Serializable getPrimaryKeyObj() {
146         return new Long(_entryId);
147     }
148 
149     public long getEntryId() {
150         return _entryId;
151     }
152 
153     public void setEntryId(long entryId) {
154         _entryId = entryId;
155     }
156 
157     public long getCompanyId() {
158         return _companyId;
159     }
160 
161     public void setCompanyId(long companyId) {
162         _companyId = companyId;
163     }
164 
165     public long getUserId() {
166         return _userId;
167     }
168 
169     public void setUserId(long userId) {
170         _userId = userId;
171 
172         if (!_setOriginalUserId) {
173             _setOriginalUserId = true;
174 
175             _originalUserId = userId;
176         }
177     }
178 
179     public long getOriginalUserId() {
180         return _originalUserId;
181     }
182 
183     public String getUserName() {
184         return GetterUtil.getString(_userName);
185     }
186 
187     public void setUserName(String userName) {
188         _userName = userName;
189     }
190 
191     public Date getCreateDate() {
192         return _createDate;
193     }
194 
195     public void setCreateDate(Date createDate) {
196         _createDate = createDate;
197     }
198 
199     public Date getModifiedDate() {
200         return _modifiedDate;
201     }
202 
203     public void setModifiedDate(Date modifiedDate) {
204         _modifiedDate = modifiedDate;
205     }
206 
207     public String getClassName() {
208         if (getClassNameId() <= 0) {
209             return StringPool.BLANK;
210         }
211 
212         return PortalUtil.getClassName(getClassNameId());
213     }
214 
215     public long getClassNameId() {
216         return _classNameId;
217     }
218 
219     public void setClassNameId(long classNameId) {
220         _classNameId = classNameId;
221 
222         if (!_setOriginalClassNameId) {
223             _setOriginalClassNameId = true;
224 
225             _originalClassNameId = classNameId;
226         }
227     }
228 
229     public long getOriginalClassNameId() {
230         return _originalClassNameId;
231     }
232 
233     public long getClassPK() {
234         return _classPK;
235     }
236 
237     public void setClassPK(long classPK) {
238         _classPK = classPK;
239 
240         if (!_setOriginalClassPK) {
241             _setOriginalClassPK = true;
242 
243             _originalClassPK = classPK;
244         }
245     }
246 
247     public long getOriginalClassPK() {
248         return _originalClassPK;
249     }
250 
251     public double getScore() {
252         return _score;
253     }
254 
255     public void setScore(double score) {
256         _score = score;
257     }
258 
259     public RatingsEntry toEscapedModel() {
260         if (isEscapedModel()) {
261             return (RatingsEntry)this;
262         }
263         else {
264             RatingsEntry model = new RatingsEntryImpl();
265 
266             model.setNew(isNew());
267             model.setEscapedModel(true);
268 
269             model.setEntryId(getEntryId());
270             model.setCompanyId(getCompanyId());
271             model.setUserId(getUserId());
272             model.setUserName(HtmlUtil.escape(getUserName()));
273             model.setCreateDate(getCreateDate());
274             model.setModifiedDate(getModifiedDate());
275             model.setClassNameId(getClassNameId());
276             model.setClassPK(getClassPK());
277             model.setScore(getScore());
278 
279             model = (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
280                     new Class[] { RatingsEntry.class },
281                     new ReadOnlyBeanHandler(model));
282 
283             return model;
284         }
285     }
286 
287     public ExpandoBridge getExpandoBridge() {
288         if (_expandoBridge == null) {
289             _expandoBridge = new ExpandoBridgeImpl(RatingsEntry.class.getName(),
290                     getPrimaryKey());
291         }
292 
293         return _expandoBridge;
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 long _originalUserId;
433     private boolean _setOriginalUserId;
434     private String _userName;
435     private Date _createDate;
436     private Date _modifiedDate;
437     private long _classNameId;
438     private long _originalClassNameId;
439     private boolean _setOriginalClassNameId;
440     private long _classPK;
441     private long _originalClassPK;
442     private boolean _setOriginalClassPK;
443     private double _score;
444     private transient ExpandoBridge _expandoBridge;
445 }