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