001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.kernel.util.Validator;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.Ticket;
027    import com.liferay.portal.model.TicketModel;
028    import com.liferay.portal.service.ServiceContext;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.Date;
039    import java.util.HashMap;
040    import java.util.Map;
041    
042    /**
043     * The base model implementation for the Ticket service. Represents a row in the "Ticket" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link TicketModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TicketImpl}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see TicketImpl
051     * @see Ticket
052     * @see TicketModel
053     * @generated
054     */
055    @ProviderType
056    public class TicketModelImpl extends BaseModelImpl<Ticket>
057            implements TicketModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this class directly. All methods that expect a ticket model instance should use the {@link Ticket} interface instead.
062             */
063            public static final String TABLE_NAME = "Ticket";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "mvccVersion", Types.BIGINT },
066                            { "ticketId", Types.BIGINT },
067                            { "companyId", Types.BIGINT },
068                            { "createDate", Types.TIMESTAMP },
069                            { "classNameId", Types.BIGINT },
070                            { "classPK", Types.BIGINT },
071                            { "key_", Types.VARCHAR },
072                            { "type_", Types.INTEGER },
073                            { "extraInfo", Types.CLOB },
074                            { "expirationDate", Types.TIMESTAMP }
075                    };
076            public static final String TABLE_SQL_CREATE = "create table Ticket (mvccVersion LONG default 0,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)";
077            public static final String TABLE_SQL_DROP = "drop table Ticket";
078            public static final String ORDER_BY_JPQL = " ORDER BY ticket.ticketId ASC";
079            public static final String ORDER_BY_SQL = " ORDER BY Ticket.ticketId ASC";
080            public static final String DATA_SOURCE = "liferayDataSource";
081            public static final String SESSION_FACTORY = "liferaySessionFactory";
082            public static final String TX_MANAGER = "liferayTransactionManager";
083            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Ticket"),
085                            true);
086            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Ticket"),
088                            true);
089            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.Ticket"),
091                            true);
092            public static final long CLASSNAMEID_COLUMN_BITMASK = 1L;
093            public static final long CLASSPK_COLUMN_BITMASK = 2L;
094            public static final long KEY_COLUMN_BITMASK = 4L;
095            public static final long TYPE_COLUMN_BITMASK = 8L;
096            public static final long TICKETID_COLUMN_BITMASK = 16L;
097            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
098                                    "lock.expiration.time.com.liferay.portal.model.Ticket"));
099    
100            public TicketModelImpl() {
101            }
102    
103            @Override
104            public long getPrimaryKey() {
105                    return _ticketId;
106            }
107    
108            @Override
109            public void setPrimaryKey(long primaryKey) {
110                    setTicketId(primaryKey);
111            }
112    
113            @Override
114            public Serializable getPrimaryKeyObj() {
115                    return _ticketId;
116            }
117    
118            @Override
119            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
120                    setPrimaryKey(((Long)primaryKeyObj).longValue());
121            }
122    
123            @Override
124            public Class<?> getModelClass() {
125                    return Ticket.class;
126            }
127    
128            @Override
129            public String getModelClassName() {
130                    return Ticket.class.getName();
131            }
132    
133            @Override
134            public Map<String, Object> getModelAttributes() {
135                    Map<String, Object> attributes = new HashMap<String, Object>();
136    
137                    attributes.put("mvccVersion", getMvccVersion());
138                    attributes.put("ticketId", getTicketId());
139                    attributes.put("companyId", getCompanyId());
140                    attributes.put("createDate", getCreateDate());
141                    attributes.put("classNameId", getClassNameId());
142                    attributes.put("classPK", getClassPK());
143                    attributes.put("key", getKey());
144                    attributes.put("type", getType());
145                    attributes.put("extraInfo", getExtraInfo());
146                    attributes.put("expirationDate", getExpirationDate());
147    
148                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
149                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
150    
151                    return attributes;
152            }
153    
154            @Override
155            public void setModelAttributes(Map<String, Object> attributes) {
156                    Long mvccVersion = (Long)attributes.get("mvccVersion");
157    
158                    if (mvccVersion != null) {
159                            setMvccVersion(mvccVersion);
160                    }
161    
162                    Long ticketId = (Long)attributes.get("ticketId");
163    
164                    if (ticketId != null) {
165                            setTicketId(ticketId);
166                    }
167    
168                    Long companyId = (Long)attributes.get("companyId");
169    
170                    if (companyId != null) {
171                            setCompanyId(companyId);
172                    }
173    
174                    Date createDate = (Date)attributes.get("createDate");
175    
176                    if (createDate != null) {
177                            setCreateDate(createDate);
178                    }
179    
180                    Long classNameId = (Long)attributes.get("classNameId");
181    
182                    if (classNameId != null) {
183                            setClassNameId(classNameId);
184                    }
185    
186                    Long classPK = (Long)attributes.get("classPK");
187    
188                    if (classPK != null) {
189                            setClassPK(classPK);
190                    }
191    
192                    String key = (String)attributes.get("key");
193    
194                    if (key != null) {
195                            setKey(key);
196                    }
197    
198                    Integer type = (Integer)attributes.get("type");
199    
200                    if (type != null) {
201                            setType(type);
202                    }
203    
204                    String extraInfo = (String)attributes.get("extraInfo");
205    
206                    if (extraInfo != null) {
207                            setExtraInfo(extraInfo);
208                    }
209    
210                    Date expirationDate = (Date)attributes.get("expirationDate");
211    
212                    if (expirationDate != null) {
213                            setExpirationDate(expirationDate);
214                    }
215            }
216    
217            @Override
218            public long getMvccVersion() {
219                    return _mvccVersion;
220            }
221    
222            @Override
223            public void setMvccVersion(long mvccVersion) {
224                    _mvccVersion = mvccVersion;
225            }
226    
227            @Override
228            public long getTicketId() {
229                    return _ticketId;
230            }
231    
232            @Override
233            public void setTicketId(long ticketId) {
234                    _columnBitmask = -1L;
235    
236                    _ticketId = ticketId;
237            }
238    
239            @Override
240            public long getCompanyId() {
241                    return _companyId;
242            }
243    
244            @Override
245            public void setCompanyId(long companyId) {
246                    _companyId = companyId;
247            }
248    
249            @Override
250            public Date getCreateDate() {
251                    return _createDate;
252            }
253    
254            @Override
255            public void setCreateDate(Date createDate) {
256                    _createDate = createDate;
257            }
258    
259            @Override
260            public String getClassName() {
261                    if (getClassNameId() <= 0) {
262                            return StringPool.BLANK;
263                    }
264    
265                    return PortalUtil.getClassName(getClassNameId());
266            }
267    
268            @Override
269            public void setClassName(String className) {
270                    long classNameId = 0;
271    
272                    if (Validator.isNotNull(className)) {
273                            classNameId = PortalUtil.getClassNameId(className);
274                    }
275    
276                    setClassNameId(classNameId);
277            }
278    
279            @Override
280            public long getClassNameId() {
281                    return _classNameId;
282            }
283    
284            @Override
285            public void setClassNameId(long classNameId) {
286                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
287    
288                    if (!_setOriginalClassNameId) {
289                            _setOriginalClassNameId = true;
290    
291                            _originalClassNameId = _classNameId;
292                    }
293    
294                    _classNameId = classNameId;
295            }
296    
297            public long getOriginalClassNameId() {
298                    return _originalClassNameId;
299            }
300    
301            @Override
302            public long getClassPK() {
303                    return _classPK;
304            }
305    
306            @Override
307            public void setClassPK(long classPK) {
308                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
309    
310                    if (!_setOriginalClassPK) {
311                            _setOriginalClassPK = true;
312    
313                            _originalClassPK = _classPK;
314                    }
315    
316                    _classPK = classPK;
317            }
318    
319            public long getOriginalClassPK() {
320                    return _originalClassPK;
321            }
322    
323            @Override
324            public String getKey() {
325                    if (_key == null) {
326                            return StringPool.BLANK;
327                    }
328                    else {
329                            return _key;
330                    }
331            }
332    
333            @Override
334            public void setKey(String key) {
335                    _columnBitmask |= KEY_COLUMN_BITMASK;
336    
337                    if (_originalKey == null) {
338                            _originalKey = _key;
339                    }
340    
341                    _key = key;
342            }
343    
344            public String getOriginalKey() {
345                    return GetterUtil.getString(_originalKey);
346            }
347    
348            @Override
349            public int getType() {
350                    return _type;
351            }
352    
353            @Override
354            public void setType(int type) {
355                    _columnBitmask |= TYPE_COLUMN_BITMASK;
356    
357                    if (!_setOriginalType) {
358                            _setOriginalType = true;
359    
360                            _originalType = _type;
361                    }
362    
363                    _type = type;
364            }
365    
366            public int getOriginalType() {
367                    return _originalType;
368            }
369    
370            @Override
371            public String getExtraInfo() {
372                    if (_extraInfo == null) {
373                            return StringPool.BLANK;
374                    }
375                    else {
376                            return _extraInfo;
377                    }
378            }
379    
380            @Override
381            public void setExtraInfo(String extraInfo) {
382                    _extraInfo = extraInfo;
383            }
384    
385            @Override
386            public Date getExpirationDate() {
387                    return _expirationDate;
388            }
389    
390            @Override
391            public void setExpirationDate(Date expirationDate) {
392                    _expirationDate = expirationDate;
393            }
394    
395            public long getColumnBitmask() {
396                    return _columnBitmask;
397            }
398    
399            @Override
400            public ExpandoBridge getExpandoBridge() {
401                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
402                            Ticket.class.getName(), getPrimaryKey());
403            }
404    
405            @Override
406            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
407                    ExpandoBridge expandoBridge = getExpandoBridge();
408    
409                    expandoBridge.setAttributes(serviceContext);
410            }
411    
412            @Override
413            public Ticket toEscapedModel() {
414                    if (_escapedModel == null) {
415                            _escapedModel = (Ticket)ProxyUtil.newProxyInstance(_classLoader,
416                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
417                    }
418    
419                    return _escapedModel;
420            }
421    
422            @Override
423            public Object clone() {
424                    TicketImpl ticketImpl = new TicketImpl();
425    
426                    ticketImpl.setMvccVersion(getMvccVersion());
427                    ticketImpl.setTicketId(getTicketId());
428                    ticketImpl.setCompanyId(getCompanyId());
429                    ticketImpl.setCreateDate(getCreateDate());
430                    ticketImpl.setClassNameId(getClassNameId());
431                    ticketImpl.setClassPK(getClassPK());
432                    ticketImpl.setKey(getKey());
433                    ticketImpl.setType(getType());
434                    ticketImpl.setExtraInfo(getExtraInfo());
435                    ticketImpl.setExpirationDate(getExpirationDate());
436    
437                    ticketImpl.resetOriginalValues();
438    
439                    return ticketImpl;
440            }
441    
442            @Override
443            public int compareTo(Ticket ticket) {
444                    int value = 0;
445    
446                    if (getTicketId() < ticket.getTicketId()) {
447                            value = -1;
448                    }
449                    else if (getTicketId() > ticket.getTicketId()) {
450                            value = 1;
451                    }
452                    else {
453                            value = 0;
454                    }
455    
456                    if (value != 0) {
457                            return value;
458                    }
459    
460                    return 0;
461            }
462    
463            @Override
464            public boolean equals(Object obj) {
465                    if (this == obj) {
466                            return true;
467                    }
468    
469                    if (!(obj instanceof Ticket)) {
470                            return false;
471                    }
472    
473                    Ticket ticket = (Ticket)obj;
474    
475                    long primaryKey = ticket.getPrimaryKey();
476    
477                    if (getPrimaryKey() == primaryKey) {
478                            return true;
479                    }
480                    else {
481                            return false;
482                    }
483            }
484    
485            @Override
486            public int hashCode() {
487                    return (int)getPrimaryKey();
488            }
489    
490            @Override
491            public boolean isEntityCacheEnabled() {
492                    return ENTITY_CACHE_ENABLED;
493            }
494    
495            @Override
496            public boolean isFinderCacheEnabled() {
497                    return FINDER_CACHE_ENABLED;
498            }
499    
500            @Override
501            public void resetOriginalValues() {
502                    TicketModelImpl ticketModelImpl = this;
503    
504                    ticketModelImpl._originalClassNameId = ticketModelImpl._classNameId;
505    
506                    ticketModelImpl._setOriginalClassNameId = false;
507    
508                    ticketModelImpl._originalClassPK = ticketModelImpl._classPK;
509    
510                    ticketModelImpl._setOriginalClassPK = false;
511    
512                    ticketModelImpl._originalKey = ticketModelImpl._key;
513    
514                    ticketModelImpl._originalType = ticketModelImpl._type;
515    
516                    ticketModelImpl._setOriginalType = false;
517    
518                    ticketModelImpl._columnBitmask = 0;
519            }
520    
521            @Override
522            public CacheModel<Ticket> toCacheModel() {
523                    TicketCacheModel ticketCacheModel = new TicketCacheModel();
524    
525                    ticketCacheModel.mvccVersion = getMvccVersion();
526    
527                    ticketCacheModel.ticketId = getTicketId();
528    
529                    ticketCacheModel.companyId = getCompanyId();
530    
531                    Date createDate = getCreateDate();
532    
533                    if (createDate != null) {
534                            ticketCacheModel.createDate = createDate.getTime();
535                    }
536                    else {
537                            ticketCacheModel.createDate = Long.MIN_VALUE;
538                    }
539    
540                    ticketCacheModel.classNameId = getClassNameId();
541    
542                    ticketCacheModel.classPK = getClassPK();
543    
544                    ticketCacheModel.key = getKey();
545    
546                    String key = ticketCacheModel.key;
547    
548                    if ((key != null) && (key.length() == 0)) {
549                            ticketCacheModel.key = null;
550                    }
551    
552                    ticketCacheModel.type = getType();
553    
554                    ticketCacheModel.extraInfo = getExtraInfo();
555    
556                    String extraInfo = ticketCacheModel.extraInfo;
557    
558                    if ((extraInfo != null) && (extraInfo.length() == 0)) {
559                            ticketCacheModel.extraInfo = null;
560                    }
561    
562                    Date expirationDate = getExpirationDate();
563    
564                    if (expirationDate != null) {
565                            ticketCacheModel.expirationDate = expirationDate.getTime();
566                    }
567                    else {
568                            ticketCacheModel.expirationDate = Long.MIN_VALUE;
569                    }
570    
571                    return ticketCacheModel;
572            }
573    
574            @Override
575            public String toString() {
576                    StringBundler sb = new StringBundler(21);
577    
578                    sb.append("{mvccVersion=");
579                    sb.append(getMvccVersion());
580                    sb.append(", ticketId=");
581                    sb.append(getTicketId());
582                    sb.append(", companyId=");
583                    sb.append(getCompanyId());
584                    sb.append(", createDate=");
585                    sb.append(getCreateDate());
586                    sb.append(", classNameId=");
587                    sb.append(getClassNameId());
588                    sb.append(", classPK=");
589                    sb.append(getClassPK());
590                    sb.append(", key=");
591                    sb.append(getKey());
592                    sb.append(", type=");
593                    sb.append(getType());
594                    sb.append(", extraInfo=");
595                    sb.append(getExtraInfo());
596                    sb.append(", expirationDate=");
597                    sb.append(getExpirationDate());
598                    sb.append("}");
599    
600                    return sb.toString();
601            }
602    
603            @Override
604            public String toXmlString() {
605                    StringBundler sb = new StringBundler(34);
606    
607                    sb.append("<model><model-name>");
608                    sb.append("com.liferay.portal.model.Ticket");
609                    sb.append("</model-name>");
610    
611                    sb.append(
612                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
613                    sb.append(getMvccVersion());
614                    sb.append("]]></column-value></column>");
615                    sb.append(
616                            "<column><column-name>ticketId</column-name><column-value><![CDATA[");
617                    sb.append(getTicketId());
618                    sb.append("]]></column-value></column>");
619                    sb.append(
620                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
621                    sb.append(getCompanyId());
622                    sb.append("]]></column-value></column>");
623                    sb.append(
624                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
625                    sb.append(getCreateDate());
626                    sb.append("]]></column-value></column>");
627                    sb.append(
628                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
629                    sb.append(getClassNameId());
630                    sb.append("]]></column-value></column>");
631                    sb.append(
632                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
633                    sb.append(getClassPK());
634                    sb.append("]]></column-value></column>");
635                    sb.append(
636                            "<column><column-name>key</column-name><column-value><![CDATA[");
637                    sb.append(getKey());
638                    sb.append("]]></column-value></column>");
639                    sb.append(
640                            "<column><column-name>type</column-name><column-value><![CDATA[");
641                    sb.append(getType());
642                    sb.append("]]></column-value></column>");
643                    sb.append(
644                            "<column><column-name>extraInfo</column-name><column-value><![CDATA[");
645                    sb.append(getExtraInfo());
646                    sb.append("]]></column-value></column>");
647                    sb.append(
648                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
649                    sb.append(getExpirationDate());
650                    sb.append("]]></column-value></column>");
651    
652                    sb.append("</model>");
653    
654                    return sb.toString();
655            }
656    
657            private static final ClassLoader _classLoader = Ticket.class.getClassLoader();
658            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
659                            Ticket.class
660                    };
661            private long _mvccVersion;
662            private long _ticketId;
663            private long _companyId;
664            private Date _createDate;
665            private long _classNameId;
666            private long _originalClassNameId;
667            private boolean _setOriginalClassNameId;
668            private long _classPK;
669            private long _originalClassPK;
670            private boolean _setOriginalClassPK;
671            private String _key;
672            private String _originalKey;
673            private int _type;
674            private int _originalType;
675            private boolean _setOriginalType;
676            private String _extraInfo;
677            private Date _expirationDate;
678            private long _columnBitmask;
679            private Ticket _escapedModel;
680    }