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