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.Address;
28  import com.liferay.portal.model.AddressSoap;
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="AddressModelImpl.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>Address</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.model.Address
57   * @see com.liferay.portal.model.AddressModel
58   * @see com.liferay.portal.model.impl.AddressImpl
59   *
60   */
61  public class AddressModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "Address";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "addressId", 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              { "street1", new Integer(Types.VARCHAR) },
89              
90  
91              { "street2", new Integer(Types.VARCHAR) },
92              
93  
94              { "street3", new Integer(Types.VARCHAR) },
95              
96  
97              { "city", new Integer(Types.VARCHAR) },
98              
99  
100             { "zip", new Integer(Types.VARCHAR) },
101             
102 
103             { "regionId", new Integer(Types.BIGINT) },
104             
105 
106             { "countryId", new Integer(Types.BIGINT) },
107             
108 
109             { "typeId", new Integer(Types.INTEGER) },
110             
111 
112             { "mailing", new Integer(Types.BOOLEAN) },
113             
114 
115             { "primary_", new Integer(Types.BOOLEAN) }
116         };
117     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)";
118     public static final String TABLE_SQL_DROP = "drop table Address";
119     public static final String DATA_SOURCE = "liferayDataSource";
120     public static final String SESSION_FACTORY = "liferaySessionFactory";
121     public static final String TX_MANAGER = "liferayTransactionManager";
122     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.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(com.liferay.portal.util.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         if (getClassNameId() <= 0) {
250             return StringPool.BLANK;
251         }
252 
253         return PortalUtil.getClassName(getClassNameId());
254     }
255 
256     public long getClassNameId() {
257         return _classNameId;
258     }
259 
260     public void setClassNameId(long classNameId) {
261         if (classNameId != _classNameId) {
262             _classNameId = classNameId;
263         }
264     }
265 
266     public long getClassPK() {
267         return _classPK;
268     }
269 
270     public void setClassPK(long classPK) {
271         if (classPK != _classPK) {
272             _classPK = classPK;
273         }
274     }
275 
276     public String getStreet1() {
277         return GetterUtil.getString(_street1);
278     }
279 
280     public void setStreet1(String street1) {
281         if (((street1 == null) && (_street1 != null)) ||
282                 ((street1 != null) && (_street1 == null)) ||
283                 ((street1 != null) && (_street1 != null) &&
284                 !street1.equals(_street1))) {
285             _street1 = street1;
286         }
287     }
288 
289     public String getStreet2() {
290         return GetterUtil.getString(_street2);
291     }
292 
293     public void setStreet2(String street2) {
294         if (((street2 == null) && (_street2 != null)) ||
295                 ((street2 != null) && (_street2 == null)) ||
296                 ((street2 != null) && (_street2 != null) &&
297                 !street2.equals(_street2))) {
298             _street2 = street2;
299         }
300     }
301 
302     public String getStreet3() {
303         return GetterUtil.getString(_street3);
304     }
305 
306     public void setStreet3(String street3) {
307         if (((street3 == null) && (_street3 != null)) ||
308                 ((street3 != null) && (_street3 == null)) ||
309                 ((street3 != null) && (_street3 != null) &&
310                 !street3.equals(_street3))) {
311             _street3 = street3;
312         }
313     }
314 
315     public String getCity() {
316         return GetterUtil.getString(_city);
317     }
318 
319     public void setCity(String city) {
320         if (((city == null) && (_city != null)) ||
321                 ((city != null) && (_city == null)) ||
322                 ((city != null) && (_city != null) && !city.equals(_city))) {
323             _city = city;
324         }
325     }
326 
327     public String getZip() {
328         return GetterUtil.getString(_zip);
329     }
330 
331     public void setZip(String zip) {
332         if (((zip == null) && (_zip != null)) ||
333                 ((zip != null) && (_zip == null)) ||
334                 ((zip != null) && (_zip != null) && !zip.equals(_zip))) {
335             _zip = zip;
336         }
337     }
338 
339     public long getRegionId() {
340         return _regionId;
341     }
342 
343     public void setRegionId(long regionId) {
344         if (regionId != _regionId) {
345             _regionId = regionId;
346         }
347     }
348 
349     public long getCountryId() {
350         return _countryId;
351     }
352 
353     public void setCountryId(long countryId) {
354         if (countryId != _countryId) {
355             _countryId = countryId;
356         }
357     }
358 
359     public int getTypeId() {
360         return _typeId;
361     }
362 
363     public void setTypeId(int typeId) {
364         if (typeId != _typeId) {
365             _typeId = typeId;
366         }
367     }
368 
369     public boolean getMailing() {
370         return _mailing;
371     }
372 
373     public boolean isMailing() {
374         return _mailing;
375     }
376 
377     public void setMailing(boolean mailing) {
378         if (mailing != _mailing) {
379             _mailing = mailing;
380         }
381     }
382 
383     public boolean getPrimary() {
384         return _primary;
385     }
386 
387     public boolean isPrimary() {
388         return _primary;
389     }
390 
391     public void setPrimary(boolean primary) {
392         if (primary != _primary) {
393             _primary = primary;
394         }
395     }
396 
397     public Address toEscapedModel() {
398         if (isEscapedModel()) {
399             return (Address)this;
400         }
401         else {
402             Address model = new AddressImpl();
403 
404             model.setNew(isNew());
405             model.setEscapedModel(true);
406 
407             model.setAddressId(getAddressId());
408             model.setCompanyId(getCompanyId());
409             model.setUserId(getUserId());
410             model.setUserName(HtmlUtil.escape(getUserName()));
411             model.setCreateDate(getCreateDate());
412             model.setModifiedDate(getModifiedDate());
413             model.setClassNameId(getClassNameId());
414             model.setClassPK(getClassPK());
415             model.setStreet1(HtmlUtil.escape(getStreet1()));
416             model.setStreet2(HtmlUtil.escape(getStreet2()));
417             model.setStreet3(HtmlUtil.escape(getStreet3()));
418             model.setCity(HtmlUtil.escape(getCity()));
419             model.setZip(HtmlUtil.escape(getZip()));
420             model.setRegionId(getRegionId());
421             model.setCountryId(getCountryId());
422             model.setTypeId(getTypeId());
423             model.setMailing(getMailing());
424             model.setPrimary(getPrimary());
425 
426             model = (Address)Proxy.newProxyInstance(Address.class.getClassLoader(),
427                     new Class[] { Address.class },
428                     new ReadOnlyBeanHandler(model));
429 
430             return model;
431         }
432     }
433 
434     public Object clone() {
435         AddressImpl clone = new AddressImpl();
436 
437         clone.setAddressId(getAddressId());
438         clone.setCompanyId(getCompanyId());
439         clone.setUserId(getUserId());
440         clone.setUserName(getUserName());
441         clone.setCreateDate(getCreateDate());
442         clone.setModifiedDate(getModifiedDate());
443         clone.setClassNameId(getClassNameId());
444         clone.setClassPK(getClassPK());
445         clone.setStreet1(getStreet1());
446         clone.setStreet2(getStreet2());
447         clone.setStreet3(getStreet3());
448         clone.setCity(getCity());
449         clone.setZip(getZip());
450         clone.setRegionId(getRegionId());
451         clone.setCountryId(getCountryId());
452         clone.setTypeId(getTypeId());
453         clone.setMailing(getMailing());
454         clone.setPrimary(getPrimary());
455 
456         return clone;
457     }
458 
459     public int compareTo(Object obj) {
460         if (obj == null) {
461             return -1;
462         }
463 
464         AddressImpl address = (AddressImpl)obj;
465 
466         int value = 0;
467 
468         value = DateUtil.compareTo(getCreateDate(), address.getCreateDate());
469 
470         if (value != 0) {
471             return value;
472         }
473 
474         return 0;
475     }
476 
477     public boolean equals(Object obj) {
478         if (obj == null) {
479             return false;
480         }
481 
482         AddressImpl address = null;
483 
484         try {
485             address = (AddressImpl)obj;
486         }
487         catch (ClassCastException cce) {
488             return false;
489         }
490 
491         long pk = address.getPrimaryKey();
492 
493         if (getPrimaryKey() == pk) {
494             return true;
495         }
496         else {
497             return false;
498         }
499     }
500 
501     public int hashCode() {
502         return (int)getPrimaryKey();
503     }
504 
505     private long _addressId;
506     private long _companyId;
507     private long _userId;
508     private String _userName;
509     private Date _createDate;
510     private Date _modifiedDate;
511     private long _classNameId;
512     private long _classPK;
513     private String _street1;
514     private String _street2;
515     private String _street3;
516     private String _city;
517     private String _zip;
518     private long _regionId;
519     private long _countryId;
520     private int _typeId;
521     private boolean _mailing;
522     private boolean _primary;
523 }