001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.ratings.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.ratings.model.RatingsEntry;
029    import com.liferay.portlet.ratings.model.RatingsEntryModel;
030    import com.liferay.portlet.ratings.model.RatingsEntrySoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * <p>
044     * This interface is a model that represents the RatingsEntry table in the
045     * database.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       RatingsEntryImpl
050     * @see       com.liferay.portlet.ratings.model.RatingsEntry
051     * @see       com.liferay.portlet.ratings.model.RatingsEntryModel
052     * @generated
053     */
054    public class RatingsEntryModelImpl extends BaseModelImpl<RatingsEntry>
055            implements RatingsEntryModel {
056            public static final String TABLE_NAME = "RatingsEntry";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "entryId", new Integer(Types.BIGINT) },
059                            { "companyId", new Integer(Types.BIGINT) },
060                            { "userId", new Integer(Types.BIGINT) },
061                            { "userName", new Integer(Types.VARCHAR) },
062                            { "createDate", new Integer(Types.TIMESTAMP) },
063                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
064                            { "classNameId", new Integer(Types.BIGINT) },
065                            { "classPK", new Integer(Types.BIGINT) },
066                            { "score", new Integer(Types.DOUBLE) }
067                    };
068            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)";
069            public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
078                            true);
079    
080            public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
081                    RatingsEntry model = new RatingsEntryImpl();
082    
083                    model.setEntryId(soapModel.getEntryId());
084                    model.setCompanyId(soapModel.getCompanyId());
085                    model.setUserId(soapModel.getUserId());
086                    model.setUserName(soapModel.getUserName());
087                    model.setCreateDate(soapModel.getCreateDate());
088                    model.setModifiedDate(soapModel.getModifiedDate());
089                    model.setClassNameId(soapModel.getClassNameId());
090                    model.setClassPK(soapModel.getClassPK());
091                    model.setScore(soapModel.getScore());
092    
093                    return model;
094            }
095    
096            public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
097                    List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
098    
099                    for (RatingsEntrySoap soapModel : soapModels) {
100                            models.add(toModel(soapModel));
101                    }
102    
103                    return models;
104            }
105    
106            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
107                                    "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsEntry"));
108    
109            public RatingsEntryModelImpl() {
110            }
111    
112            public long getPrimaryKey() {
113                    return _entryId;
114            }
115    
116            public void setPrimaryKey(long pk) {
117                    setEntryId(pk);
118            }
119    
120            public Serializable getPrimaryKeyObj() {
121                    return new Long(_entryId);
122            }
123    
124            public long getEntryId() {
125                    return _entryId;
126            }
127    
128            public void setEntryId(long entryId) {
129                    _entryId = entryId;
130            }
131    
132            public long getCompanyId() {
133                    return _companyId;
134            }
135    
136            public void setCompanyId(long companyId) {
137                    _companyId = companyId;
138            }
139    
140            public long getUserId() {
141                    return _userId;
142            }
143    
144            public void setUserId(long userId) {
145                    _userId = userId;
146    
147                    if (!_setOriginalUserId) {
148                            _setOriginalUserId = true;
149    
150                            _originalUserId = userId;
151                    }
152            }
153    
154            public String getUserUuid() throws SystemException {
155                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
156            }
157    
158            public void setUserUuid(String userUuid) {
159                    _userUuid = userUuid;
160            }
161    
162            public long getOriginalUserId() {
163                    return _originalUserId;
164            }
165    
166            public String getUserName() {
167                    if (_userName == null) {
168                            return StringPool.BLANK;
169                    }
170                    else {
171                            return _userName;
172                    }
173            }
174    
175            public void setUserName(String userName) {
176                    _userName = userName;
177            }
178    
179            public Date getCreateDate() {
180                    return _createDate;
181            }
182    
183            public void setCreateDate(Date createDate) {
184                    _createDate = createDate;
185            }
186    
187            public Date getModifiedDate() {
188                    return _modifiedDate;
189            }
190    
191            public void setModifiedDate(Date modifiedDate) {
192                    _modifiedDate = modifiedDate;
193            }
194    
195            public String getClassName() {
196                    if (getClassNameId() <= 0) {
197                            return StringPool.BLANK;
198                    }
199    
200                    return PortalUtil.getClassName(getClassNameId());
201            }
202    
203            public long getClassNameId() {
204                    return _classNameId;
205            }
206    
207            public void setClassNameId(long classNameId) {
208                    _classNameId = classNameId;
209    
210                    if (!_setOriginalClassNameId) {
211                            _setOriginalClassNameId = true;
212    
213                            _originalClassNameId = classNameId;
214                    }
215            }
216    
217            public long getOriginalClassNameId() {
218                    return _originalClassNameId;
219            }
220    
221            public long getClassPK() {
222                    return _classPK;
223            }
224    
225            public void setClassPK(long classPK) {
226                    _classPK = classPK;
227    
228                    if (!_setOriginalClassPK) {
229                            _setOriginalClassPK = true;
230    
231                            _originalClassPK = classPK;
232                    }
233            }
234    
235            public long getOriginalClassPK() {
236                    return _originalClassPK;
237            }
238    
239            public double getScore() {
240                    return _score;
241            }
242    
243            public void setScore(double score) {
244                    _score = score;
245            }
246    
247            public RatingsEntry toEscapedModel() {
248                    if (isEscapedModel()) {
249                            return (RatingsEntry)this;
250                    }
251                    else {
252                            return (RatingsEntry)Proxy.newProxyInstance(RatingsEntry.class.getClassLoader(),
253                                    new Class[] { RatingsEntry.class },
254                                    new AutoEscapeBeanHandler(this));
255                    }
256            }
257    
258            public ExpandoBridge getExpandoBridge() {
259                    if (_expandoBridge == null) {
260                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
261                                            RatingsEntry.class.getName(), getPrimaryKey());
262                    }
263    
264                    return _expandoBridge;
265            }
266    
267            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
268                    getExpandoBridge().setAttributes(serviceContext);
269            }
270    
271            public Object clone() {
272                    RatingsEntryImpl clone = new RatingsEntryImpl();
273    
274                    clone.setEntryId(getEntryId());
275                    clone.setCompanyId(getCompanyId());
276                    clone.setUserId(getUserId());
277                    clone.setUserName(getUserName());
278                    clone.setCreateDate(getCreateDate());
279                    clone.setModifiedDate(getModifiedDate());
280                    clone.setClassNameId(getClassNameId());
281                    clone.setClassPK(getClassPK());
282                    clone.setScore(getScore());
283    
284                    return clone;
285            }
286    
287            public int compareTo(RatingsEntry ratingsEntry) {
288                    long pk = ratingsEntry.getPrimaryKey();
289    
290                    if (getPrimaryKey() < pk) {
291                            return -1;
292                    }
293                    else if (getPrimaryKey() > pk) {
294                            return 1;
295                    }
296                    else {
297                            return 0;
298                    }
299            }
300    
301            public boolean equals(Object obj) {
302                    if (obj == null) {
303                            return false;
304                    }
305    
306                    RatingsEntry ratingsEntry = null;
307    
308                    try {
309                            ratingsEntry = (RatingsEntry)obj;
310                    }
311                    catch (ClassCastException cce) {
312                            return false;
313                    }
314    
315                    long pk = ratingsEntry.getPrimaryKey();
316    
317                    if (getPrimaryKey() == pk) {
318                            return true;
319                    }
320                    else {
321                            return false;
322                    }
323            }
324    
325            public int hashCode() {
326                    return (int)getPrimaryKey();
327            }
328    
329            public String toString() {
330                    StringBundler sb = new StringBundler(19);
331    
332                    sb.append("{entryId=");
333                    sb.append(getEntryId());
334                    sb.append(", companyId=");
335                    sb.append(getCompanyId());
336                    sb.append(", userId=");
337                    sb.append(getUserId());
338                    sb.append(", userName=");
339                    sb.append(getUserName());
340                    sb.append(", createDate=");
341                    sb.append(getCreateDate());
342                    sb.append(", modifiedDate=");
343                    sb.append(getModifiedDate());
344                    sb.append(", classNameId=");
345                    sb.append(getClassNameId());
346                    sb.append(", classPK=");
347                    sb.append(getClassPK());
348                    sb.append(", score=");
349                    sb.append(getScore());
350                    sb.append("}");
351    
352                    return sb.toString();
353            }
354    
355            public String toXmlString() {
356                    StringBundler sb = new StringBundler(31);
357    
358                    sb.append("<model><model-name>");
359                    sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
360                    sb.append("</model-name>");
361    
362                    sb.append(
363                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
364                    sb.append(getEntryId());
365                    sb.append("]]></column-value></column>");
366                    sb.append(
367                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
368                    sb.append(getCompanyId());
369                    sb.append("]]></column-value></column>");
370                    sb.append(
371                            "<column><column-name>userId</column-name><column-value><![CDATA[");
372                    sb.append(getUserId());
373                    sb.append("]]></column-value></column>");
374                    sb.append(
375                            "<column><column-name>userName</column-name><column-value><![CDATA[");
376                    sb.append(getUserName());
377                    sb.append("]]></column-value></column>");
378                    sb.append(
379                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
380                    sb.append(getCreateDate());
381                    sb.append("]]></column-value></column>");
382                    sb.append(
383                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
384                    sb.append(getModifiedDate());
385                    sb.append("]]></column-value></column>");
386                    sb.append(
387                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
388                    sb.append(getClassNameId());
389                    sb.append("]]></column-value></column>");
390                    sb.append(
391                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
392                    sb.append(getClassPK());
393                    sb.append("]]></column-value></column>");
394                    sb.append(
395                            "<column><column-name>score</column-name><column-value><![CDATA[");
396                    sb.append(getScore());
397                    sb.append("]]></column-value></column>");
398    
399                    sb.append("</model>");
400    
401                    return sb.toString();
402            }
403    
404            private long _entryId;
405            private long _companyId;
406            private long _userId;
407            private String _userUuid;
408            private long _originalUserId;
409            private boolean _setOriginalUserId;
410            private String _userName;
411            private Date _createDate;
412            private Date _modifiedDate;
413            private long _classNameId;
414            private long _originalClassNameId;
415            private boolean _setOriginalClassNameId;
416            private long _classPK;
417            private long _originalClassPK;
418            private boolean _setOriginalClassPK;
419            private double _score;
420            private transient ExpandoBridge _expandoBridge;
421    }