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.expando.model.ExpandoBridge;
31 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32 import com.liferay.portlet.polls.model.PollsChoice;
33 import com.liferay.portlet.polls.model.PollsChoiceSoap;
34
35 import java.io.Serializable;
36
37 import java.lang.reflect.Proxy;
38
39 import java.sql.Types;
40
41 import java.util.ArrayList;
42 import java.util.List;
43
44
64 public class PollsChoiceModelImpl extends BaseModelImpl<PollsChoice> {
65 public static final String TABLE_NAME = "PollsChoice";
66 public static final Object[][] TABLE_COLUMNS = {
67 { "uuid_", new Integer(Types.VARCHAR) },
68
69
70 { "choiceId", new Integer(Types.BIGINT) },
71
72
73 { "questionId", new Integer(Types.BIGINT) },
74
75
76 { "name", new Integer(Types.VARCHAR) },
77
78
79 { "description", new Integer(Types.VARCHAR) }
80 };
81 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)";
82 public static final String TABLE_SQL_DROP = "drop table PollsChoice";
83 public static final String DATA_SOURCE = "liferayDataSource";
84 public static final String SESSION_FACTORY = "liferaySessionFactory";
85 public static final String TX_MANAGER = "liferayTransactionManager";
86 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
88 true);
89 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
91 true);
92
93 public static PollsChoice toModel(PollsChoiceSoap soapModel) {
94 PollsChoice model = new PollsChoiceImpl();
95
96 model.setUuid(soapModel.getUuid());
97 model.setChoiceId(soapModel.getChoiceId());
98 model.setQuestionId(soapModel.getQuestionId());
99 model.setName(soapModel.getName());
100 model.setDescription(soapModel.getDescription());
101
102 return model;
103 }
104
105 public static List<PollsChoice> toModels(PollsChoiceSoap[] soapModels) {
106 List<PollsChoice> models = new ArrayList<PollsChoice>(soapModels.length);
107
108 for (PollsChoiceSoap soapModel : soapModels) {
109 models.add(toModel(soapModel));
110 }
111
112 return models;
113 }
114
115 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
116 "lock.expiration.time.com.liferay.portlet.polls.model.PollsChoice"));
117
118 public PollsChoiceModelImpl() {
119 }
120
121 public long getPrimaryKey() {
122 return _choiceId;
123 }
124
125 public void setPrimaryKey(long pk) {
126 setChoiceId(pk);
127 }
128
129 public Serializable getPrimaryKeyObj() {
130 return new Long(_choiceId);
131 }
132
133 public String getUuid() {
134 return GetterUtil.getString(_uuid);
135 }
136
137 public void setUuid(String uuid) {
138 _uuid = uuid;
139 }
140
141 public long getChoiceId() {
142 return _choiceId;
143 }
144
145 public void setChoiceId(long choiceId) {
146 _choiceId = choiceId;
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 String getName() {
168 return GetterUtil.getString(_name);
169 }
170
171 public void setName(String name) {
172 _name = name;
173
174 if (_originalName == null) {
175 _originalName = name;
176 }
177 }
178
179 public String getOriginalName() {
180 return GetterUtil.getString(_originalName);
181 }
182
183 public String getDescription() {
184 return GetterUtil.getString(_description);
185 }
186
187 public void setDescription(String description) {
188 _description = description;
189 }
190
191 public PollsChoice toEscapedModel() {
192 if (isEscapedModel()) {
193 return (PollsChoice)this;
194 }
195 else {
196 PollsChoice model = new PollsChoiceImpl();
197
198 model.setNew(isNew());
199 model.setEscapedModel(true);
200
201 model.setUuid(HtmlUtil.escape(getUuid()));
202 model.setChoiceId(getChoiceId());
203 model.setQuestionId(getQuestionId());
204 model.setName(HtmlUtil.escape(getName()));
205 model.setDescription(HtmlUtil.escape(getDescription()));
206
207 model = (PollsChoice)Proxy.newProxyInstance(PollsChoice.class.getClassLoader(),
208 new Class[] { PollsChoice.class },
209 new ReadOnlyBeanHandler(model));
210
211 return model;
212 }
213 }
214
215 public ExpandoBridge getExpandoBridge() {
216 if (_expandoBridge == null) {
217 _expandoBridge = new ExpandoBridgeImpl(PollsChoice.class.getName(),
218 getPrimaryKey());
219 }
220
221 return _expandoBridge;
222 }
223
224 public Object clone() {
225 PollsChoiceImpl clone = new PollsChoiceImpl();
226
227 clone.setUuid(getUuid());
228 clone.setChoiceId(getChoiceId());
229 clone.setQuestionId(getQuestionId());
230 clone.setName(getName());
231 clone.setDescription(getDescription());
232
233 return clone;
234 }
235
236 public int compareTo(PollsChoice pollsChoice) {
237 int value = 0;
238
239 if (getQuestionId() < pollsChoice.getQuestionId()) {
240 value = -1;
241 }
242 else if (getQuestionId() > pollsChoice.getQuestionId()) {
243 value = 1;
244 }
245 else {
246 value = 0;
247 }
248
249 if (value != 0) {
250 return value;
251 }
252
253 value = getName().compareTo(pollsChoice.getName());
254
255 if (value != 0) {
256 return value;
257 }
258
259 return 0;
260 }
261
262 public boolean equals(Object obj) {
263 if (obj == null) {
264 return false;
265 }
266
267 PollsChoice pollsChoice = null;
268
269 try {
270 pollsChoice = (PollsChoice)obj;
271 }
272 catch (ClassCastException cce) {
273 return false;
274 }
275
276 long pk = pollsChoice.getPrimaryKey();
277
278 if (getPrimaryKey() == pk) {
279 return true;
280 }
281 else {
282 return false;
283 }
284 }
285
286 public int hashCode() {
287 return (int)getPrimaryKey();
288 }
289
290 public String toString() {
291 StringBuilder sb = new StringBuilder();
292
293 sb.append("{uuid=");
294 sb.append(getUuid());
295 sb.append(", choiceId=");
296 sb.append(getChoiceId());
297 sb.append(", questionId=");
298 sb.append(getQuestionId());
299 sb.append(", name=");
300 sb.append(getName());
301 sb.append(", description=");
302 sb.append(getDescription());
303 sb.append("}");
304
305 return sb.toString();
306 }
307
308 public String toXmlString() {
309 StringBuilder sb = new StringBuilder();
310
311 sb.append("<model><model-name>");
312 sb.append("com.liferay.portlet.polls.model.PollsChoice");
313 sb.append("</model-name>");
314
315 sb.append(
316 "<column><column-name>uuid</column-name><column-value><![CDATA[");
317 sb.append(getUuid());
318 sb.append("]]></column-value></column>");
319 sb.append(
320 "<column><column-name>choiceId</column-name><column-value><![CDATA[");
321 sb.append(getChoiceId());
322 sb.append("]]></column-value></column>");
323 sb.append(
324 "<column><column-name>questionId</column-name><column-value><![CDATA[");
325 sb.append(getQuestionId());
326 sb.append("]]></column-value></column>");
327 sb.append(
328 "<column><column-name>name</column-name><column-value><![CDATA[");
329 sb.append(getName());
330 sb.append("]]></column-value></column>");
331 sb.append(
332 "<column><column-name>description</column-name><column-value><![CDATA[");
333 sb.append(getDescription());
334 sb.append("]]></column-value></column>");
335
336 sb.append("</model>");
337
338 return sb.toString();
339 }
340
341 private String _uuid;
342 private long _choiceId;
343 private long _questionId;
344 private long _originalQuestionId;
345 private boolean _setOriginalQuestionId;
346 private String _name;
347 private String _originalName;
348 private String _description;
349 private transient ExpandoBridge _expandoBridge;
350 }