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<PollsChoice> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
86 true);
87 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
88 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
89 true);
90
91 public static PollsChoice toModel(PollsChoiceSoap soapModel) {
92 PollsChoice model = new PollsChoiceImpl();
93
94 model.setUuid(soapModel.getUuid());
95 model.setChoiceId(soapModel.getChoiceId());
96 model.setQuestionId(soapModel.getQuestionId());
97 model.setName(soapModel.getName());
98 model.setDescription(soapModel.getDescription());
99
100 return model;
101 }
102
103 public static List<PollsChoice> toModels(PollsChoiceSoap[] soapModels) {
104 List<PollsChoice> models = new ArrayList<PollsChoice>(soapModels.length);
105
106 for (PollsChoiceSoap soapModel : soapModels) {
107 models.add(toModel(soapModel));
108 }
109
110 return models;
111 }
112
113 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114 "lock.expiration.time.com.liferay.portlet.polls.model.PollsChoice"));
115
116 public PollsChoiceModelImpl() {
117 }
118
119 public long getPrimaryKey() {
120 return _choiceId;
121 }
122
123 public void setPrimaryKey(long pk) {
124 setChoiceId(pk);
125 }
126
127 public Serializable getPrimaryKeyObj() {
128 return new Long(_choiceId);
129 }
130
131 public String getUuid() {
132 return GetterUtil.getString(_uuid);
133 }
134
135 public void setUuid(String uuid) {
136 _uuid = uuid;
137 }
138
139 public long getChoiceId() {
140 return _choiceId;
141 }
142
143 public void setChoiceId(long choiceId) {
144 _choiceId = choiceId;
145 }
146
147 public long getQuestionId() {
148 return _questionId;
149 }
150
151 public void setQuestionId(long questionId) {
152 _questionId = questionId;
153
154 if (!_setOriginalQuestionId) {
155 _setOriginalQuestionId = true;
156
157 _originalQuestionId = questionId;
158 }
159 }
160
161 public long getOriginalQuestionId() {
162 return _originalQuestionId;
163 }
164
165 public String getName() {
166 return GetterUtil.getString(_name);
167 }
168
169 public void setName(String name) {
170 _name = name;
171
172 if (_originalName == null) {
173 _originalName = name;
174 }
175 }
176
177 public String getOriginalName() {
178 return GetterUtil.getString(_originalName);
179 }
180
181 public String getDescription() {
182 return GetterUtil.getString(_description);
183 }
184
185 public void setDescription(String description) {
186 _description = description;
187 }
188
189 public PollsChoice toEscapedModel() {
190 if (isEscapedModel()) {
191 return (PollsChoice)this;
192 }
193 else {
194 PollsChoice model = new PollsChoiceImpl();
195
196 model.setNew(isNew());
197 model.setEscapedModel(true);
198
199 model.setUuid(HtmlUtil.escape(getUuid()));
200 model.setChoiceId(getChoiceId());
201 model.setQuestionId(getQuestionId());
202 model.setName(HtmlUtil.escape(getName()));
203 model.setDescription(HtmlUtil.escape(getDescription()));
204
205 model = (PollsChoice)Proxy.newProxyInstance(PollsChoice.class.getClassLoader(),
206 new Class[] { PollsChoice.class },
207 new ReadOnlyBeanHandler(model));
208
209 return model;
210 }
211 }
212
213 public Object clone() {
214 PollsChoiceImpl clone = new PollsChoiceImpl();
215
216 clone.setUuid(getUuid());
217 clone.setChoiceId(getChoiceId());
218 clone.setQuestionId(getQuestionId());
219 clone.setName(getName());
220 clone.setDescription(getDescription());
221
222 return clone;
223 }
224
225 public int compareTo(PollsChoice pollsChoice) {
226 int value = 0;
227
228 if (getQuestionId() < pollsChoice.getQuestionId()) {
229 value = -1;
230 }
231 else if (getQuestionId() > pollsChoice.getQuestionId()) {
232 value = 1;
233 }
234 else {
235 value = 0;
236 }
237
238 if (value != 0) {
239 return value;
240 }
241
242 value = getName().compareTo(pollsChoice.getName());
243
244 if (value != 0) {
245 return value;
246 }
247
248 return 0;
249 }
250
251 public boolean equals(Object obj) {
252 if (obj == null) {
253 return false;
254 }
255
256 PollsChoice pollsChoice = null;
257
258 try {
259 pollsChoice = (PollsChoice)obj;
260 }
261 catch (ClassCastException cce) {
262 return false;
263 }
264
265 long pk = pollsChoice.getPrimaryKey();
266
267 if (getPrimaryKey() == pk) {
268 return true;
269 }
270 else {
271 return false;
272 }
273 }
274
275 public int hashCode() {
276 return (int)getPrimaryKey();
277 }
278
279 public String toString() {
280 StringBuilder sb = new StringBuilder();
281
282 sb.append("{uuid=");
283 sb.append(getUuid());
284 sb.append(", choiceId=");
285 sb.append(getChoiceId());
286 sb.append(", questionId=");
287 sb.append(getQuestionId());
288 sb.append(", name=");
289 sb.append(getName());
290 sb.append(", description=");
291 sb.append(getDescription());
292 sb.append("}");
293
294 return sb.toString();
295 }
296
297 public String toXmlString() {
298 StringBuilder sb = new StringBuilder();
299
300 sb.append("<model><model-name>");
301 sb.append("com.liferay.portlet.polls.model.PollsChoice");
302 sb.append("</model-name>");
303
304 sb.append(
305 "<column><column-name>uuid</column-name><column-value><![CDATA[");
306 sb.append(getUuid());
307 sb.append("]]></column-value></column>");
308 sb.append(
309 "<column><column-name>choiceId</column-name><column-value><![CDATA[");
310 sb.append(getChoiceId());
311 sb.append("]]></column-value></column>");
312 sb.append(
313 "<column><column-name>questionId</column-name><column-value><![CDATA[");
314 sb.append(getQuestionId());
315 sb.append("]]></column-value></column>");
316 sb.append(
317 "<column><column-name>name</column-name><column-value><![CDATA[");
318 sb.append(getName());
319 sb.append("]]></column-value></column>");
320 sb.append(
321 "<column><column-name>description</column-name><column-value><![CDATA[");
322 sb.append(getDescription());
323 sb.append("]]></column-value></column>");
324
325 sb.append("</model>");
326
327 return sb.toString();
328 }
329
330 private String _uuid;
331 private long _choiceId;
332 private long _questionId;
333 private long _originalQuestionId;
334 private boolean _setOriginalQuestionId;
335 private String _name;
336 private String _originalName;
337 private String _description;
338 }