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