001    /**
002     * Copyright (c) 2000-2010 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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Ticket;
022    import com.liferay.portal.model.TicketModel;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.Date;
036    
037    /**
038     * 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.
039     *
040     * <p>
041     * 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}.
042     * </p>
043     *
044     * <p>
045     * 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.
046     * </p>
047     *
048     * @author Brian Wing Shun Chan
049     * @see TicketImpl
050     * @see com.liferay.portal.model.Ticket
051     * @see com.liferay.portal.model.TicketModel
052     * @generated
053     */
054    public class TicketModelImpl extends BaseModelImpl<Ticket>
055            implements TicketModel {
056            public static final String TABLE_NAME = "Ticket";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "ticketId", new Integer(Types.BIGINT) },
059                            { "companyId", new Integer(Types.BIGINT) },
060                            { "createDate", new Integer(Types.TIMESTAMP) },
061                            { "classNameId", new Integer(Types.BIGINT) },
062                            { "classPK", new Integer(Types.BIGINT) },
063                            { "key_", new Integer(Types.VARCHAR) },
064                            { "expirationDate", new Integer(Types.TIMESTAMP) }
065                    };
066            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,expirationDate DATE null)";
067            public static final String TABLE_SQL_DROP = "drop table Ticket";
068            public static final String ORDER_BY_JPQL = " ORDER BY ticket.ticketId ASC";
069            public static final String ORDER_BY_SQL = " ORDER BY Ticket.ticketId ASC";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Ticket"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Ticket"),
078                            true);
079            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
080                                    "lock.expiration.time.com.liferay.portal.model.Ticket"));
081    
082            public TicketModelImpl() {
083            }
084    
085            public long getPrimaryKey() {
086                    return _ticketId;
087            }
088    
089            public void setPrimaryKey(long pk) {
090                    setTicketId(pk);
091            }
092    
093            public Serializable getPrimaryKeyObj() {
094                    return new Long(_ticketId);
095            }
096    
097            public long getTicketId() {
098                    return _ticketId;
099            }
100    
101            public void setTicketId(long ticketId) {
102                    _ticketId = ticketId;
103            }
104    
105            public long getCompanyId() {
106                    return _companyId;
107            }
108    
109            public void setCompanyId(long companyId) {
110                    _companyId = companyId;
111            }
112    
113            public Date getCreateDate() {
114                    return _createDate;
115            }
116    
117            public void setCreateDate(Date createDate) {
118                    _createDate = createDate;
119            }
120    
121            public String getClassName() {
122                    if (getClassNameId() <= 0) {
123                            return StringPool.BLANK;
124                    }
125    
126                    return PortalUtil.getClassName(getClassNameId());
127            }
128    
129            public long getClassNameId() {
130                    return _classNameId;
131            }
132    
133            public void setClassNameId(long classNameId) {
134                    _classNameId = classNameId;
135            }
136    
137            public long getClassPK() {
138                    return _classPK;
139            }
140    
141            public void setClassPK(long classPK) {
142                    _classPK = classPK;
143            }
144    
145            public String getKey() {
146                    if (_key == null) {
147                            return StringPool.BLANK;
148                    }
149                    else {
150                            return _key;
151                    }
152            }
153    
154            public void setKey(String key) {
155                    _key = key;
156    
157                    if (_originalKey == null) {
158                            _originalKey = key;
159                    }
160            }
161    
162            public String getOriginalKey() {
163                    return GetterUtil.getString(_originalKey);
164            }
165    
166            public Date getExpirationDate() {
167                    return _expirationDate;
168            }
169    
170            public void setExpirationDate(Date expirationDate) {
171                    _expirationDate = expirationDate;
172            }
173    
174            public Ticket toEscapedModel() {
175                    if (isEscapedModel()) {
176                            return (Ticket)this;
177                    }
178                    else {
179                            return (Ticket)Proxy.newProxyInstance(Ticket.class.getClassLoader(),
180                                    new Class[] { Ticket.class }, new AutoEscapeBeanHandler(this));
181                    }
182            }
183    
184            public ExpandoBridge getExpandoBridge() {
185                    if (_expandoBridge == null) {
186                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
187                                            Ticket.class.getName(), getPrimaryKey());
188                    }
189    
190                    return _expandoBridge;
191            }
192    
193            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
194                    getExpandoBridge().setAttributes(serviceContext);
195            }
196    
197            public Object clone() {
198                    TicketImpl clone = new TicketImpl();
199    
200                    clone.setTicketId(getTicketId());
201                    clone.setCompanyId(getCompanyId());
202                    clone.setCreateDate(getCreateDate());
203                    clone.setClassNameId(getClassNameId());
204                    clone.setClassPK(getClassPK());
205                    clone.setKey(getKey());
206                    clone.setExpirationDate(getExpirationDate());
207    
208                    return clone;
209            }
210    
211            public int compareTo(Ticket ticket) {
212                    int value = 0;
213    
214                    if (getTicketId() < ticket.getTicketId()) {
215                            value = -1;
216                    }
217                    else if (getTicketId() > ticket.getTicketId()) {
218                            value = 1;
219                    }
220                    else {
221                            value = 0;
222                    }
223    
224                    if (value != 0) {
225                            return value;
226                    }
227    
228                    return 0;
229            }
230    
231            public boolean equals(Object obj) {
232                    if (obj == null) {
233                            return false;
234                    }
235    
236                    Ticket ticket = null;
237    
238                    try {
239                            ticket = (Ticket)obj;
240                    }
241                    catch (ClassCastException cce) {
242                            return false;
243                    }
244    
245                    long pk = ticket.getPrimaryKey();
246    
247                    if (getPrimaryKey() == pk) {
248                            return true;
249                    }
250                    else {
251                            return false;
252                    }
253            }
254    
255            public int hashCode() {
256                    return (int)getPrimaryKey();
257            }
258    
259            public String toString() {
260                    StringBundler sb = new StringBundler(15);
261    
262                    sb.append("{ticketId=");
263                    sb.append(getTicketId());
264                    sb.append(", companyId=");
265                    sb.append(getCompanyId());
266                    sb.append(", createDate=");
267                    sb.append(getCreateDate());
268                    sb.append(", classNameId=");
269                    sb.append(getClassNameId());
270                    sb.append(", classPK=");
271                    sb.append(getClassPK());
272                    sb.append(", key=");
273                    sb.append(getKey());
274                    sb.append(", expirationDate=");
275                    sb.append(getExpirationDate());
276                    sb.append("}");
277    
278                    return sb.toString();
279            }
280    
281            public String toXmlString() {
282                    StringBundler sb = new StringBundler(25);
283    
284                    sb.append("<model><model-name>");
285                    sb.append("com.liferay.portal.model.Ticket");
286                    sb.append("</model-name>");
287    
288                    sb.append(
289                            "<column><column-name>ticketId</column-name><column-value><![CDATA[");
290                    sb.append(getTicketId());
291                    sb.append("]]></column-value></column>");
292                    sb.append(
293                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
294                    sb.append(getCompanyId());
295                    sb.append("]]></column-value></column>");
296                    sb.append(
297                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
298                    sb.append(getCreateDate());
299                    sb.append("]]></column-value></column>");
300                    sb.append(
301                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
302                    sb.append(getClassNameId());
303                    sb.append("]]></column-value></column>");
304                    sb.append(
305                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
306                    sb.append(getClassPK());
307                    sb.append("]]></column-value></column>");
308                    sb.append(
309                            "<column><column-name>key</column-name><column-value><![CDATA[");
310                    sb.append(getKey());
311                    sb.append("]]></column-value></column>");
312                    sb.append(
313                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
314                    sb.append(getExpirationDate());
315                    sb.append("]]></column-value></column>");
316    
317                    sb.append("</model>");
318    
319                    return sb.toString();
320            }
321    
322            private long _ticketId;
323            private long _companyId;
324            private Date _createDate;
325            private long _classNameId;
326            private long _classPK;
327            private String _key;
328            private String _originalKey;
329            private Date _expirationDate;
330            private transient ExpandoBridge _expandoBridge;
331    }