1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.DateUtil;
24  import com.liferay.portal.kernel.util.GetterUtil;
25  import com.liferay.portal.kernel.util.HtmlUtil;
26  import com.liferay.portal.kernel.util.StringPool;
27  import com.liferay.portal.model.Phone;
28  import com.liferay.portal.model.PhoneSoap;
29  import com.liferay.portal.util.PortalUtil;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.Date;
39  import java.util.List;
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.model.Phone
57   * @see com.liferay.portal.model.PhoneModel
58   * @see com.liferay.portal.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 String DATA_SOURCE = "liferayDataSource";
102     public static final String SESSION_FACTORY = "liferaySessionFactory";
103     public static final String TX_MANAGER = "liferayTransactionManager";
104     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
105                 "value.object.finder.cache.enabled.com.liferay.portal.model.Phone"),
106             true);
107 
108     public static Phone toModel(PhoneSoap soapModel) {
109         Phone model = new PhoneImpl();
110 
111         model.setPhoneId(soapModel.getPhoneId());
112         model.setCompanyId(soapModel.getCompanyId());
113         model.setUserId(soapModel.getUserId());
114         model.setUserName(soapModel.getUserName());
115         model.setCreateDate(soapModel.getCreateDate());
116         model.setModifiedDate(soapModel.getModifiedDate());
117         model.setClassNameId(soapModel.getClassNameId());
118         model.setClassPK(soapModel.getClassPK());
119         model.setNumber(soapModel.getNumber());
120         model.setExtension(soapModel.getExtension());
121         model.setTypeId(soapModel.getTypeId());
122         model.setPrimary(soapModel.getPrimary());
123 
124         return model;
125     }
126 
127     public static List<Phone> toModels(PhoneSoap[] soapModels) {
128         List<Phone> models = new ArrayList<Phone>(soapModels.length);
129 
130         for (PhoneSoap soapModel : soapModels) {
131             models.add(toModel(soapModel));
132         }
133 
134         return models;
135     }
136 
137     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
138                 "lock.expiration.time.com.liferay.portal.model.Phone"));
139 
140     public PhoneModelImpl() {
141     }
142 
143     public long getPrimaryKey() {
144         return _phoneId;
145     }
146 
147     public void setPrimaryKey(long pk) {
148         setPhoneId(pk);
149     }
150 
151     public Serializable getPrimaryKeyObj() {
152         return new Long(_phoneId);
153     }
154 
155     public long getPhoneId() {
156         return _phoneId;
157     }
158 
159     public void setPhoneId(long phoneId) {
160         if (phoneId != _phoneId) {
161             _phoneId = phoneId;
162         }
163     }
164 
165     public long getCompanyId() {
166         return _companyId;
167     }
168 
169     public void setCompanyId(long companyId) {
170         if (companyId != _companyId) {
171             _companyId = companyId;
172         }
173     }
174 
175     public long getUserId() {
176         return _userId;
177     }
178 
179     public void setUserId(long userId) {
180         if (userId != _userId) {
181             _userId = userId;
182         }
183     }
184 
185     public String getUserName() {
186         return GetterUtil.getString(_userName);
187     }
188 
189     public void setUserName(String userName) {
190         if (((userName == null) && (_userName != null)) ||
191                 ((userName != null) && (_userName == null)) ||
192                 ((userName != null) && (_userName != null) &&
193                 !userName.equals(_userName))) {
194             _userName = userName;
195         }
196     }
197 
198     public Date getCreateDate() {
199         return _createDate;
200     }
201 
202     public void setCreateDate(Date createDate) {
203         if (((createDate == null) && (_createDate != null)) ||
204                 ((createDate != null) && (_createDate == null)) ||
205                 ((createDate != null) && (_createDate != null) &&
206                 !createDate.equals(_createDate))) {
207             _createDate = createDate;
208         }
209     }
210 
211     public Date getModifiedDate() {
212         return _modifiedDate;
213     }
214 
215     public void setModifiedDate(Date modifiedDate) {
216         if (((modifiedDate == null) && (_modifiedDate != null)) ||
217                 ((modifiedDate != null) && (_modifiedDate == null)) ||
218                 ((modifiedDate != null) && (_modifiedDate != null) &&
219                 !modifiedDate.equals(_modifiedDate))) {
220             _modifiedDate = modifiedDate;
221         }
222     }
223 
224     public String getClassName() {
225         if (getClassNameId() <= 0) {
226             return StringPool.BLANK;
227         }
228 
229         return PortalUtil.getClassName(getClassNameId());
230     }
231 
232     public long getClassNameId() {
233         return _classNameId;
234     }
235 
236     public void setClassNameId(long classNameId) {
237         if (classNameId != _classNameId) {
238             _classNameId = classNameId;
239         }
240     }
241 
242     public long getClassPK() {
243         return _classPK;
244     }
245 
246     public void setClassPK(long classPK) {
247         if (classPK != _classPK) {
248             _classPK = classPK;
249         }
250     }
251 
252     public String getNumber() {
253         return GetterUtil.getString(_number);
254     }
255 
256     public void setNumber(String number) {
257         if (((number == null) && (_number != null)) ||
258                 ((number != null) && (_number == null)) ||
259                 ((number != null) && (_number != null) &&
260                 !number.equals(_number))) {
261             _number = number;
262         }
263     }
264 
265     public String getExtension() {
266         return GetterUtil.getString(_extension);
267     }
268 
269     public void setExtension(String extension) {
270         if (((extension == null) && (_extension != null)) ||
271                 ((extension != null) && (_extension == null)) ||
272                 ((extension != null) && (_extension != null) &&
273                 !extension.equals(_extension))) {
274             _extension = extension;
275         }
276     }
277 
278     public int getTypeId() {
279         return _typeId;
280     }
281 
282     public void setTypeId(int typeId) {
283         if (typeId != _typeId) {
284             _typeId = typeId;
285         }
286     }
287 
288     public boolean getPrimary() {
289         return _primary;
290     }
291 
292     public boolean isPrimary() {
293         return _primary;
294     }
295 
296     public void setPrimary(boolean primary) {
297         if (primary != _primary) {
298             _primary = primary;
299         }
300     }
301 
302     public Phone toEscapedModel() {
303         if (isEscapedModel()) {
304             return (Phone)this;
305         }
306         else {
307             Phone model = new PhoneImpl();
308 
309             model.setNew(isNew());
310             model.setEscapedModel(true);
311 
312             model.setPhoneId(getPhoneId());
313             model.setCompanyId(getCompanyId());
314             model.setUserId(getUserId());
315             model.setUserName(HtmlUtil.escape(getUserName()));
316             model.setCreateDate(getCreateDate());
317             model.setModifiedDate(getModifiedDate());
318             model.setClassNameId(getClassNameId());
319             model.setClassPK(getClassPK());
320             model.setNumber(HtmlUtil.escape(getNumber()));
321             model.setExtension(HtmlUtil.escape(getExtension()));
322             model.setTypeId(getTypeId());
323             model.setPrimary(getPrimary());
324 
325             model = (Phone)Proxy.newProxyInstance(Phone.class.getClassLoader(),
326                     new Class[] { Phone.class }, new ReadOnlyBeanHandler(model));
327 
328             return model;
329         }
330     }
331 
332     public Object clone() {
333         PhoneImpl clone = new PhoneImpl();
334 
335         clone.setPhoneId(getPhoneId());
336         clone.setCompanyId(getCompanyId());
337         clone.setUserId(getUserId());
338         clone.setUserName(getUserName());
339         clone.setCreateDate(getCreateDate());
340         clone.setModifiedDate(getModifiedDate());
341         clone.setClassNameId(getClassNameId());
342         clone.setClassPK(getClassPK());
343         clone.setNumber(getNumber());
344         clone.setExtension(getExtension());
345         clone.setTypeId(getTypeId());
346         clone.setPrimary(getPrimary());
347 
348         return clone;
349     }
350 
351     public int compareTo(Object obj) {
352         if (obj == null) {
353             return -1;
354         }
355 
356         PhoneImpl phone = (PhoneImpl)obj;
357 
358         int value = 0;
359 
360         value = DateUtil.compareTo(getCreateDate(), phone.getCreateDate());
361 
362         if (value != 0) {
363             return value;
364         }
365 
366         return 0;
367     }
368 
369     public boolean equals(Object obj) {
370         if (obj == null) {
371             return false;
372         }
373 
374         PhoneImpl phone = null;
375 
376         try {
377             phone = (PhoneImpl)obj;
378         }
379         catch (ClassCastException cce) {
380             return false;
381         }
382 
383         long pk = phone.getPrimaryKey();
384 
385         if (getPrimaryKey() == pk) {
386             return true;
387         }
388         else {
389             return false;
390         }
391     }
392 
393     public int hashCode() {
394         return (int)getPrimaryKey();
395     }
396 
397     private long _phoneId;
398     private long _companyId;
399     private long _userId;
400     private String _userName;
401     private Date _createDate;
402     private Date _modifiedDate;
403     private long _classNameId;
404     private long _classPK;
405     private String _number;
406     private String _extension;
407     private int _typeId;
408     private boolean _primary;
409 }