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