001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.ProxyUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.kernel.util.Validator;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.Ticket;
025 import com.liferay.portal.model.TicketModel;
026 import com.liferay.portal.service.ServiceContext;
027 import com.liferay.portal.util.PortalUtil;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031
032 import java.io.Serializable;
033
034 import java.sql.Types;
035
036 import java.util.Date;
037 import java.util.HashMap;
038 import java.util.Map;
039
040
053 public class TicketModelImpl extends BaseModelImpl<Ticket>
054 implements TicketModel {
055
060 public static final String TABLE_NAME = "Ticket";
061 public static final Object[][] TABLE_COLUMNS = {
062 { "ticketId", Types.BIGINT },
063 { "companyId", Types.BIGINT },
064 { "createDate", Types.TIMESTAMP },
065 { "classNameId", Types.BIGINT },
066 { "classPK", Types.BIGINT },
067 { "key_", Types.VARCHAR },
068 { "type_", Types.INTEGER },
069 { "extraInfo", Types.CLOB },
070 { "expirationDate", Types.TIMESTAMP }
071 };
072 public static final String TABLE_SQL_CREATE = "create table Ticket (ticketId LONG not null primary key,companyId LONG,createDate DATE null,classNameId LONG,classPK LONG,key_ VARCHAR(75) null,type_ INTEGER,extraInfo TEXT null,expirationDate DATE null)";
073 public static final String TABLE_SQL_DROP = "drop table Ticket";
074 public static final String ORDER_BY_JPQL = " ORDER BY ticket.ticketId ASC";
075 public static final String ORDER_BY_SQL = " ORDER BY Ticket.ticketId ASC";
076 public static final String DATA_SOURCE = "liferayDataSource";
077 public static final String SESSION_FACTORY = "liferaySessionFactory";
078 public static final String TX_MANAGER = "liferayTransactionManager";
079 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080 "value.object.entity.cache.enabled.com.liferay.portal.model.Ticket"),
081 true);
082 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083 "value.object.finder.cache.enabled.com.liferay.portal.model.Ticket"),
084 true);
085 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086 "value.object.column.bitmask.enabled.com.liferay.portal.model.Ticket"),
087 true);
088 public static long KEY_COLUMN_BITMASK = 1L;
089 public static long TICKETID_COLUMN_BITMASK = 2L;
090 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
091 "lock.expiration.time.com.liferay.portal.model.Ticket"));
092
093 public TicketModelImpl() {
094 }
095
096 public long getPrimaryKey() {
097 return _ticketId;
098 }
099
100 public void setPrimaryKey(long primaryKey) {
101 setTicketId(primaryKey);
102 }
103
104 public Serializable getPrimaryKeyObj() {
105 return new Long(_ticketId);
106 }
107
108 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
109 setPrimaryKey(((Long)primaryKeyObj).longValue());
110 }
111
112 public Class<?> getModelClass() {
113 return Ticket.class;
114 }
115
116 public String getModelClassName() {
117 return Ticket.class.getName();
118 }
119
120 @Override
121 public Map<String, Object> getModelAttributes() {
122 Map<String, Object> attributes = new HashMap<String, Object>();
123
124 attributes.put("ticketId", getTicketId());
125 attributes.put("companyId", getCompanyId());
126 attributes.put("createDate", getCreateDate());
127 attributes.put("classNameId", getClassNameId());
128 attributes.put("classPK", getClassPK());
129 attributes.put("key", getKey());
130 attributes.put("type", getType());
131 attributes.put("extraInfo", getExtraInfo());
132 attributes.put("expirationDate", getExpirationDate());
133
134 return attributes;
135 }
136
137 @Override
138 public void setModelAttributes(Map<String, Object> attributes) {
139 Long ticketId = (Long)attributes.get("ticketId");
140
141 if (ticketId != null) {
142 setTicketId(ticketId);
143 }
144
145 Long companyId = (Long)attributes.get("companyId");
146
147 if (companyId != null) {
148 setCompanyId(companyId);
149 }
150
151 Date createDate = (Date)attributes.get("createDate");
152
153 if (createDate != null) {
154 setCreateDate(createDate);
155 }
156
157 Long classNameId = (Long)attributes.get("classNameId");
158
159 if (classNameId != null) {
160 setClassNameId(classNameId);
161 }
162
163 Long classPK = (Long)attributes.get("classPK");
164
165 if (classPK != null) {
166 setClassPK(classPK);
167 }
168
169 String key = (String)attributes.get("key");
170
171 if (key != null) {
172 setKey(key);
173 }
174
175 Integer type = (Integer)attributes.get("type");
176
177 if (type != null) {
178 setType(type);
179 }
180
181 String extraInfo = (String)attributes.get("extraInfo");
182
183 if (extraInfo != null) {
184 setExtraInfo(extraInfo);
185 }
186
187 Date expirationDate = (Date)attributes.get("expirationDate");
188
189 if (expirationDate != null) {
190 setExpirationDate(expirationDate);
191 }
192 }
193
194 public long getTicketId() {
195 return _ticketId;
196 }
197
198 public void setTicketId(long ticketId) {
199 _columnBitmask = -1L;
200
201 _ticketId = ticketId;
202 }
203
204 public long getCompanyId() {
205 return _companyId;
206 }
207
208 public void setCompanyId(long companyId) {
209 _companyId = companyId;
210 }
211
212 public Date getCreateDate() {
213 return _createDate;
214 }
215
216 public void setCreateDate(Date createDate) {
217 _createDate = createDate;
218 }
219
220 public String getClassName() {
221 if (getClassNameId() <= 0) {
222 return StringPool.BLANK;
223 }
224
225 return PortalUtil.getClassName(getClassNameId());
226 }
227
228 public void setClassName(String className) {
229 long classNameId = 0;
230
231 if (Validator.isNotNull(className)) {
232 classNameId = PortalUtil.getClassNameId(className);
233 }
234
235 setClassNameId(classNameId);
236 }
237
238 public long getClassNameId() {
239 return _classNameId;
240 }
241
242 public void setClassNameId(long classNameId) {
243 _classNameId = classNameId;
244 }
245
246 public long getClassPK() {
247 return _classPK;
248 }
249
250 public void setClassPK(long classPK) {
251 _classPK = classPK;
252 }
253
254 public String getKey() {
255 if (_key == null) {
256 return StringPool.BLANK;
257 }
258 else {
259 return _key;
260 }
261 }
262
263 public void setKey(String key) {
264 _columnBitmask |= KEY_COLUMN_BITMASK;
265
266 if (_originalKey == null) {
267 _originalKey = _key;
268 }
269
270 _key = key;
271 }
272
273 public String getOriginalKey() {
274 return GetterUtil.getString(_originalKey);
275 }
276
277 public int getType() {
278 return _type;
279 }
280
281 public void setType(int type) {
282 _type = type;
283 }
284
285 public String getExtraInfo() {
286 if (_extraInfo == null) {
287 return StringPool.BLANK;
288 }
289 else {
290 return _extraInfo;
291 }
292 }
293
294 public void setExtraInfo(String extraInfo) {
295 _extraInfo = extraInfo;
296 }
297
298 public Date getExpirationDate() {
299 return _expirationDate;
300 }
301
302 public void setExpirationDate(Date expirationDate) {
303 _expirationDate = expirationDate;
304 }
305
306 public long getColumnBitmask() {
307 return _columnBitmask;
308 }
309
310 @Override
311 public ExpandoBridge getExpandoBridge() {
312 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
313 Ticket.class.getName(), getPrimaryKey());
314 }
315
316 @Override
317 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
318 ExpandoBridge expandoBridge = getExpandoBridge();
319
320 expandoBridge.setAttributes(serviceContext);
321 }
322
323 @Override
324 public Ticket toEscapedModel() {
325 if (_escapedModel == null) {
326 _escapedModel = (Ticket)ProxyUtil.newProxyInstance(_classLoader,
327 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
328 }
329
330 return _escapedModel;
331 }
332
333 @Override
334 public Object clone() {
335 TicketImpl ticketImpl = new TicketImpl();
336
337 ticketImpl.setTicketId(getTicketId());
338 ticketImpl.setCompanyId(getCompanyId());
339 ticketImpl.setCreateDate(getCreateDate());
340 ticketImpl.setClassNameId(getClassNameId());
341 ticketImpl.setClassPK(getClassPK());
342 ticketImpl.setKey(getKey());
343 ticketImpl.setType(getType());
344 ticketImpl.setExtraInfo(getExtraInfo());
345 ticketImpl.setExpirationDate(getExpirationDate());
346
347 ticketImpl.resetOriginalValues();
348
349 return ticketImpl;
350 }
351
352 public int compareTo(Ticket ticket) {
353 int value = 0;
354
355 if (getTicketId() < ticket.getTicketId()) {
356 value = -1;
357 }
358 else if (getTicketId() > ticket.getTicketId()) {
359 value = 1;
360 }
361 else {
362 value = 0;
363 }
364
365 if (value != 0) {
366 return value;
367 }
368
369 return 0;
370 }
371
372 @Override
373 public boolean equals(Object obj) {
374 if (obj == null) {
375 return false;
376 }
377
378 Ticket ticket = null;
379
380 try {
381 ticket = (Ticket)obj;
382 }
383 catch (ClassCastException cce) {
384 return false;
385 }
386
387 long primaryKey = ticket.getPrimaryKey();
388
389 if (getPrimaryKey() == primaryKey) {
390 return true;
391 }
392 else {
393 return false;
394 }
395 }
396
397 @Override
398 public int hashCode() {
399 return (int)getPrimaryKey();
400 }
401
402 @Override
403 public void resetOriginalValues() {
404 TicketModelImpl ticketModelImpl = this;
405
406 ticketModelImpl._originalKey = ticketModelImpl._key;
407
408 ticketModelImpl._columnBitmask = 0;
409 }
410
411 @Override
412 public CacheModel<Ticket> toCacheModel() {
413 TicketCacheModel ticketCacheModel = new TicketCacheModel();
414
415 ticketCacheModel.ticketId = getTicketId();
416
417 ticketCacheModel.companyId = getCompanyId();
418
419 Date createDate = getCreateDate();
420
421 if (createDate != null) {
422 ticketCacheModel.createDate = createDate.getTime();
423 }
424 else {
425 ticketCacheModel.createDate = Long.MIN_VALUE;
426 }
427
428 ticketCacheModel.classNameId = getClassNameId();
429
430 ticketCacheModel.classPK = getClassPK();
431
432 ticketCacheModel.key = getKey();
433
434 String key = ticketCacheModel.key;
435
436 if ((key != null) && (key.length() == 0)) {
437 ticketCacheModel.key = null;
438 }
439
440 ticketCacheModel.type = getType();
441
442 ticketCacheModel.extraInfo = getExtraInfo();
443
444 String extraInfo = ticketCacheModel.extraInfo;
445
446 if ((extraInfo != null) && (extraInfo.length() == 0)) {
447 ticketCacheModel.extraInfo = null;
448 }
449
450 Date expirationDate = getExpirationDate();
451
452 if (expirationDate != null) {
453 ticketCacheModel.expirationDate = expirationDate.getTime();
454 }
455 else {
456 ticketCacheModel.expirationDate = Long.MIN_VALUE;
457 }
458
459 return ticketCacheModel;
460 }
461
462 @Override
463 public String toString() {
464 StringBundler sb = new StringBundler(19);
465
466 sb.append("{ticketId=");
467 sb.append(getTicketId());
468 sb.append(", companyId=");
469 sb.append(getCompanyId());
470 sb.append(", createDate=");
471 sb.append(getCreateDate());
472 sb.append(", classNameId=");
473 sb.append(getClassNameId());
474 sb.append(", classPK=");
475 sb.append(getClassPK());
476 sb.append(", key=");
477 sb.append(getKey());
478 sb.append(", type=");
479 sb.append(getType());
480 sb.append(", extraInfo=");
481 sb.append(getExtraInfo());
482 sb.append(", expirationDate=");
483 sb.append(getExpirationDate());
484 sb.append("}");
485
486 return sb.toString();
487 }
488
489 public String toXmlString() {
490 StringBundler sb = new StringBundler(31);
491
492 sb.append("<model><model-name>");
493 sb.append("com.liferay.portal.model.Ticket");
494 sb.append("</model-name>");
495
496 sb.append(
497 "<column><column-name>ticketId</column-name><column-value><![CDATA[");
498 sb.append(getTicketId());
499 sb.append("]]></column-value></column>");
500 sb.append(
501 "<column><column-name>companyId</column-name><column-value><![CDATA[");
502 sb.append(getCompanyId());
503 sb.append("]]></column-value></column>");
504 sb.append(
505 "<column><column-name>createDate</column-name><column-value><![CDATA[");
506 sb.append(getCreateDate());
507 sb.append("]]></column-value></column>");
508 sb.append(
509 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
510 sb.append(getClassNameId());
511 sb.append("]]></column-value></column>");
512 sb.append(
513 "<column><column-name>classPK</column-name><column-value><![CDATA[");
514 sb.append(getClassPK());
515 sb.append("]]></column-value></column>");
516 sb.append(
517 "<column><column-name>key</column-name><column-value><![CDATA[");
518 sb.append(getKey());
519 sb.append("]]></column-value></column>");
520 sb.append(
521 "<column><column-name>type</column-name><column-value><![CDATA[");
522 sb.append(getType());
523 sb.append("]]></column-value></column>");
524 sb.append(
525 "<column><column-name>extraInfo</column-name><column-value><![CDATA[");
526 sb.append(getExtraInfo());
527 sb.append("]]></column-value></column>");
528 sb.append(
529 "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
530 sb.append(getExpirationDate());
531 sb.append("]]></column-value></column>");
532
533 sb.append("</model>");
534
535 return sb.toString();
536 }
537
538 private static ClassLoader _classLoader = Ticket.class.getClassLoader();
539 private static Class<?>[] _escapedModelInterfaces = new Class[] { Ticket.class };
540 private long _ticketId;
541 private long _companyId;
542 private Date _createDate;
543 private long _classNameId;
544 private long _classPK;
545 private String _key;
546 private String _originalKey;
547 private int _type;
548 private String _extraInfo;
549 private Date _expirationDate;
550 private long _columnBitmask;
551 private Ticket _escapedModel;
552 }