1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.polls.model.impl;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import java.io.Serializable;
30  
31  import java.sql.Types;
32  
33  import java.util.Date;
34  
35  /**
36   * <a href="PollsVoteModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>PollsVote</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.polls.service.model.PollsVote
51   * @see com.liferay.portlet.polls.service.model.PollsVoteModel
52   * @see com.liferay.portlet.polls.service.model.impl.PollsVoteImpl
53   *
54   */
55  public class PollsVoteModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "PollsVote";
57      public static Object[][] TABLE_COLUMNS = {
58              { "voteId", new Integer(Types.BIGINT) },
59              { "userId", new Integer(Types.BIGINT) },
60              { "questionId", new Integer(Types.BIGINT) },
61              { "choiceId", new Integer(Types.BIGINT) },
62              { "voteDate", new Integer(Types.TIMESTAMP) }
63          };
64      public static String TABLE_SQL_CREATE = "create table PollsVote (voteId LONG not null primary key,userId LONG,questionId LONG,choiceId LONG,voteDate DATE null)";
65      public static String TABLE_SQL_DROP = "drop table PollsVote";
66      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
67                  "xss.allow.com.liferay.portlet.polls.model.PollsVote"),
68              XSS_ALLOW);
69      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
70                  "lock.expiration.time.com.liferay.portlet.polls.model.PollsVoteModel"));
71  
72      public PollsVoteModelImpl() {
73      }
74  
75      public long getPrimaryKey() {
76          return _voteId;
77      }
78  
79      public void setPrimaryKey(long pk) {
80          setVoteId(pk);
81      }
82  
83      public Serializable getPrimaryKeyObj() {
84          return new Long(_voteId);
85      }
86  
87      public long getVoteId() {
88          return _voteId;
89      }
90  
91      public void setVoteId(long voteId) {
92          if (voteId != _voteId) {
93              _voteId = voteId;
94          }
95      }
96  
97      public long getUserId() {
98          return _userId;
99      }
100 
101     public void setUserId(long userId) {
102         if (userId != _userId) {
103             _userId = userId;
104         }
105     }
106 
107     public long getQuestionId() {
108         return _questionId;
109     }
110 
111     public void setQuestionId(long questionId) {
112         if (questionId != _questionId) {
113             _questionId = questionId;
114         }
115     }
116 
117     public long getChoiceId() {
118         return _choiceId;
119     }
120 
121     public void setChoiceId(long choiceId) {
122         if (choiceId != _choiceId) {
123             _choiceId = choiceId;
124         }
125     }
126 
127     public Date getVoteDate() {
128         return _voteDate;
129     }
130 
131     public void setVoteDate(Date voteDate) {
132         if (((voteDate == null) && (_voteDate != null)) ||
133                 ((voteDate != null) && (_voteDate == null)) ||
134                 ((voteDate != null) && (_voteDate != null) &&
135                 !voteDate.equals(_voteDate))) {
136             _voteDate = voteDate;
137         }
138     }
139 
140     public Object clone() {
141         PollsVoteImpl clone = new PollsVoteImpl();
142         clone.setVoteId(getVoteId());
143         clone.setUserId(getUserId());
144         clone.setQuestionId(getQuestionId());
145         clone.setChoiceId(getChoiceId());
146         clone.setVoteDate(getVoteDate());
147 
148         return clone;
149     }
150 
151     public int compareTo(Object obj) {
152         if (obj == null) {
153             return -1;
154         }
155 
156         PollsVoteImpl pollsVote = (PollsVoteImpl)obj;
157         long pk = pollsVote.getPrimaryKey();
158 
159         if (getPrimaryKey() < pk) {
160             return -1;
161         }
162         else if (getPrimaryKey() > pk) {
163             return 1;
164         }
165         else {
166             return 0;
167         }
168     }
169 
170     public boolean equals(Object obj) {
171         if (obj == null) {
172             return false;
173         }
174 
175         PollsVoteImpl pollsVote = null;
176 
177         try {
178             pollsVote = (PollsVoteImpl)obj;
179         }
180         catch (ClassCastException cce) {
181             return false;
182         }
183 
184         long pk = pollsVote.getPrimaryKey();
185 
186         if (getPrimaryKey() == pk) {
187             return true;
188         }
189         else {
190             return false;
191         }
192     }
193 
194     public int hashCode() {
195         return (int)getPrimaryKey();
196     }
197 
198     private long _voteId;
199     private long _userId;
200     private long _questionId;
201     private long _choiceId;
202     private Date _voteDate;
203 }