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