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