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