1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.Phone;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.util.Html;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.Date;
40  
41  /**
42   * <a href="PhoneModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>Phone</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.Phone
57   * @see com.liferay.portal.service.model.PhoneModel
58   * @see com.liferay.portal.service.model.impl.PhoneImpl
59   *
60   */
61  public class PhoneModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "Phone";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "phoneId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "userId", new Integer(Types.BIGINT) },
71              
72  
73              { "userName", new Integer(Types.VARCHAR) },
74              
75  
76              { "createDate", new Integer(Types.TIMESTAMP) },
77              
78  
79              { "modifiedDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "classNameId", new Integer(Types.BIGINT) },
83              
84  
85              { "classPK", new Integer(Types.BIGINT) },
86              
87  
88              { "number_", new Integer(Types.VARCHAR) },
89              
90  
91              { "extension", new Integer(Types.VARCHAR) },
92              
93  
94              { "typeId", new Integer(Types.INTEGER) },
95              
96  
97              { "primary_", new Integer(Types.BOOLEAN) }
98          };
99      public static final String TABLE_SQL_CREATE = "create table Phone (phoneId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,number_ VARCHAR(75) null,extension VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
100     public static final String TABLE_SQL_DROP = "drop table Phone";
101     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
102                 "value.object.finder.cache.enabled.com.liferay.portal.model.Phone"),
103             true);
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portal.model.Phone"));
106 
107     public PhoneModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _phoneId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setPhoneId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_phoneId);
120     }
121 
122     public long getPhoneId() {
123         return _phoneId;
124     }
125 
126     public void setPhoneId(long phoneId) {
127         if (phoneId != _phoneId) {
128             _phoneId = phoneId;
129         }
130     }
131 
132     public long getCompanyId() {
133         return _companyId;
134     }
135 
136     public void setCompanyId(long companyId) {
137         if (companyId != _companyId) {
138             _companyId = companyId;
139         }
140     }
141 
142     public long getUserId() {
143         return _userId;
144     }
145 
146     public void setUserId(long userId) {
147         if (userId != _userId) {
148             _userId = userId;
149         }
150     }
151 
152     public String getUserName() {
153         return GetterUtil.getString(_userName);
154     }
155 
156     public void setUserName(String userName) {
157         if (((userName == null) && (_userName != null)) ||
158                 ((userName != null) && (_userName == null)) ||
159                 ((userName != null) && (_userName != null) &&
160                 !userName.equals(_userName))) {
161             _userName = userName;
162         }
163     }
164 
165     public Date getCreateDate() {
166         return _createDate;
167     }
168 
169     public void setCreateDate(Date createDate) {
170         if (((createDate == null) && (_createDate != null)) ||
171                 ((createDate != null) && (_createDate == null)) ||
172                 ((createDate != null) && (_createDate != null) &&
173                 !createDate.equals(_createDate))) {
174             _createDate = createDate;
175         }
176     }
177 
178     public Date getModifiedDate() {
179         return _modifiedDate;
180     }
181 
182     public void setModifiedDate(Date modifiedDate) {
183         if (((modifiedDate == null) && (_modifiedDate != null)) ||
184                 ((modifiedDate != null) && (_modifiedDate == null)) ||
185                 ((modifiedDate != null) && (_modifiedDate != null) &&
186                 !modifiedDate.equals(_modifiedDate))) {
187             _modifiedDate = modifiedDate;
188         }
189     }
190 
191     public long getClassNameId() {
192         return _classNameId;
193     }
194 
195     public void setClassNameId(long classNameId) {
196         if (classNameId != _classNameId) {
197             _classNameId = classNameId;
198         }
199     }
200 
201     public long getClassPK() {
202         return _classPK;
203     }
204 
205     public void setClassPK(long classPK) {
206         if (classPK != _classPK) {
207             _classPK = classPK;
208         }
209     }
210 
211     public String getNumber() {
212         return GetterUtil.getString(_number);
213     }
214 
215     public void setNumber(String number) {
216         if (((number == null) && (_number != null)) ||
217                 ((number != null) && (_number == null)) ||
218                 ((number != null) && (_number != null) &&
219                 !number.equals(_number))) {
220             _number = number;
221         }
222     }
223 
224     public String getExtension() {
225         return GetterUtil.getString(_extension);
226     }
227 
228     public void setExtension(String extension) {
229         if (((extension == null) && (_extension != null)) ||
230                 ((extension != null) && (_extension == null)) ||
231                 ((extension != null) && (_extension != null) &&
232                 !extension.equals(_extension))) {
233             _extension = extension;
234         }
235     }
236 
237     public int getTypeId() {
238         return _typeId;
239     }
240 
241     public void setTypeId(int typeId) {
242         if (typeId != _typeId) {
243             _typeId = typeId;
244         }
245     }
246 
247     public boolean getPrimary() {
248         return _primary;
249     }
250 
251     public boolean isPrimary() {
252         return _primary;
253     }
254 
255     public void setPrimary(boolean primary) {
256         if (primary != _primary) {
257             _primary = primary;
258         }
259     }
260 
261     public Phone toEscapedModel() {
262         if (isEscapedModel()) {
263             return (Phone)this;
264         }
265         else {
266             Phone model = new PhoneImpl();
267 
268             model.setEscapedModel(true);
269 
270             model.setPhoneId(getPhoneId());
271             model.setCompanyId(getCompanyId());
272             model.setUserId(getUserId());
273             model.setUserName(Html.escape(getUserName()));
274             model.setCreateDate(getCreateDate());
275             model.setModifiedDate(getModifiedDate());
276             model.setClassNameId(getClassNameId());
277             model.setClassPK(getClassPK());
278             model.setNumber(Html.escape(getNumber()));
279             model.setExtension(Html.escape(getExtension()));
280             model.setTypeId(getTypeId());
281             model.setPrimary(getPrimary());
282 
283             model = (Phone)Proxy.newProxyInstance(Phone.class.getClassLoader(),
284                     new Class[] { Phone.class }, new ReadOnlyBeanHandler(model));
285 
286             return model;
287         }
288     }
289 
290     public Object clone() {
291         PhoneImpl clone = new PhoneImpl();
292 
293         clone.setPhoneId(getPhoneId());
294         clone.setCompanyId(getCompanyId());
295         clone.setUserId(getUserId());
296         clone.setUserName(getUserName());
297         clone.setCreateDate(getCreateDate());
298         clone.setModifiedDate(getModifiedDate());
299         clone.setClassNameId(getClassNameId());
300         clone.setClassPK(getClassPK());
301         clone.setNumber(getNumber());
302         clone.setExtension(getExtension());
303         clone.setTypeId(getTypeId());
304         clone.setPrimary(getPrimary());
305 
306         return clone;
307     }
308 
309     public int compareTo(Object obj) {
310         if (obj == null) {
311             return -1;
312         }
313 
314         PhoneImpl phone = (PhoneImpl)obj;
315 
316         int value = 0;
317 
318         value = DateUtil.compareTo(getCreateDate(), phone.getCreateDate());
319 
320         if (value != 0) {
321             return value;
322         }
323 
324         return 0;
325     }
326 
327     public boolean equals(Object obj) {
328         if (obj == null) {
329             return false;
330         }
331 
332         PhoneImpl phone = null;
333 
334         try {
335             phone = (PhoneImpl)obj;
336         }
337         catch (ClassCastException cce) {
338             return false;
339         }
340 
341         long pk = phone.getPrimaryKey();
342 
343         if (getPrimaryKey() == pk) {
344             return true;
345         }
346         else {
347             return false;
348         }
349     }
350 
351     public int hashCode() {
352         return (int)getPrimaryKey();
353     }
354 
355     private long _phoneId;
356     private long _companyId;
357     private long _userId;
358     private String _userName;
359     private Date _createDate;
360     private Date _modifiedDate;
361     private long _classNameId;
362     private long _classPK;
363     private String _number;
364     private String _extension;
365     private int _typeId;
366     private boolean _primary;
367 }