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.Address;
30  import com.liferay.portal.model.AddressSoap;
31  import com.liferay.portal.util.PortalUtil;
32  import com.liferay.portal.util.PropsUtil;
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="AddressModelImpl.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>Address</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.service.model.Address
60   * @see com.liferay.portal.service.model.AddressModel
61   * @see com.liferay.portal.service.model.impl.AddressImpl
62   *
63   */
64  public class AddressModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "Address";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "addressId", 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              { "street1", new Integer(Types.VARCHAR) },
92              
93  
94              { "street2", new Integer(Types.VARCHAR) },
95              
96  
97              { "street3", new Integer(Types.VARCHAR) },
98              
99  
100             { "city", new Integer(Types.VARCHAR) },
101             
102 
103             { "zip", new Integer(Types.VARCHAR) },
104             
105 
106             { "regionId", new Integer(Types.BIGINT) },
107             
108 
109             { "countryId", new Integer(Types.BIGINT) },
110             
111 
112             { "typeId", new Integer(Types.INTEGER) },
113             
114 
115             { "mailing", new Integer(Types.BOOLEAN) },
116             
117 
118             { "primary_", new Integer(Types.BOOLEAN) }
119         };
120     public static final String TABLE_SQL_CREATE = "create table Address (addressId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,street1 VARCHAR(75) null,street2 VARCHAR(75) null,street3 VARCHAR(75) null,city VARCHAR(75) null,zip VARCHAR(75) null,regionId LONG,countryId LONG,typeId INTEGER,mailing BOOLEAN,primary_ BOOLEAN)";
121     public static final String TABLE_SQL_DROP = "drop table Address";
122     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
123                 "value.object.finder.cache.enabled.com.liferay.portal.model.Address"),
124             true);
125 
126     public static Address toModel(AddressSoap soapModel) {
127         Address model = new AddressImpl();
128 
129         model.setAddressId(soapModel.getAddressId());
130         model.setCompanyId(soapModel.getCompanyId());
131         model.setUserId(soapModel.getUserId());
132         model.setUserName(soapModel.getUserName());
133         model.setCreateDate(soapModel.getCreateDate());
134         model.setModifiedDate(soapModel.getModifiedDate());
135         model.setClassNameId(soapModel.getClassNameId());
136         model.setClassPK(soapModel.getClassPK());
137         model.setStreet1(soapModel.getStreet1());
138         model.setStreet2(soapModel.getStreet2());
139         model.setStreet3(soapModel.getStreet3());
140         model.setCity(soapModel.getCity());
141         model.setZip(soapModel.getZip());
142         model.setRegionId(soapModel.getRegionId());
143         model.setCountryId(soapModel.getCountryId());
144         model.setTypeId(soapModel.getTypeId());
145         model.setMailing(soapModel.getMailing());
146         model.setPrimary(soapModel.getPrimary());
147 
148         return model;
149     }
150 
151     public static List<Address> toModels(AddressSoap[] soapModels) {
152         List<Address> models = new ArrayList<Address>(soapModels.length);
153 
154         for (AddressSoap soapModel : soapModels) {
155             models.add(toModel(soapModel));
156         }
157 
158         return models;
159     }
160 
161     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
162                 "lock.expiration.time.com.liferay.portal.model.Address"));
163 
164     public AddressModelImpl() {
165     }
166 
167     public long getPrimaryKey() {
168         return _addressId;
169     }
170 
171     public void setPrimaryKey(long pk) {
172         setAddressId(pk);
173     }
174 
175     public Serializable getPrimaryKeyObj() {
176         return new Long(_addressId);
177     }
178 
179     public long getAddressId() {
180         return _addressId;
181     }
182 
183     public void setAddressId(long addressId) {
184         if (addressId != _addressId) {
185             _addressId = addressId;
186         }
187     }
188 
189     public long getCompanyId() {
190         return _companyId;
191     }
192 
193     public void setCompanyId(long companyId) {
194         if (companyId != _companyId) {
195             _companyId = companyId;
196         }
197     }
198 
199     public long getUserId() {
200         return _userId;
201     }
202 
203     public void setUserId(long userId) {
204         if (userId != _userId) {
205             _userId = userId;
206         }
207     }
208 
209     public String getUserName() {
210         return GetterUtil.getString(_userName);
211     }
212 
213     public void setUserName(String userName) {
214         if (((userName == null) && (_userName != null)) ||
215                 ((userName != null) && (_userName == null)) ||
216                 ((userName != null) && (_userName != null) &&
217                 !userName.equals(_userName))) {
218             _userName = userName;
219         }
220     }
221 
222     public Date getCreateDate() {
223         return _createDate;
224     }
225 
226     public void setCreateDate(Date createDate) {
227         if (((createDate == null) && (_createDate != null)) ||
228                 ((createDate != null) && (_createDate == null)) ||
229                 ((createDate != null) && (_createDate != null) &&
230                 !createDate.equals(_createDate))) {
231             _createDate = createDate;
232         }
233     }
234 
235     public Date getModifiedDate() {
236         return _modifiedDate;
237     }
238 
239     public void setModifiedDate(Date modifiedDate) {
240         if (((modifiedDate == null) && (_modifiedDate != null)) ||
241                 ((modifiedDate != null) && (_modifiedDate == null)) ||
242                 ((modifiedDate != null) && (_modifiedDate != null) &&
243                 !modifiedDate.equals(_modifiedDate))) {
244             _modifiedDate = modifiedDate;
245         }
246     }
247 
248     public String getClassName() {
249         return PortalUtil.getClassName(getClassNameId());
250     }
251 
252     public long getClassNameId() {
253         return _classNameId;
254     }
255 
256     public void setClassNameId(long classNameId) {
257         if (classNameId != _classNameId) {
258             _classNameId = classNameId;
259         }
260     }
261 
262     public long getClassPK() {
263         return _classPK;
264     }
265 
266     public void setClassPK(long classPK) {
267         if (classPK != _classPK) {
268             _classPK = classPK;
269         }
270     }
271 
272     public String getStreet1() {
273         return GetterUtil.getString(_street1);
274     }
275 
276     public void setStreet1(String street1) {
277         if (((street1 == null) && (_street1 != null)) ||
278                 ((street1 != null) && (_street1 == null)) ||
279                 ((street1 != null) && (_street1 != null) &&
280                 !street1.equals(_street1))) {
281             _street1 = street1;
282         }
283     }
284 
285     public String getStreet2() {
286         return GetterUtil.getString(_street2);
287     }
288 
289     public void setStreet2(String street2) {
290         if (((street2 == null) && (_street2 != null)) ||
291                 ((street2 != null) && (_street2 == null)) ||
292                 ((street2 != null) && (_street2 != null) &&
293                 !street2.equals(_street2))) {
294             _street2 = street2;
295         }
296     }
297 
298     public String getStreet3() {
299         return GetterUtil.getString(_street3);
300     }
301 
302     public void setStreet3(String street3) {
303         if (((street3 == null) && (_street3 != null)) ||
304                 ((street3 != null) && (_street3 == null)) ||
305                 ((street3 != null) && (_street3 != null) &&
306                 !street3.equals(_street3))) {
307             _street3 = street3;
308         }
309     }
310 
311     public String getCity() {
312         return GetterUtil.getString(_city);
313     }
314 
315     public void setCity(String city) {
316         if (((city == null) && (_city != null)) ||
317                 ((city != null) && (_city == null)) ||
318                 ((city != null) && (_city != null) && !city.equals(_city))) {
319             _city = city;
320         }
321     }
322 
323     public String getZip() {
324         return GetterUtil.getString(_zip);
325     }
326 
327     public void setZip(String zip) {
328         if (((zip == null) && (_zip != null)) ||
329                 ((zip != null) && (_zip == null)) ||
330                 ((zip != null) && (_zip != null) && !zip.equals(_zip))) {
331             _zip = zip;
332         }
333     }
334 
335     public long getRegionId() {
336         return _regionId;
337     }
338 
339     public void setRegionId(long regionId) {
340         if (regionId != _regionId) {
341             _regionId = regionId;
342         }
343     }
344 
345     public long getCountryId() {
346         return _countryId;
347     }
348 
349     public void setCountryId(long countryId) {
350         if (countryId != _countryId) {
351             _countryId = countryId;
352         }
353     }
354 
355     public int getTypeId() {
356         return _typeId;
357     }
358 
359     public void setTypeId(int typeId) {
360         if (typeId != _typeId) {
361             _typeId = typeId;
362         }
363     }
364 
365     public boolean getMailing() {
366         return _mailing;
367     }
368 
369     public boolean isMailing() {
370         return _mailing;
371     }
372 
373     public void setMailing(boolean mailing) {
374         if (mailing != _mailing) {
375             _mailing = mailing;
376         }
377     }
378 
379     public boolean getPrimary() {
380         return _primary;
381     }
382 
383     public boolean isPrimary() {
384         return _primary;
385     }
386 
387     public void setPrimary(boolean primary) {
388         if (primary != _primary) {
389             _primary = primary;
390         }
391     }
392 
393     public Address toEscapedModel() {
394         if (isEscapedModel()) {
395             return (Address)this;
396         }
397         else {
398             Address model = new AddressImpl();
399 
400             model.setEscapedModel(true);
401 
402             model.setAddressId(getAddressId());
403             model.setCompanyId(getCompanyId());
404             model.setUserId(getUserId());
405             model.setUserName(HtmlUtil.escape(getUserName()));
406             model.setCreateDate(getCreateDate());
407             model.setModifiedDate(getModifiedDate());
408             model.setClassNameId(getClassNameId());
409             model.setClassPK(getClassPK());
410             model.setStreet1(HtmlUtil.escape(getStreet1()));
411             model.setStreet2(HtmlUtil.escape(getStreet2()));
412             model.setStreet3(HtmlUtil.escape(getStreet3()));
413             model.setCity(HtmlUtil.escape(getCity()));
414             model.setZip(HtmlUtil.escape(getZip()));
415             model.setRegionId(getRegionId());
416             model.setCountryId(getCountryId());
417             model.setTypeId(getTypeId());
418             model.setMailing(getMailing());
419             model.setPrimary(getPrimary());
420 
421             model = (Address)Proxy.newProxyInstance(Address.class.getClassLoader(),
422                     new Class[] { Address.class },
423                     new ReadOnlyBeanHandler(model));
424 
425             return model;
426         }
427     }
428 
429     public Object clone() {
430         AddressImpl clone = new AddressImpl();
431 
432         clone.setAddressId(getAddressId());
433         clone.setCompanyId(getCompanyId());
434         clone.setUserId(getUserId());
435         clone.setUserName(getUserName());
436         clone.setCreateDate(getCreateDate());
437         clone.setModifiedDate(getModifiedDate());
438         clone.setClassNameId(getClassNameId());
439         clone.setClassPK(getClassPK());
440         clone.setStreet1(getStreet1());
441         clone.setStreet2(getStreet2());
442         clone.setStreet3(getStreet3());
443         clone.setCity(getCity());
444         clone.setZip(getZip());
445         clone.setRegionId(getRegionId());
446         clone.setCountryId(getCountryId());
447         clone.setTypeId(getTypeId());
448         clone.setMailing(getMailing());
449         clone.setPrimary(getPrimary());
450 
451         return clone;
452     }
453 
454     public int compareTo(Object obj) {
455         if (obj == null) {
456             return -1;
457         }
458 
459         AddressImpl address = (AddressImpl)obj;
460 
461         int value = 0;
462 
463         value = DateUtil.compareTo(getCreateDate(), address.getCreateDate());
464 
465         if (value != 0) {
466             return value;
467         }
468 
469         return 0;
470     }
471 
472     public boolean equals(Object obj) {
473         if (obj == null) {
474             return false;
475         }
476 
477         AddressImpl address = null;
478 
479         try {
480             address = (AddressImpl)obj;
481         }
482         catch (ClassCastException cce) {
483             return false;
484         }
485 
486         long pk = address.getPrimaryKey();
487 
488         if (getPrimaryKey() == pk) {
489             return true;
490         }
491         else {
492             return false;
493         }
494     }
495 
496     public int hashCode() {
497         return (int)getPrimaryKey();
498     }
499 
500     private long _addressId;
501     private long _companyId;
502     private long _userId;
503     private String _userName;
504     private Date _createDate;
505     private Date _modifiedDate;
506     private long _classNameId;
507     private long _classPK;
508     private String _street1;
509     private String _street2;
510     private String _street3;
511     private String _city;
512     private String _zip;
513     private long _regionId;
514     private long _countryId;
515     private int _typeId;
516     private boolean _mailing;
517     private boolean _primary;
518 }