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