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 com.liferay.portal.model.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 com.liferay.portal.model.Ticket
052     * @see com.liferay.portal.model.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 com.liferay.portal.model.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 KEY_COLUMN_BITMASK = 1L;
093            public static final long TICKETID_COLUMN_BITMASK = 2L;
094            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
095                                    "lock.expiration.time.com.liferay.portal.model.Ticket"));
096    
097            public TicketModelImpl() {
098            }
099    
100            @Override
101            public long getPrimaryKey() {
102                    return _ticketId;
103            }
104    
105            @Override
106            public void setPrimaryKey(long primaryKey) {
107                    setTicketId(primaryKey);
108            }
109    
110            @Override
111            public Serializable getPrimaryKeyObj() {
112                    return _ticketId;
113            }
114    
115            @Override
116            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
117                    setPrimaryKey(((Long)primaryKeyObj).longValue());
118            }
119    
120            @Override
121            public Class<?> getModelClass() {
122                    return Ticket.class;
123            }
124    
125            @Override
126            public String getModelClassName() {
127                    return Ticket.class.getName();
128            }
129    
130            @Override
131            public Map<String, Object> getModelAttributes() {
132                    Map<String, Object> attributes = new HashMap<String, Object>();
133    
134                    attributes.put("mvccVersion", getMvccVersion());
135                    attributes.put("ticketId", getTicketId());
136                    attributes.put("companyId", getCompanyId());
137                    attributes.put("createDate", getCreateDate());
138                    attributes.put("classNameId", getClassNameId());
139                    attributes.put("classPK", getClassPK());
140                    attributes.put("key", getKey());
141                    attributes.put("type", getType());
142                    attributes.put("extraInfo", getExtraInfo());
143                    attributes.put("expirationDate", getExpirationDate());
144    
145                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
146                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
147    
148                    return attributes;
149            }
150    
151            @Override
152            public void setModelAttributes(Map<String, Object> attributes) {
153                    Long mvccVersion = (Long)attributes.get("mvccVersion");
154    
155                    if (mvccVersion != null) {
156                            setMvccVersion(mvccVersion);
157                    }
158    
159                    Long ticketId = (Long)attributes.get("ticketId");
160    
161                    if (ticketId != null) {
162                            setTicketId(ticketId);
163                    }
164    
165                    Long companyId = (Long)attributes.get("companyId");
166    
167                    if (companyId != null) {
168                            setCompanyId(companyId);
169                    }
170    
171                    Date createDate = (Date)attributes.get("createDate");
172    
173                    if (createDate != null) {
174                            setCreateDate(createDate);
175                    }
176    
177                    Long classNameId = (Long)attributes.get("classNameId");
178    
179                    if (classNameId != null) {
180                            setClassNameId(classNameId);
181                    }
182    
183                    Long classPK = (Long)attributes.get("classPK");
184    
185                    if (classPK != null) {
186                            setClassPK(classPK);
187                    }
188    
189                    String key = (String)attributes.get("key");
190    
191                    if (key != null) {
192                            setKey(key);
193                    }
194    
195                    Integer type = (Integer)attributes.get("type");
196    
197                    if (type != null) {
198                            setType(type);
199                    }
200    
201                    String extraInfo = (String)attributes.get("extraInfo");
202    
203                    if (extraInfo != null) {
204                            setExtraInfo(extraInfo);
205                    }
206    
207                    Date expirationDate = (Date)attributes.get("expirationDate");
208    
209                    if (expirationDate != null) {
210                            setExpirationDate(expirationDate);
211                    }
212            }
213    
214            @Override
215            public long getMvccVersion() {
216                    return _mvccVersion;
217            }
218    
219            @Override
220            public void setMvccVersion(long mvccVersion) {
221                    _mvccVersion = mvccVersion;
222            }
223    
224            @Override
225            public long getTicketId() {
226                    return _ticketId;
227            }
228    
229            @Override
230            public void setTicketId(long ticketId) {
231                    _columnBitmask = -1L;
232    
233                    _ticketId = ticketId;
234            }
235    
236            @Override
237            public long getCompanyId() {
238                    return _companyId;
239            }
240    
241            @Override
242            public void setCompanyId(long companyId) {
243                    _companyId = companyId;
244            }
245    
246            @Override
247            public Date getCreateDate() {
248                    return _createDate;
249            }
250    
251            @Override
252            public void setCreateDate(Date createDate) {
253                    _createDate = createDate;
254            }
255    
256            @Override
257            public String getClassName() {
258                    if (getClassNameId() <= 0) {
259                            return StringPool.BLANK;
260                    }
261    
262                    return PortalUtil.getClassName(getClassNameId());
263            }
264    
265            @Override
266            public void setClassName(String className) {
267                    long classNameId = 0;
268    
269                    if (Validator.isNotNull(className)) {
270                            classNameId = PortalUtil.getClassNameId(className);
271                    }
272    
273                    setClassNameId(classNameId);
274            }
275    
276            @Override
277            public long getClassNameId() {
278                    return _classNameId;
279            }
280    
281            @Override
282            public void setClassNameId(long classNameId) {
283                    _classNameId = classNameId;
284            }
285    
286            @Override
287            public long getClassPK() {
288                    return _classPK;
289            }
290    
291            @Override
292            public void setClassPK(long classPK) {
293                    _classPK = classPK;
294            }
295    
296            @Override
297            public String getKey() {
298                    if (_key == null) {
299                            return StringPool.BLANK;
300                    }
301                    else {
302                            return _key;
303                    }
304            }
305    
306            @Override
307            public void setKey(String key) {
308                    _columnBitmask |= KEY_COLUMN_BITMASK;
309    
310                    if (_originalKey == null) {
311                            _originalKey = _key;
312                    }
313    
314                    _key = key;
315            }
316    
317            public String getOriginalKey() {
318                    return GetterUtil.getString(_originalKey);
319            }
320    
321            @Override
322            public int getType() {
323                    return _type;
324            }
325    
326            @Override
327            public void setType(int type) {
328                    _type = type;
329            }
330    
331            @Override
332            public String getExtraInfo() {
333                    if (_extraInfo == null) {
334                            return StringPool.BLANK;
335                    }
336                    else {
337                            return _extraInfo;
338                    }
339            }
340    
341            @Override
342            public void setExtraInfo(String extraInfo) {
343                    _extraInfo = extraInfo;
344            }
345    
346            @Override
347            public Date getExpirationDate() {
348                    return _expirationDate;
349            }
350    
351            @Override
352            public void setExpirationDate(Date expirationDate) {
353                    _expirationDate = expirationDate;
354            }
355    
356            public long getColumnBitmask() {
357                    return _columnBitmask;
358            }
359    
360            @Override
361            public ExpandoBridge getExpandoBridge() {
362                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
363                            Ticket.class.getName(), getPrimaryKey());
364            }
365    
366            @Override
367            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
368                    ExpandoBridge expandoBridge = getExpandoBridge();
369    
370                    expandoBridge.setAttributes(serviceContext);
371            }
372    
373            @Override
374            public Ticket toEscapedModel() {
375                    if (_escapedModel == null) {
376                            _escapedModel = (Ticket)ProxyUtil.newProxyInstance(_classLoader,
377                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
378                    }
379    
380                    return _escapedModel;
381            }
382    
383            @Override
384            public Object clone() {
385                    TicketImpl ticketImpl = new TicketImpl();
386    
387                    ticketImpl.setMvccVersion(getMvccVersion());
388                    ticketImpl.setTicketId(getTicketId());
389                    ticketImpl.setCompanyId(getCompanyId());
390                    ticketImpl.setCreateDate(getCreateDate());
391                    ticketImpl.setClassNameId(getClassNameId());
392                    ticketImpl.setClassPK(getClassPK());
393                    ticketImpl.setKey(getKey());
394                    ticketImpl.setType(getType());
395                    ticketImpl.setExtraInfo(getExtraInfo());
396                    ticketImpl.setExpirationDate(getExpirationDate());
397    
398                    ticketImpl.resetOriginalValues();
399    
400                    return ticketImpl;
401            }
402    
403            @Override
404            public int compareTo(Ticket ticket) {
405                    int value = 0;
406    
407                    if (getTicketId() < ticket.getTicketId()) {
408                            value = -1;
409                    }
410                    else if (getTicketId() > ticket.getTicketId()) {
411                            value = 1;
412                    }
413                    else {
414                            value = 0;
415                    }
416    
417                    if (value != 0) {
418                            return value;
419                    }
420    
421                    return 0;
422            }
423    
424            @Override
425            public boolean equals(Object obj) {
426                    if (this == obj) {
427                            return true;
428                    }
429    
430                    if (!(obj instanceof Ticket)) {
431                            return false;
432                    }
433    
434                    Ticket ticket = (Ticket)obj;
435    
436                    long primaryKey = ticket.getPrimaryKey();
437    
438                    if (getPrimaryKey() == primaryKey) {
439                            return true;
440                    }
441                    else {
442                            return false;
443                    }
444            }
445    
446            @Override
447            public int hashCode() {
448                    return (int)getPrimaryKey();
449            }
450    
451            @Override
452            public boolean isEntityCacheEnabled() {
453                    return ENTITY_CACHE_ENABLED;
454            }
455    
456            @Override
457            public boolean isFinderCacheEnabled() {
458                    return FINDER_CACHE_ENABLED;
459            }
460    
461            @Override
462            public void resetOriginalValues() {
463                    TicketModelImpl ticketModelImpl = this;
464    
465                    ticketModelImpl._originalKey = ticketModelImpl._key;
466    
467                    ticketModelImpl._columnBitmask = 0;
468            }
469    
470            @Override
471            public CacheModel<Ticket> toCacheModel() {
472                    TicketCacheModel ticketCacheModel = new TicketCacheModel();
473    
474                    ticketCacheModel.mvccVersion = getMvccVersion();
475    
476                    ticketCacheModel.ticketId = getTicketId();
477    
478                    ticketCacheModel.companyId = getCompanyId();
479    
480                    Date createDate = getCreateDate();
481    
482                    if (createDate != null) {
483                            ticketCacheModel.createDate = createDate.getTime();
484                    }
485                    else {
486                            ticketCacheModel.createDate = Long.MIN_VALUE;
487                    }
488    
489                    ticketCacheModel.classNameId = getClassNameId();
490    
491                    ticketCacheModel.classPK = getClassPK();
492    
493                    ticketCacheModel.key = getKey();
494    
495                    String key = ticketCacheModel.key;
496    
497                    if ((key != null) && (key.length() == 0)) {
498                            ticketCacheModel.key = null;
499                    }
500    
501                    ticketCacheModel.type = getType();
502    
503                    ticketCacheModel.extraInfo = getExtraInfo();
504    
505                    String extraInfo = ticketCacheModel.extraInfo;
506    
507                    if ((extraInfo != null) && (extraInfo.length() == 0)) {
508                            ticketCacheModel.extraInfo = null;
509                    }
510    
511                    Date expirationDate = getExpirationDate();
512    
513                    if (expirationDate != null) {
514                            ticketCacheModel.expirationDate = expirationDate.getTime();
515                    }
516                    else {
517                            ticketCacheModel.expirationDate = Long.MIN_VALUE;
518                    }
519    
520                    return ticketCacheModel;
521            }
522    
523            @Override
524            public String toString() {
525                    StringBundler sb = new StringBundler(21);
526    
527                    sb.append("{mvccVersion=");
528                    sb.append(getMvccVersion());
529                    sb.append(", ticketId=");
530                    sb.append(getTicketId());
531                    sb.append(", companyId=");
532                    sb.append(getCompanyId());
533                    sb.append(", createDate=");
534                    sb.append(getCreateDate());
535                    sb.append(", classNameId=");
536                    sb.append(getClassNameId());
537                    sb.append(", classPK=");
538                    sb.append(getClassPK());
539                    sb.append(", key=");
540                    sb.append(getKey());
541                    sb.append(", type=");
542                    sb.append(getType());
543                    sb.append(", extraInfo=");
544                    sb.append(getExtraInfo());
545                    sb.append(", expirationDate=");
546                    sb.append(getExpirationDate());
547                    sb.append("}");
548    
549                    return sb.toString();
550            }
551    
552            @Override
553            public String toXmlString() {
554                    StringBundler sb = new StringBundler(34);
555    
556                    sb.append("<model><model-name>");
557                    sb.append("com.liferay.portal.model.Ticket");
558                    sb.append("</model-name>");
559    
560                    sb.append(
561                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
562                    sb.append(getMvccVersion());
563                    sb.append("]]></column-value></column>");
564                    sb.append(
565                            "<column><column-name>ticketId</column-name><column-value><![CDATA[");
566                    sb.append(getTicketId());
567                    sb.append("]]></column-value></column>");
568                    sb.append(
569                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
570                    sb.append(getCompanyId());
571                    sb.append("]]></column-value></column>");
572                    sb.append(
573                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
574                    sb.append(getCreateDate());
575                    sb.append("]]></column-value></column>");
576                    sb.append(
577                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
578                    sb.append(getClassNameId());
579                    sb.append("]]></column-value></column>");
580                    sb.append(
581                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
582                    sb.append(getClassPK());
583                    sb.append("]]></column-value></column>");
584                    sb.append(
585                            "<column><column-name>key</column-name><column-value><![CDATA[");
586                    sb.append(getKey());
587                    sb.append("]]></column-value></column>");
588                    sb.append(
589                            "<column><column-name>type</column-name><column-value><![CDATA[");
590                    sb.append(getType());
591                    sb.append("]]></column-value></column>");
592                    sb.append(
593                            "<column><column-name>extraInfo</column-name><column-value><![CDATA[");
594                    sb.append(getExtraInfo());
595                    sb.append("]]></column-value></column>");
596                    sb.append(
597                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
598                    sb.append(getExpirationDate());
599                    sb.append("]]></column-value></column>");
600    
601                    sb.append("</model>");
602    
603                    return sb.toString();
604            }
605    
606            private static final ClassLoader _classLoader = Ticket.class.getClassLoader();
607            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
608                            Ticket.class
609                    };
610            private long _mvccVersion;
611            private long _ticketId;
612            private long _companyId;
613            private Date _createDate;
614            private long _classNameId;
615            private long _classPK;
616            private String _key;
617            private String _originalKey;
618            private int _type;
619            private String _extraInfo;
620            private Date _expirationDate;
621            private long _columnBitmask;
622            private Ticket _escapedModel;
623    }