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.kernel.util.HtmlUtil;
29  import com.liferay.portal.kernel.util.StringPool;
30  import com.liferay.portal.model.Phone;
31  import com.liferay.portal.model.PhoneSoap;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="PhoneModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>Phone</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.model.Phone
60   * @see com.liferay.portal.model.PhoneModel
61   * @see com.liferay.portal.model.impl.PhoneImpl
62   *
63   */
64  public class PhoneModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "Phone";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "phoneId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "classNameId", new Integer(Types.BIGINT) },
86              
87  
88              { "classPK", new Integer(Types.BIGINT) },
89              
90  
91              { "number_", new Integer(Types.VARCHAR) },
92              
93  
94              { "extension", new Integer(Types.VARCHAR) },
95              
96  
97              { "typeId", new Integer(Types.INTEGER) },
98              
99  
100             { "primary_", new Integer(Types.BOOLEAN) }
101         };
102     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)";
103     public static final String TABLE_SQL_DROP = "drop table Phone";
104     public static final String DATA_SOURCE = "liferayDataSource";
105     public static final String SESSION_FACTORY = "liferaySessionFactory";
106     public static final String TX_MANAGER = "liferayTransactionManager";
107     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
108                 "value.object.finder.cache.enabled.com.liferay.portal.model.Phone"),
109             true);
110 
111     public static Phone toModel(PhoneSoap soapModel) {
112         Phone model = new PhoneImpl();
113 
114         model.setPhoneId(soapModel.getPhoneId());
115         model.setCompanyId(soapModel.getCompanyId());
116         model.setUserId(soapModel.getUserId());
117         model.setUserName(soapModel.getUserName());
118         model.setCreateDate(soapModel.getCreateDate());
119         model.setModifiedDate(soapModel.getModifiedDate());
120         model.setClassNameId(soapModel.getClassNameId());
121         model.setClassPK(soapModel.getClassPK());
122         model.setNumber(soapModel.getNumber());
123         model.setExtension(soapModel.getExtension());
124         model.setTypeId(soapModel.getTypeId());
125         model.setPrimary(soapModel.getPrimary());
126 
127         return model;
128     }
129 
130     public static List<Phone> toModels(PhoneSoap[] soapModels) {
131         List<Phone> models = new ArrayList<Phone>(soapModels.length);
132 
133         for (PhoneSoap soapModel : soapModels) {
134             models.add(toModel(soapModel));
135         }
136 
137         return models;
138     }
139 
140     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
141                 "lock.expiration.time.com.liferay.portal.model.Phone"));
142 
143     public PhoneModelImpl() {
144     }
145 
146     public long getPrimaryKey() {
147         return _phoneId;
148     }
149 
150     public void setPrimaryKey(long pk) {
151         setPhoneId(pk);
152     }
153 
154     public Serializable getPrimaryKeyObj() {
155         return new Long(_phoneId);
156     }
157 
158     public long getPhoneId() {
159         return _phoneId;
160     }
161 
162     public void setPhoneId(long phoneId) {
163         if (phoneId != _phoneId) {
164             _phoneId = phoneId;
165         }
166     }
167 
168     public long getCompanyId() {
169         return _companyId;
170     }
171 
172     public void setCompanyId(long companyId) {
173         if (companyId != _companyId) {
174             _companyId = companyId;
175         }
176     }
177 
178     public long getUserId() {
179         return _userId;
180     }
181 
182     public void setUserId(long userId) {
183         if (userId != _userId) {
184             _userId = userId;
185         }
186     }
187 
188     public String getUserName() {
189         return GetterUtil.getString(_userName);
190     }
191 
192     public void setUserName(String userName) {
193         if (((userName == null) && (_userName != null)) ||
194                 ((userName != null) && (_userName == null)) ||
195                 ((userName != null) && (_userName != null) &&
196                 !userName.equals(_userName))) {
197             _userName = userName;
198         }
199     }
200 
201     public Date getCreateDate() {
202         return _createDate;
203     }
204 
205     public void setCreateDate(Date createDate) {
206         if (((createDate == null) && (_createDate != null)) ||
207                 ((createDate != null) && (_createDate == null)) ||
208                 ((createDate != null) && (_createDate != null) &&
209                 !createDate.equals(_createDate))) {
210             _createDate = createDate;
211         }
212     }
213 
214     public Date getModifiedDate() {
215         return _modifiedDate;
216     }
217 
218     public void setModifiedDate(Date modifiedDate) {
219         if (((modifiedDate == null) && (_modifiedDate != null)) ||
220                 ((modifiedDate != null) && (_modifiedDate == null)) ||
221                 ((modifiedDate != null) && (_modifiedDate != null) &&
222                 !modifiedDate.equals(_modifiedDate))) {
223             _modifiedDate = modifiedDate;
224         }
225     }
226 
227     public String getClassName() {
228         if (getClassNameId() <= 0) {
229             return StringPool.BLANK;
230         }
231 
232         return PortalUtil.getClassName(getClassNameId());
233     }
234 
235     public long getClassNameId() {
236         return _classNameId;
237     }
238 
239     public void setClassNameId(long classNameId) {
240         if (classNameId != _classNameId) {
241             _classNameId = classNameId;
242         }
243     }
244 
245     public long getClassPK() {
246         return _classPK;
247     }
248 
249     public void setClassPK(long classPK) {
250         if (classPK != _classPK) {
251             _classPK = classPK;
252         }
253     }
254 
255     public String getNumber() {
256         return GetterUtil.getString(_number);
257     }
258 
259     public void setNumber(String number) {
260         if (((number == null) && (_number != null)) ||
261                 ((number != null) && (_number == null)) ||
262                 ((number != null) && (_number != null) &&
263                 !number.equals(_number))) {
264             _number = number;
265         }
266     }
267 
268     public String getExtension() {
269         return GetterUtil.getString(_extension);
270     }
271 
272     public void setExtension(String extension) {
273         if (((extension == null) && (_extension != null)) ||
274                 ((extension != null) && (_extension == null)) ||
275                 ((extension != null) && (_extension != null) &&
276                 !extension.equals(_extension))) {
277             _extension = extension;
278         }
279     }
280 
281     public int getTypeId() {
282         return _typeId;
283     }
284 
285     public void setTypeId(int typeId) {
286         if (typeId != _typeId) {
287             _typeId = typeId;
288         }
289     }
290 
291     public boolean getPrimary() {
292         return _primary;
293     }
294 
295     public boolean isPrimary() {
296         return _primary;
297     }
298 
299     public void setPrimary(boolean primary) {
300         if (primary != _primary) {
301             _primary = primary;
302         }
303     }
304 
305     public Phone toEscapedModel() {
306         if (isEscapedModel()) {
307             return (Phone)this;
308         }
309         else {
310             Phone model = new PhoneImpl();
311 
312             model.setNew(isNew());
313             model.setEscapedModel(true);
314 
315             model.setPhoneId(getPhoneId());
316             model.setCompanyId(getCompanyId());
317             model.setUserId(getUserId());
318             model.setUserName(HtmlUtil.escape(getUserName()));
319             model.setCreateDate(getCreateDate());
320             model.setModifiedDate(getModifiedDate());
321             model.setClassNameId(getClassNameId());
322             model.setClassPK(getClassPK());
323             model.setNumber(HtmlUtil.escape(getNumber()));
324             model.setExtension(HtmlUtil.escape(getExtension()));
325             model.setTypeId(getTypeId());
326             model.setPrimary(getPrimary());
327 
328             model = (Phone)Proxy.newProxyInstance(Phone.class.getClassLoader(),
329                     new Class[] { Phone.class }, new ReadOnlyBeanHandler(model));
330 
331             return model;
332         }
333     }
334 
335     public Object clone() {
336         PhoneImpl clone = new PhoneImpl();
337 
338         clone.setPhoneId(getPhoneId());
339         clone.setCompanyId(getCompanyId());
340         clone.setUserId(getUserId());
341         clone.setUserName(getUserName());
342         clone.setCreateDate(getCreateDate());
343         clone.setModifiedDate(getModifiedDate());
344         clone.setClassNameId(getClassNameId());
345         clone.setClassPK(getClassPK());
346         clone.setNumber(getNumber());
347         clone.setExtension(getExtension());
348         clone.setTypeId(getTypeId());
349         clone.setPrimary(getPrimary());
350 
351         return clone;
352     }
353 
354     public int compareTo(Object obj) {
355         if (obj == null) {
356             return -1;
357         }
358 
359         PhoneImpl phone = (PhoneImpl)obj;
360 
361         int value = 0;
362 
363         value = DateUtil.compareTo(getCreateDate(), phone.getCreateDate());
364 
365         if (value != 0) {
366             return value;
367         }
368 
369         return 0;
370     }
371 
372     public boolean equals(Object obj) {
373         if (obj == null) {
374             return false;
375         }
376 
377         PhoneImpl phone = null;
378 
379         try {
380             phone = (PhoneImpl)obj;
381         }
382         catch (ClassCastException cce) {
383             return false;
384         }
385 
386         long pk = phone.getPrimaryKey();
387 
388         if (getPrimaryKey() == pk) {
389             return true;
390         }
391         else {
392             return false;
393         }
394     }
395 
396     public int hashCode() {
397         return (int)getPrimaryKey();
398     }
399 
400     private long _phoneId;
401     private long _companyId;
402     private long _userId;
403     private String _userName;
404     private Date _createDate;
405     private Date _modifiedDate;
406     private long _classNameId;
407     private long _classPK;
408     private String _number;
409     private String _extension;
410     private int _typeId;
411     private boolean _primary;
412 }