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