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.kernel.util.StringBundler;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30 import com.liferay.portal.service.ServiceContext;
31
32 import com.liferay.portlet.expando.model.ExpandoBridge;
33 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
34 import com.liferay.portlet.polls.model.PollsChoice;
35 import com.liferay.portlet.polls.model.PollsChoiceSoap;
36
37 import java.io.Serializable;
38
39 import java.lang.reflect.Proxy;
40
41 import java.sql.Types;
42
43 import java.util.ArrayList;
44 import java.util.List;
45
46
65 public class PollsChoiceModelImpl extends BaseModelImpl<PollsChoice> {
66 public static final String TABLE_NAME = "PollsChoice";
67 public static final Object[][] TABLE_COLUMNS = {
68 { "uuid_", new Integer(Types.VARCHAR) },
69 { "choiceId", new Integer(Types.BIGINT) },
70 { "questionId", new Integer(Types.BIGINT) },
71 { "name", new Integer(Types.VARCHAR) },
72 { "description", new Integer(Types.VARCHAR) }
73 };
74 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)";
75 public static final String TABLE_SQL_DROP = "drop table PollsChoice";
76 public static final String ORDER_BY_JPQL = " ORDER BY pollsChoice.questionId ASC, pollsChoice.name ASC";
77 public static final String ORDER_BY_SQL = " ORDER BY PollsChoice.questionId ASC, PollsChoice.name ASC";
78 public static final String DATA_SOURCE = "liferayDataSource";
79 public static final String SESSION_FACTORY = "liferaySessionFactory";
80 public static final String TX_MANAGER = "liferayTransactionManager";
81 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
83 true);
84 public static final boolean FINDER_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 _uuid = uuid;
134 }
135
136 public long getChoiceId() {
137 return _choiceId;
138 }
139
140 public void setChoiceId(long choiceId) {
141 _choiceId = choiceId;
142 }
143
144 public long getQuestionId() {
145 return _questionId;
146 }
147
148 public void setQuestionId(long questionId) {
149 _questionId = questionId;
150
151 if (!_setOriginalQuestionId) {
152 _setOriginalQuestionId = true;
153
154 _originalQuestionId = questionId;
155 }
156 }
157
158 public long getOriginalQuestionId() {
159 return _originalQuestionId;
160 }
161
162 public String getName() {
163 return GetterUtil.getString(_name);
164 }
165
166 public void setName(String name) {
167 _name = name;
168
169 if (_originalName == null) {
170 _originalName = name;
171 }
172 }
173
174 public String getOriginalName() {
175 return GetterUtil.getString(_originalName);
176 }
177
178 public String getDescription() {
179 return GetterUtil.getString(_description);
180 }
181
182 public void setDescription(String description) {
183 _description = description;
184 }
185
186 public PollsChoice toEscapedModel() {
187 if (isEscapedModel()) {
188 return (PollsChoice)this;
189 }
190 else {
191 PollsChoice model = new PollsChoiceImpl();
192
193 model.setNew(isNew());
194 model.setEscapedModel(true);
195
196 model.setUuid(HtmlUtil.escape(getUuid()));
197 model.setChoiceId(getChoiceId());
198 model.setQuestionId(getQuestionId());
199 model.setName(HtmlUtil.escape(getName()));
200 model.setDescription(HtmlUtil.escape(getDescription()));
201
202 model = (PollsChoice)Proxy.newProxyInstance(PollsChoice.class.getClassLoader(),
203 new Class[] { PollsChoice.class },
204 new ReadOnlyBeanHandler(model));
205
206 return model;
207 }
208 }
209
210 public ExpandoBridge getExpandoBridge() {
211 if (_expandoBridge == null) {
212 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(PollsChoice.class.getName(),
213 getPrimaryKey());
214 }
215
216 return _expandoBridge;
217 }
218
219 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
220 getExpandoBridge().setAttributes(serviceContext);
221 }
222
223 public Object clone() {
224 PollsChoiceImpl clone = new PollsChoiceImpl();
225
226 clone.setUuid(getUuid());
227 clone.setChoiceId(getChoiceId());
228 clone.setQuestionId(getQuestionId());
229 clone.setName(getName());
230 clone.setDescription(getDescription());
231
232 return clone;
233 }
234
235 public int compareTo(PollsChoice pollsChoice) {
236 int value = 0;
237
238 if (getQuestionId() < pollsChoice.getQuestionId()) {
239 value = -1;
240 }
241 else if (getQuestionId() > pollsChoice.getQuestionId()) {
242 value = 1;
243 }
244 else {
245 value = 0;
246 }
247
248 if (value != 0) {
249 return value;
250 }
251
252 value = getName().compareTo(pollsChoice.getName());
253
254 if (value != 0) {
255 return value;
256 }
257
258 return 0;
259 }
260
261 public boolean equals(Object obj) {
262 if (obj == null) {
263 return false;
264 }
265
266 PollsChoice pollsChoice = null;
267
268 try {
269 pollsChoice = (PollsChoice)obj;
270 }
271 catch (ClassCastException cce) {
272 return false;
273 }
274
275 long pk = pollsChoice.getPrimaryKey();
276
277 if (getPrimaryKey() == pk) {
278 return true;
279 }
280 else {
281 return false;
282 }
283 }
284
285 public int hashCode() {
286 return (int)getPrimaryKey();
287 }
288
289 public String toString() {
290 StringBundler sb = new StringBundler(11);
291
292 sb.append("{uuid=");
293 sb.append(getUuid());
294 sb.append(", choiceId=");
295 sb.append(getChoiceId());
296 sb.append(", questionId=");
297 sb.append(getQuestionId());
298 sb.append(", name=");
299 sb.append(getName());
300 sb.append(", description=");
301 sb.append(getDescription());
302 sb.append("}");
303
304 return sb.toString();
305 }
306
307 public String toXmlString() {
308 StringBundler sb = new StringBundler(19);
309
310 sb.append("<model><model-name>");
311 sb.append("com.liferay.portlet.polls.model.PollsChoice");
312 sb.append("</model-name>");
313
314 sb.append(
315 "<column><column-name>uuid</column-name><column-value><![CDATA[");
316 sb.append(getUuid());
317 sb.append("]]></column-value></column>");
318 sb.append(
319 "<column><column-name>choiceId</column-name><column-value><![CDATA[");
320 sb.append(getChoiceId());
321 sb.append("]]></column-value></column>");
322 sb.append(
323 "<column><column-name>questionId</column-name><column-value><![CDATA[");
324 sb.append(getQuestionId());
325 sb.append("]]></column-value></column>");
326 sb.append(
327 "<column><column-name>name</column-name><column-value><![CDATA[");
328 sb.append(getName());
329 sb.append("]]></column-value></column>");
330 sb.append(
331 "<column><column-name>description</column-name><column-value><![CDATA[");
332 sb.append(getDescription());
333 sb.append("]]></column-value></column>");
334
335 sb.append("</model>");
336
337 return sb.toString();
338 }
339
340 private String _uuid;
341 private long _choiceId;
342 private long _questionId;
343 private long _originalQuestionId;
344 private boolean _setOriginalQuestionId;
345 private String _name;
346 private String _originalName;
347 private String _description;
348 private transient ExpandoBridge _expandoBridge;
349 }