1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.Ticket;
22  import com.liferay.portal.model.TicketSoap;
23  import com.liferay.portal.service.ServiceContext;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.expando.model.ExpandoBridge;
27  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.Date;
37  import java.util.List;
38  
39  /**
40   * <a href="TicketModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This interface is a model that represents the Ticket table in the
49   * database.
50   * </p>
51   *
52   * @author    Brian Wing Shun Chan
53   * @see       TicketImpl
54   * @see       com.liferay.portal.model.Ticket
55   * @see       com.liferay.portal.model.TicketModel
56   * @generated
57   */
58  public class TicketModelImpl extends BaseModelImpl<Ticket> {
59      public static final String TABLE_NAME = "Ticket";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "ticketId", new Integer(Types.BIGINT) },
62              { "companyId", new Integer(Types.BIGINT) },
63              { "createDate", new Integer(Types.TIMESTAMP) },
64              { "classNameId", new Integer(Types.BIGINT) },
65              { "classPK", new Integer(Types.BIGINT) },
66              { "key_", new Integer(Types.VARCHAR) },
67              { "expirationDate", new Integer(Types.TIMESTAMP) }
68          };
69      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)";
70      public static final String TABLE_SQL_DROP = "drop table Ticket";
71      public static final String ORDER_BY_JPQL = " ORDER BY ticket.ticketId ASC";
72      public static final String ORDER_BY_SQL = " ORDER BY Ticket.ticketId ASC";
73      public static final String DATA_SOURCE = "liferayDataSource";
74      public static final String SESSION_FACTORY = "liferaySessionFactory";
75      public static final String TX_MANAGER = "liferayTransactionManager";
76      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.entity.cache.enabled.com.liferay.portal.model.Ticket"),
78              true);
79      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portal.model.Ticket"),
81              true);
82  
83      public static Ticket toModel(TicketSoap soapModel) {
84          Ticket model = new TicketImpl();
85  
86          model.setTicketId(soapModel.getTicketId());
87          model.setCompanyId(soapModel.getCompanyId());
88          model.setCreateDate(soapModel.getCreateDate());
89          model.setClassNameId(soapModel.getClassNameId());
90          model.setClassPK(soapModel.getClassPK());
91          model.setKey(soapModel.getKey());
92          model.setExpirationDate(soapModel.getExpirationDate());
93  
94          return model;
95      }
96  
97      public static List<Ticket> toModels(TicketSoap[] soapModels) {
98          List<Ticket> models = new ArrayList<Ticket>(soapModels.length);
99  
100         for (TicketSoap soapModel : soapModels) {
101             models.add(toModel(soapModel));
102         }
103 
104         return models;
105     }
106 
107     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
108                 "lock.expiration.time.com.liferay.portal.model.Ticket"));
109 
110     public TicketModelImpl() {
111     }
112 
113     public long getPrimaryKey() {
114         return _ticketId;
115     }
116 
117     public void setPrimaryKey(long pk) {
118         setTicketId(pk);
119     }
120 
121     public Serializable getPrimaryKeyObj() {
122         return new Long(_ticketId);
123     }
124 
125     public long getTicketId() {
126         return _ticketId;
127     }
128 
129     public void setTicketId(long ticketId) {
130         _ticketId = ticketId;
131     }
132 
133     public long getCompanyId() {
134         return _companyId;
135     }
136 
137     public void setCompanyId(long companyId) {
138         _companyId = companyId;
139     }
140 
141     public Date getCreateDate() {
142         return _createDate;
143     }
144 
145     public void setCreateDate(Date createDate) {
146         _createDate = createDate;
147     }
148 
149     public String getClassName() {
150         if (getClassNameId() <= 0) {
151             return StringPool.BLANK;
152         }
153 
154         return PortalUtil.getClassName(getClassNameId());
155     }
156 
157     public long getClassNameId() {
158         return _classNameId;
159     }
160 
161     public void setClassNameId(long classNameId) {
162         _classNameId = classNameId;
163     }
164 
165     public long getClassPK() {
166         return _classPK;
167     }
168 
169     public void setClassPK(long classPK) {
170         _classPK = classPK;
171     }
172 
173     public String getKey() {
174         if (_key == null) {
175             return StringPool.BLANK;
176         }
177         else {
178             return _key;
179         }
180     }
181 
182     public void setKey(String key) {
183         _key = key;
184 
185         if (_originalKey == null) {
186             _originalKey = key;
187         }
188     }
189 
190     public String getOriginalKey() {
191         return GetterUtil.getString(_originalKey);
192     }
193 
194     public Date getExpirationDate() {
195         return _expirationDate;
196     }
197 
198     public void setExpirationDate(Date expirationDate) {
199         _expirationDate = expirationDate;
200     }
201 
202     public Ticket toEscapedModel() {
203         if (isEscapedModel()) {
204             return (Ticket)this;
205         }
206         else {
207             return (Ticket)Proxy.newProxyInstance(Ticket.class.getClassLoader(),
208                 new Class[] { Ticket.class }, new AutoEscapeBeanHandler(this));
209         }
210     }
211 
212     public ExpandoBridge getExpandoBridge() {
213         if (_expandoBridge == null) {
214             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
215                     Ticket.class.getName(), getPrimaryKey());
216         }
217 
218         return _expandoBridge;
219     }
220 
221     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
222         getExpandoBridge().setAttributes(serviceContext);
223     }
224 
225     public Object clone() {
226         TicketImpl clone = new TicketImpl();
227 
228         clone.setTicketId(getTicketId());
229         clone.setCompanyId(getCompanyId());
230         clone.setCreateDate(getCreateDate());
231         clone.setClassNameId(getClassNameId());
232         clone.setClassPK(getClassPK());
233         clone.setKey(getKey());
234         clone.setExpirationDate(getExpirationDate());
235 
236         return clone;
237     }
238 
239     public int compareTo(Ticket ticket) {
240         int value = 0;
241 
242         if (getTicketId() < ticket.getTicketId()) {
243             value = -1;
244         }
245         else if (getTicketId() > ticket.getTicketId()) {
246             value = 1;
247         }
248         else {
249             value = 0;
250         }
251 
252         if (value != 0) {
253             return value;
254         }
255 
256         return 0;
257     }
258 
259     public boolean equals(Object obj) {
260         if (obj == null) {
261             return false;
262         }
263 
264         Ticket ticket = null;
265 
266         try {
267             ticket = (Ticket)obj;
268         }
269         catch (ClassCastException cce) {
270             return false;
271         }
272 
273         long pk = ticket.getPrimaryKey();
274 
275         if (getPrimaryKey() == pk) {
276             return true;
277         }
278         else {
279             return false;
280         }
281     }
282 
283     public int hashCode() {
284         return (int)getPrimaryKey();
285     }
286 
287     public String toString() {
288         StringBundler sb = new StringBundler(15);
289 
290         sb.append("{ticketId=");
291         sb.append(getTicketId());
292         sb.append(", companyId=");
293         sb.append(getCompanyId());
294         sb.append(", createDate=");
295         sb.append(getCreateDate());
296         sb.append(", classNameId=");
297         sb.append(getClassNameId());
298         sb.append(", classPK=");
299         sb.append(getClassPK());
300         sb.append(", key=");
301         sb.append(getKey());
302         sb.append(", expirationDate=");
303         sb.append(getExpirationDate());
304         sb.append("}");
305 
306         return sb.toString();
307     }
308 
309     public String toXmlString() {
310         StringBundler sb = new StringBundler(25);
311 
312         sb.append("<model><model-name>");
313         sb.append("com.liferay.portal.model.Ticket");
314         sb.append("</model-name>");
315 
316         sb.append(
317             "<column><column-name>ticketId</column-name><column-value><![CDATA[");
318         sb.append(getTicketId());
319         sb.append("]]></column-value></column>");
320         sb.append(
321             "<column><column-name>companyId</column-name><column-value><![CDATA[");
322         sb.append(getCompanyId());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>createDate</column-name><column-value><![CDATA[");
326         sb.append(getCreateDate());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
330         sb.append(getClassNameId());
331         sb.append("]]></column-value></column>");
332         sb.append(
333             "<column><column-name>classPK</column-name><column-value><![CDATA[");
334         sb.append(getClassPK());
335         sb.append("]]></column-value></column>");
336         sb.append(
337             "<column><column-name>key</column-name><column-value><![CDATA[");
338         sb.append(getKey());
339         sb.append("]]></column-value></column>");
340         sb.append(
341             "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
342         sb.append(getExpirationDate());
343         sb.append("]]></column-value></column>");
344 
345         sb.append("</model>");
346 
347         return sb.toString();
348     }
349 
350     private long _ticketId;
351     private long _companyId;
352     private Date _createDate;
353     private long _classNameId;
354     private long _classPK;
355     private String _key;
356     private String _originalKey;
357     private Date _expirationDate;
358     private transient ExpandoBridge _expandoBridge;
359 }