1
22
23 package com.liferay.portlet.polls.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.impl.BaseModelImpl;
29
30 import com.liferay.portlet.polls.model.PollsChoice;
31 import com.liferay.portlet.polls.model.PollsChoiceSoap;
32
33 import java.io.Serializable;
34
35 import java.lang.reflect.Proxy;
36
37 import java.sql.Types;
38
39 import java.util.ArrayList;
40 import java.util.List;
41
42
62 public class PollsChoiceModelImpl extends BaseModelImpl {
63 public static final String TABLE_NAME = "PollsChoice";
64 public static final Object[][] TABLE_COLUMNS = {
65 { "uuid_", new Integer(Types.VARCHAR) },
66
67
68 { "choiceId", new Integer(Types.BIGINT) },
69
70
71 { "questionId", new Integer(Types.BIGINT) },
72
73
74 { "name", new Integer(Types.VARCHAR) },
75
76
77 { "description", new Integer(Types.VARCHAR) }
78 };
79 public static final String TABLE_SQL_CREATE = "create table PollsChoice (uuid_ VARCHAR(75) null,choiceId LONG not null primary key,questionId LONG,name VARCHAR(75) null,description VARCHAR(1000) null)";
80 public static final String TABLE_SQL_DROP = "drop table PollsChoice";
81 public static final String DATA_SOURCE = "liferayDataSource";
82 public static final String SESSION_FACTORY = "liferaySessionFactory";
83 public static final String TX_MANAGER = "liferayTransactionManager";
84 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
86 true);
87
88 public static PollsChoice toModel(PollsChoiceSoap soapModel) {
89 PollsChoice model = new PollsChoiceImpl();
90
91 model.setUuid(soapModel.getUuid());
92 model.setChoiceId(soapModel.getChoiceId());
93 model.setQuestionId(soapModel.getQuestionId());
94 model.setName(soapModel.getName());
95 model.setDescription(soapModel.getDescription());
96
97 return model;
98 }
99
100 public static List<PollsChoice> toModels(PollsChoiceSoap[] soapModels) {
101 List<PollsChoice> models = new ArrayList<PollsChoice>(soapModels.length);
102
103 for (PollsChoiceSoap soapModel : soapModels) {
104 models.add(toModel(soapModel));
105 }
106
107 return models;
108 }
109
110 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111 "lock.expiration.time.com.liferay.portlet.polls.model.PollsChoice"));
112
113 public PollsChoiceModelImpl() {
114 }
115
116 public long getPrimaryKey() {
117 return _choiceId;
118 }
119
120 public void setPrimaryKey(long pk) {
121 setChoiceId(pk);
122 }
123
124 public Serializable getPrimaryKeyObj() {
125 return new Long(_choiceId);
126 }
127
128 public String getUuid() {
129 return GetterUtil.getString(_uuid);
130 }
131
132 public void setUuid(String uuid) {
133 if ((uuid != null) && (uuid != _uuid)) {
134 _uuid = uuid;
135 }
136 }
137
138 public long getChoiceId() {
139 return _choiceId;
140 }
141
142 public void setChoiceId(long choiceId) {
143 if (choiceId != _choiceId) {
144 _choiceId = choiceId;
145 }
146 }
147
148 public long getQuestionId() {
149 return _questionId;
150 }
151
152 public void setQuestionId(long questionId) {
153 if (questionId != _questionId) {
154 _questionId = questionId;
155 }
156 }
157
158 public String getName() {
159 return GetterUtil.getString(_name);
160 }
161
162 public void setName(String name) {
163 if (((name == null) && (_name != null)) ||
164 ((name != null) && (_name == null)) ||
165 ((name != null) && (_name != null) && !name.equals(_name))) {
166 _name = name;
167 }
168 }
169
170 public String getDescription() {
171 return GetterUtil.getString(_description);
172 }
173
174 public void setDescription(String description) {
175 if (((description == null) && (_description != null)) ||
176 ((description != null) && (_description == null)) ||
177 ((description != null) && (_description != null) &&
178 !description.equals(_description))) {
179 _description = description;
180 }
181 }
182
183 public PollsChoice toEscapedModel() {
184 if (isEscapedModel()) {
185 return (PollsChoice)this;
186 }
187 else {
188 PollsChoice model = new PollsChoiceImpl();
189
190 model.setEscapedModel(true);
191
192 model.setUuid(HtmlUtil.escape(getUuid()));
193 model.setChoiceId(getChoiceId());
194 model.setQuestionId(getQuestionId());
195 model.setName(HtmlUtil.escape(getName()));
196 model.setDescription(HtmlUtil.escape(getDescription()));
197
198 model = (PollsChoice)Proxy.newProxyInstance(PollsChoice.class.getClassLoader(),
199 new Class[] { PollsChoice.class },
200 new ReadOnlyBeanHandler(model));
201
202 return model;
203 }
204 }
205
206 public Object clone() {
207 PollsChoiceImpl clone = new PollsChoiceImpl();
208
209 clone.setUuid(getUuid());
210 clone.setChoiceId(getChoiceId());
211 clone.setQuestionId(getQuestionId());
212 clone.setName(getName());
213 clone.setDescription(getDescription());
214
215 return clone;
216 }
217
218 public int compareTo(Object obj) {
219 if (obj == null) {
220 return -1;
221 }
222
223 PollsChoiceImpl pollsChoice = (PollsChoiceImpl)obj;
224
225 int value = 0;
226
227 if (getQuestionId() < pollsChoice.getQuestionId()) {
228 value = -1;
229 }
230 else if (getQuestionId() > pollsChoice.getQuestionId()) {
231 value = 1;
232 }
233 else {
234 value = 0;
235 }
236
237 if (value != 0) {
238 return value;
239 }
240
241 value = getName().compareTo(pollsChoice.getName());
242
243 if (value != 0) {
244 return value;
245 }
246
247 return 0;
248 }
249
250 public boolean equals(Object obj) {
251 if (obj == null) {
252 return false;
253 }
254
255 PollsChoiceImpl pollsChoice = null;
256
257 try {
258 pollsChoice = (PollsChoiceImpl)obj;
259 }
260 catch (ClassCastException cce) {
261 return false;
262 }
263
264 long pk = pollsChoice.getPrimaryKey();
265
266 if (getPrimaryKey() == pk) {
267 return true;
268 }
269 else {
270 return false;
271 }
272 }
273
274 public int hashCode() {
275 return (int)getPrimaryKey();
276 }
277
278 private String _uuid;
279 private long _choiceId;
280 private long _questionId;
281 private String _name;
282 private String _description;
283 }