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.polls.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.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    import com.liferay.portal.util.PortalUtil;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    import com.liferay.portlet.polls.model.PollsVote;
028    import com.liferay.portlet.polls.model.PollsVoteModel;
029    import com.liferay.portlet.polls.model.PollsVoteSoap;
030    
031    import java.io.Serializable;
032    
033    import java.lang.reflect.Proxy;
034    
035    import java.sql.Types;
036    
037    import java.util.ArrayList;
038    import java.util.Date;
039    import java.util.List;
040    
041    /**
042     * <p>
043     * This interface is a model that represents the PollsVote table in the
044     * database.
045     * </p>
046     *
047     * @author    Brian Wing Shun Chan
048     * @see       PollsVoteImpl
049     * @see       com.liferay.portlet.polls.model.PollsVote
050     * @see       com.liferay.portlet.polls.model.PollsVoteModel
051     * @generated
052     */
053    public class PollsVoteModelImpl extends BaseModelImpl<PollsVote>
054            implements PollsVoteModel {
055            public static final String TABLE_NAME = "PollsVote";
056            public static final Object[][] TABLE_COLUMNS = {
057                            { "voteId", new Integer(Types.BIGINT) },
058                            { "userId", new Integer(Types.BIGINT) },
059                            { "questionId", new Integer(Types.BIGINT) },
060                            { "choiceId", new Integer(Types.BIGINT) },
061                            { "voteDate", new Integer(Types.TIMESTAMP) }
062                    };
063            public static final String TABLE_SQL_CREATE = "create table PollsVote (voteId LONG not null primary key,userId LONG,questionId LONG,choiceId LONG,voteDate DATE null)";
064            public static final String TABLE_SQL_DROP = "drop table PollsVote";
065            public static final String DATA_SOURCE = "liferayDataSource";
066            public static final String SESSION_FACTORY = "liferaySessionFactory";
067            public static final String TX_MANAGER = "liferayTransactionManager";
068            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069                                    "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
070                            true);
071            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072                                    "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
073                            true);
074    
075            public static PollsVote toModel(PollsVoteSoap soapModel) {
076                    PollsVote model = new PollsVoteImpl();
077    
078                    model.setVoteId(soapModel.getVoteId());
079                    model.setUserId(soapModel.getUserId());
080                    model.setQuestionId(soapModel.getQuestionId());
081                    model.setChoiceId(soapModel.getChoiceId());
082                    model.setVoteDate(soapModel.getVoteDate());
083    
084                    return model;
085            }
086    
087            public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
088                    List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
089    
090                    for (PollsVoteSoap soapModel : soapModels) {
091                            models.add(toModel(soapModel));
092                    }
093    
094                    return models;
095            }
096    
097            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
098                                    "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
099    
100            public PollsVoteModelImpl() {
101            }
102    
103            public long getPrimaryKey() {
104                    return _voteId;
105            }
106    
107            public void setPrimaryKey(long pk) {
108                    setVoteId(pk);
109            }
110    
111            public Serializable getPrimaryKeyObj() {
112                    return new Long(_voteId);
113            }
114    
115            public long getVoteId() {
116                    return _voteId;
117            }
118    
119            public void setVoteId(long voteId) {
120                    _voteId = voteId;
121            }
122    
123            public long getUserId() {
124                    return _userId;
125            }
126    
127            public void setUserId(long userId) {
128                    _userId = userId;
129    
130                    if (!_setOriginalUserId) {
131                            _setOriginalUserId = true;
132    
133                            _originalUserId = userId;
134                    }
135            }
136    
137            public String getUserUuid() throws SystemException {
138                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
139            }
140    
141            public void setUserUuid(String userUuid) {
142                    _userUuid = userUuid;
143            }
144    
145            public long getOriginalUserId() {
146                    return _originalUserId;
147            }
148    
149            public long getQuestionId() {
150                    return _questionId;
151            }
152    
153            public void setQuestionId(long questionId) {
154                    _questionId = questionId;
155    
156                    if (!_setOriginalQuestionId) {
157                            _setOriginalQuestionId = true;
158    
159                            _originalQuestionId = questionId;
160                    }
161            }
162    
163            public long getOriginalQuestionId() {
164                    return _originalQuestionId;
165            }
166    
167            public long getChoiceId() {
168                    return _choiceId;
169            }
170    
171            public void setChoiceId(long choiceId) {
172                    _choiceId = choiceId;
173            }
174    
175            public Date getVoteDate() {
176                    return _voteDate;
177            }
178    
179            public void setVoteDate(Date voteDate) {
180                    _voteDate = voteDate;
181            }
182    
183            public PollsVote toEscapedModel() {
184                    if (isEscapedModel()) {
185                            return (PollsVote)this;
186                    }
187                    else {
188                            return (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
189                                    new Class[] { PollsVote.class }, new AutoEscapeBeanHandler(this));
190                    }
191            }
192    
193            public ExpandoBridge getExpandoBridge() {
194                    if (_expandoBridge == null) {
195                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
196                                            PollsVote.class.getName(), getPrimaryKey());
197                    }
198    
199                    return _expandoBridge;
200            }
201    
202            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
203                    getExpandoBridge().setAttributes(serviceContext);
204            }
205    
206            public Object clone() {
207                    PollsVoteImpl clone = new PollsVoteImpl();
208    
209                    clone.setVoteId(getVoteId());
210                    clone.setUserId(getUserId());
211                    clone.setQuestionId(getQuestionId());
212                    clone.setChoiceId(getChoiceId());
213                    clone.setVoteDate(getVoteDate());
214    
215                    return clone;
216            }
217    
218            public int compareTo(PollsVote pollsVote) {
219                    long pk = pollsVote.getPrimaryKey();
220    
221                    if (getPrimaryKey() < pk) {
222                            return -1;
223                    }
224                    else if (getPrimaryKey() > pk) {
225                            return 1;
226                    }
227                    else {
228                            return 0;
229                    }
230            }
231    
232            public boolean equals(Object obj) {
233                    if (obj == null) {
234                            return false;
235                    }
236    
237                    PollsVote pollsVote = null;
238    
239                    try {
240                            pollsVote = (PollsVote)obj;
241                    }
242                    catch (ClassCastException cce) {
243                            return false;
244                    }
245    
246                    long pk = pollsVote.getPrimaryKey();
247    
248                    if (getPrimaryKey() == pk) {
249                            return true;
250                    }
251                    else {
252                            return false;
253                    }
254            }
255    
256            public int hashCode() {
257                    return (int)getPrimaryKey();
258            }
259    
260            public String toString() {
261                    StringBundler sb = new StringBundler(11);
262    
263                    sb.append("{voteId=");
264                    sb.append(getVoteId());
265                    sb.append(", userId=");
266                    sb.append(getUserId());
267                    sb.append(", questionId=");
268                    sb.append(getQuestionId());
269                    sb.append(", choiceId=");
270                    sb.append(getChoiceId());
271                    sb.append(", voteDate=");
272                    sb.append(getVoteDate());
273                    sb.append("}");
274    
275                    return sb.toString();
276            }
277    
278            public String toXmlString() {
279                    StringBundler sb = new StringBundler(19);
280    
281                    sb.append("<model><model-name>");
282                    sb.append("com.liferay.portlet.polls.model.PollsVote");
283                    sb.append("</model-name>");
284    
285                    sb.append(
286                            "<column><column-name>voteId</column-name><column-value><![CDATA[");
287                    sb.append(getVoteId());
288                    sb.append("]]></column-value></column>");
289                    sb.append(
290                            "<column><column-name>userId</column-name><column-value><![CDATA[");
291                    sb.append(getUserId());
292                    sb.append("]]></column-value></column>");
293                    sb.append(
294                            "<column><column-name>questionId</column-name><column-value><![CDATA[");
295                    sb.append(getQuestionId());
296                    sb.append("]]></column-value></column>");
297                    sb.append(
298                            "<column><column-name>choiceId</column-name><column-value><![CDATA[");
299                    sb.append(getChoiceId());
300                    sb.append("]]></column-value></column>");
301                    sb.append(
302                            "<column><column-name>voteDate</column-name><column-value><![CDATA[");
303                    sb.append(getVoteDate());
304                    sb.append("]]></column-value></column>");
305    
306                    sb.append("</model>");
307    
308                    return sb.toString();
309            }
310    
311            private long _voteId;
312            private long _userId;
313            private String _userUuid;
314            private long _originalUserId;
315            private boolean _setOriginalUserId;
316            private long _questionId;
317            private long _originalQuestionId;
318            private boolean _setOriginalQuestionId;
319            private long _choiceId;
320            private Date _voteDate;
321            private transient ExpandoBridge _expandoBridge;
322    }