001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.json.JSON;
020 import com.liferay.portal.kernel.util.DateUtil;
021 import com.liferay.portal.kernel.util.GetterUtil;
022 import com.liferay.portal.kernel.util.ProxyUtil;
023 import com.liferay.portal.kernel.util.StringBundler;
024 import com.liferay.portal.kernel.util.StringPool;
025 import com.liferay.portal.kernel.util.Validator;
026 import com.liferay.portal.model.CacheModel;
027 import com.liferay.portal.model.EmailAddress;
028 import com.liferay.portal.model.EmailAddressModel;
029 import com.liferay.portal.model.EmailAddressSoap;
030 import com.liferay.portal.service.ServiceContext;
031 import com.liferay.portal.util.PortalUtil;
032
033 import com.liferay.portlet.expando.model.ExpandoBridge;
034 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
035
036 import java.io.Serializable;
037
038 import java.sql.Types;
039
040 import java.util.ArrayList;
041 import java.util.Date;
042 import java.util.HashMap;
043 import java.util.List;
044 import java.util.Map;
045
046
059 @JSON(strict = true)
060 public class EmailAddressModelImpl extends BaseModelImpl<EmailAddress>
061 implements EmailAddressModel {
062
067 public static final String TABLE_NAME = "EmailAddress";
068 public static final Object[][] TABLE_COLUMNS = {
069 { "emailAddressId", Types.BIGINT },
070 { "companyId", Types.BIGINT },
071 { "userId", Types.BIGINT },
072 { "userName", Types.VARCHAR },
073 { "createDate", Types.TIMESTAMP },
074 { "modifiedDate", Types.TIMESTAMP },
075 { "classNameId", Types.BIGINT },
076 { "classPK", Types.BIGINT },
077 { "address", Types.VARCHAR },
078 { "typeId", Types.INTEGER },
079 { "primary_", Types.BOOLEAN }
080 };
081 public static final String TABLE_SQL_CREATE = "create table EmailAddress (emailAddressId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,address VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
082 public static final String TABLE_SQL_DROP = "drop table EmailAddress";
083 public static final String ORDER_BY_JPQL = " ORDER BY emailAddress.createDate ASC";
084 public static final String ORDER_BY_SQL = " ORDER BY EmailAddress.createDate ASC";
085 public static final String DATA_SOURCE = "liferayDataSource";
086 public static final String SESSION_FACTORY = "liferaySessionFactory";
087 public static final String TX_MANAGER = "liferayTransactionManager";
088 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089 "value.object.entity.cache.enabled.com.liferay.portal.model.EmailAddress"),
090 true);
091 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
092 "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
093 true);
094 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095 "value.object.column.bitmask.enabled.com.liferay.portal.model.EmailAddress"),
096 true);
097 public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
098 public static long CLASSPK_COLUMN_BITMASK = 2L;
099 public static long COMPANYID_COLUMN_BITMASK = 4L;
100 public static long PRIMARY_COLUMN_BITMASK = 8L;
101 public static long USERID_COLUMN_BITMASK = 16L;
102
103
109 public static EmailAddress toModel(EmailAddressSoap soapModel) {
110 if (soapModel == null) {
111 return null;
112 }
113
114 EmailAddress model = new EmailAddressImpl();
115
116 model.setEmailAddressId(soapModel.getEmailAddressId());
117 model.setCompanyId(soapModel.getCompanyId());
118 model.setUserId(soapModel.getUserId());
119 model.setUserName(soapModel.getUserName());
120 model.setCreateDate(soapModel.getCreateDate());
121 model.setModifiedDate(soapModel.getModifiedDate());
122 model.setClassNameId(soapModel.getClassNameId());
123 model.setClassPK(soapModel.getClassPK());
124 model.setAddress(soapModel.getAddress());
125 model.setTypeId(soapModel.getTypeId());
126 model.setPrimary(soapModel.getPrimary());
127
128 return model;
129 }
130
131
137 public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
138 if (soapModels == null) {
139 return null;
140 }
141
142 List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
143
144 for (EmailAddressSoap soapModel : soapModels) {
145 models.add(toModel(soapModel));
146 }
147
148 return models;
149 }
150
151 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
152 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
153
154 public EmailAddressModelImpl() {
155 }
156
157 public long getPrimaryKey() {
158 return _emailAddressId;
159 }
160
161 public void setPrimaryKey(long primaryKey) {
162 setEmailAddressId(primaryKey);
163 }
164
165 public Serializable getPrimaryKeyObj() {
166 return new Long(_emailAddressId);
167 }
168
169 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
170 setPrimaryKey(((Long)primaryKeyObj).longValue());
171 }
172
173 public Class<?> getModelClass() {
174 return EmailAddress.class;
175 }
176
177 public String getModelClassName() {
178 return EmailAddress.class.getName();
179 }
180
181 @Override
182 public Map<String, Object> getModelAttributes() {
183 Map<String, Object> attributes = new HashMap<String, Object>();
184
185 attributes.put("emailAddressId", getEmailAddressId());
186 attributes.put("companyId", getCompanyId());
187 attributes.put("userId", getUserId());
188 attributes.put("userName", getUserName());
189 attributes.put("createDate", getCreateDate());
190 attributes.put("modifiedDate", getModifiedDate());
191 attributes.put("classNameId", getClassNameId());
192 attributes.put("classPK", getClassPK());
193 attributes.put("address", getAddress());
194 attributes.put("typeId", getTypeId());
195 attributes.put("primary", getPrimary());
196
197 return attributes;
198 }
199
200 @Override
201 public void setModelAttributes(Map<String, Object> attributes) {
202 Long emailAddressId = (Long)attributes.get("emailAddressId");
203
204 if (emailAddressId != null) {
205 setEmailAddressId(emailAddressId);
206 }
207
208 Long companyId = (Long)attributes.get("companyId");
209
210 if (companyId != null) {
211 setCompanyId(companyId);
212 }
213
214 Long userId = (Long)attributes.get("userId");
215
216 if (userId != null) {
217 setUserId(userId);
218 }
219
220 String userName = (String)attributes.get("userName");
221
222 if (userName != null) {
223 setUserName(userName);
224 }
225
226 Date createDate = (Date)attributes.get("createDate");
227
228 if (createDate != null) {
229 setCreateDate(createDate);
230 }
231
232 Date modifiedDate = (Date)attributes.get("modifiedDate");
233
234 if (modifiedDate != null) {
235 setModifiedDate(modifiedDate);
236 }
237
238 Long classNameId = (Long)attributes.get("classNameId");
239
240 if (classNameId != null) {
241 setClassNameId(classNameId);
242 }
243
244 Long classPK = (Long)attributes.get("classPK");
245
246 if (classPK != null) {
247 setClassPK(classPK);
248 }
249
250 String address = (String)attributes.get("address");
251
252 if (address != null) {
253 setAddress(address);
254 }
255
256 Integer typeId = (Integer)attributes.get("typeId");
257
258 if (typeId != null) {
259 setTypeId(typeId);
260 }
261
262 Boolean primary = (Boolean)attributes.get("primary");
263
264 if (primary != null) {
265 setPrimary(primary);
266 }
267 }
268
269 @JSON
270 public long getEmailAddressId() {
271 return _emailAddressId;
272 }
273
274 public void setEmailAddressId(long emailAddressId) {
275 _emailAddressId = emailAddressId;
276 }
277
278 @JSON
279 public long getCompanyId() {
280 return _companyId;
281 }
282
283 public void setCompanyId(long companyId) {
284 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
285
286 if (!_setOriginalCompanyId) {
287 _setOriginalCompanyId = true;
288
289 _originalCompanyId = _companyId;
290 }
291
292 _companyId = companyId;
293 }
294
295 public long getOriginalCompanyId() {
296 return _originalCompanyId;
297 }
298
299 @JSON
300 public long getUserId() {
301 return _userId;
302 }
303
304 public void setUserId(long userId) {
305 _columnBitmask |= USERID_COLUMN_BITMASK;
306
307 if (!_setOriginalUserId) {
308 _setOriginalUserId = true;
309
310 _originalUserId = _userId;
311 }
312
313 _userId = userId;
314 }
315
316 public String getUserUuid() throws SystemException {
317 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
318 }
319
320 public void setUserUuid(String userUuid) {
321 _userUuid = userUuid;
322 }
323
324 public long getOriginalUserId() {
325 return _originalUserId;
326 }
327
328 @JSON
329 public String getUserName() {
330 if (_userName == null) {
331 return StringPool.BLANK;
332 }
333 else {
334 return _userName;
335 }
336 }
337
338 public void setUserName(String userName) {
339 _userName = userName;
340 }
341
342 @JSON
343 public Date getCreateDate() {
344 return _createDate;
345 }
346
347 public void setCreateDate(Date createDate) {
348 _columnBitmask = -1L;
349
350 _createDate = createDate;
351 }
352
353 @JSON
354 public Date getModifiedDate() {
355 return _modifiedDate;
356 }
357
358 public void setModifiedDate(Date modifiedDate) {
359 _modifiedDate = modifiedDate;
360 }
361
362 public String getClassName() {
363 if (getClassNameId() <= 0) {
364 return StringPool.BLANK;
365 }
366
367 return PortalUtil.getClassName(getClassNameId());
368 }
369
370 public void setClassName(String className) {
371 long classNameId = 0;
372
373 if (Validator.isNotNull(className)) {
374 classNameId = PortalUtil.getClassNameId(className);
375 }
376
377 setClassNameId(classNameId);
378 }
379
380 @JSON
381 public long getClassNameId() {
382 return _classNameId;
383 }
384
385 public void setClassNameId(long classNameId) {
386 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
387
388 if (!_setOriginalClassNameId) {
389 _setOriginalClassNameId = true;
390
391 _originalClassNameId = _classNameId;
392 }
393
394 _classNameId = classNameId;
395 }
396
397 public long getOriginalClassNameId() {
398 return _originalClassNameId;
399 }
400
401 @JSON
402 public long getClassPK() {
403 return _classPK;
404 }
405
406 public void setClassPK(long classPK) {
407 _columnBitmask |= CLASSPK_COLUMN_BITMASK;
408
409 if (!_setOriginalClassPK) {
410 _setOriginalClassPK = true;
411
412 _originalClassPK = _classPK;
413 }
414
415 _classPK = classPK;
416 }
417
418 public long getOriginalClassPK() {
419 return _originalClassPK;
420 }
421
422 @JSON
423 public String getAddress() {
424 if (_address == null) {
425 return StringPool.BLANK;
426 }
427 else {
428 return _address;
429 }
430 }
431
432 public void setAddress(String address) {
433 _address = address;
434 }
435
436 @JSON
437 public int getTypeId() {
438 return _typeId;
439 }
440
441 public void setTypeId(int typeId) {
442 _typeId = typeId;
443 }
444
445 @JSON
446 public boolean getPrimary() {
447 return _primary;
448 }
449
450 public boolean isPrimary() {
451 return _primary;
452 }
453
454 public void setPrimary(boolean primary) {
455 _columnBitmask |= PRIMARY_COLUMN_BITMASK;
456
457 if (!_setOriginalPrimary) {
458 _setOriginalPrimary = true;
459
460 _originalPrimary = _primary;
461 }
462
463 _primary = primary;
464 }
465
466 public boolean getOriginalPrimary() {
467 return _originalPrimary;
468 }
469
470 public long getColumnBitmask() {
471 return _columnBitmask;
472 }
473
474 @Override
475 public ExpandoBridge getExpandoBridge() {
476 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
477 EmailAddress.class.getName(), getPrimaryKey());
478 }
479
480 @Override
481 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
482 ExpandoBridge expandoBridge = getExpandoBridge();
483
484 expandoBridge.setAttributes(serviceContext);
485 }
486
487 @Override
488 public EmailAddress toEscapedModel() {
489 if (_escapedModel == null) {
490 _escapedModel = (EmailAddress)ProxyUtil.newProxyInstance(_classLoader,
491 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
492 }
493
494 return _escapedModel;
495 }
496
497 public EmailAddress toUnescapedModel() {
498 return (EmailAddress)this;
499 }
500
501 @Override
502 public Object clone() {
503 EmailAddressImpl emailAddressImpl = new EmailAddressImpl();
504
505 emailAddressImpl.setEmailAddressId(getEmailAddressId());
506 emailAddressImpl.setCompanyId(getCompanyId());
507 emailAddressImpl.setUserId(getUserId());
508 emailAddressImpl.setUserName(getUserName());
509 emailAddressImpl.setCreateDate(getCreateDate());
510 emailAddressImpl.setModifiedDate(getModifiedDate());
511 emailAddressImpl.setClassNameId(getClassNameId());
512 emailAddressImpl.setClassPK(getClassPK());
513 emailAddressImpl.setAddress(getAddress());
514 emailAddressImpl.setTypeId(getTypeId());
515 emailAddressImpl.setPrimary(getPrimary());
516
517 emailAddressImpl.resetOriginalValues();
518
519 return emailAddressImpl;
520 }
521
522 public int compareTo(EmailAddress emailAddress) {
523 int value = 0;
524
525 value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
526
527 if (value != 0) {
528 return value;
529 }
530
531 return 0;
532 }
533
534 @Override
535 public boolean equals(Object obj) {
536 if (this == obj) {
537 return true;
538 }
539
540 if (!(obj instanceof EmailAddress)) {
541 return false;
542 }
543
544 EmailAddress emailAddress = (EmailAddress)obj;
545
546 long primaryKey = emailAddress.getPrimaryKey();
547
548 if (getPrimaryKey() == primaryKey) {
549 return true;
550 }
551 else {
552 return false;
553 }
554 }
555
556 @Override
557 public int hashCode() {
558 return (int)getPrimaryKey();
559 }
560
561 @Override
562 public void resetOriginalValues() {
563 EmailAddressModelImpl emailAddressModelImpl = this;
564
565 emailAddressModelImpl._originalCompanyId = emailAddressModelImpl._companyId;
566
567 emailAddressModelImpl._setOriginalCompanyId = false;
568
569 emailAddressModelImpl._originalUserId = emailAddressModelImpl._userId;
570
571 emailAddressModelImpl._setOriginalUserId = false;
572
573 emailAddressModelImpl._originalClassNameId = emailAddressModelImpl._classNameId;
574
575 emailAddressModelImpl._setOriginalClassNameId = false;
576
577 emailAddressModelImpl._originalClassPK = emailAddressModelImpl._classPK;
578
579 emailAddressModelImpl._setOriginalClassPK = false;
580
581 emailAddressModelImpl._originalPrimary = emailAddressModelImpl._primary;
582
583 emailAddressModelImpl._setOriginalPrimary = false;
584
585 emailAddressModelImpl._columnBitmask = 0;
586 }
587
588 @Override
589 public CacheModel<EmailAddress> toCacheModel() {
590 EmailAddressCacheModel emailAddressCacheModel = new EmailAddressCacheModel();
591
592 emailAddressCacheModel.emailAddressId = getEmailAddressId();
593
594 emailAddressCacheModel.companyId = getCompanyId();
595
596 emailAddressCacheModel.userId = getUserId();
597
598 emailAddressCacheModel.userName = getUserName();
599
600 String userName = emailAddressCacheModel.userName;
601
602 if ((userName != null) && (userName.length() == 0)) {
603 emailAddressCacheModel.userName = null;
604 }
605
606 Date createDate = getCreateDate();
607
608 if (createDate != null) {
609 emailAddressCacheModel.createDate = createDate.getTime();
610 }
611 else {
612 emailAddressCacheModel.createDate = Long.MIN_VALUE;
613 }
614
615 Date modifiedDate = getModifiedDate();
616
617 if (modifiedDate != null) {
618 emailAddressCacheModel.modifiedDate = modifiedDate.getTime();
619 }
620 else {
621 emailAddressCacheModel.modifiedDate = Long.MIN_VALUE;
622 }
623
624 emailAddressCacheModel.classNameId = getClassNameId();
625
626 emailAddressCacheModel.classPK = getClassPK();
627
628 emailAddressCacheModel.address = getAddress();
629
630 String address = emailAddressCacheModel.address;
631
632 if ((address != null) && (address.length() == 0)) {
633 emailAddressCacheModel.address = null;
634 }
635
636 emailAddressCacheModel.typeId = getTypeId();
637
638 emailAddressCacheModel.primary = getPrimary();
639
640 return emailAddressCacheModel;
641 }
642
643 @Override
644 public String toString() {
645 StringBundler sb = new StringBundler(23);
646
647 sb.append("{emailAddressId=");
648 sb.append(getEmailAddressId());
649 sb.append(", companyId=");
650 sb.append(getCompanyId());
651 sb.append(", userId=");
652 sb.append(getUserId());
653 sb.append(", userName=");
654 sb.append(getUserName());
655 sb.append(", createDate=");
656 sb.append(getCreateDate());
657 sb.append(", modifiedDate=");
658 sb.append(getModifiedDate());
659 sb.append(", classNameId=");
660 sb.append(getClassNameId());
661 sb.append(", classPK=");
662 sb.append(getClassPK());
663 sb.append(", address=");
664 sb.append(getAddress());
665 sb.append(", typeId=");
666 sb.append(getTypeId());
667 sb.append(", primary=");
668 sb.append(getPrimary());
669 sb.append("}");
670
671 return sb.toString();
672 }
673
674 public String toXmlString() {
675 StringBundler sb = new StringBundler(37);
676
677 sb.append("<model><model-name>");
678 sb.append("com.liferay.portal.model.EmailAddress");
679 sb.append("</model-name>");
680
681 sb.append(
682 "<column><column-name>emailAddressId</column-name><column-value><![CDATA[");
683 sb.append(getEmailAddressId());
684 sb.append("]]></column-value></column>");
685 sb.append(
686 "<column><column-name>companyId</column-name><column-value><![CDATA[");
687 sb.append(getCompanyId());
688 sb.append("]]></column-value></column>");
689 sb.append(
690 "<column><column-name>userId</column-name><column-value><![CDATA[");
691 sb.append(getUserId());
692 sb.append("]]></column-value></column>");
693 sb.append(
694 "<column><column-name>userName</column-name><column-value><![CDATA[");
695 sb.append(getUserName());
696 sb.append("]]></column-value></column>");
697 sb.append(
698 "<column><column-name>createDate</column-name><column-value><![CDATA[");
699 sb.append(getCreateDate());
700 sb.append("]]></column-value></column>");
701 sb.append(
702 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
703 sb.append(getModifiedDate());
704 sb.append("]]></column-value></column>");
705 sb.append(
706 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
707 sb.append(getClassNameId());
708 sb.append("]]></column-value></column>");
709 sb.append(
710 "<column><column-name>classPK</column-name><column-value><![CDATA[");
711 sb.append(getClassPK());
712 sb.append("]]></column-value></column>");
713 sb.append(
714 "<column><column-name>address</column-name><column-value><![CDATA[");
715 sb.append(getAddress());
716 sb.append("]]></column-value></column>");
717 sb.append(
718 "<column><column-name>typeId</column-name><column-value><![CDATA[");
719 sb.append(getTypeId());
720 sb.append("]]></column-value></column>");
721 sb.append(
722 "<column><column-name>primary</column-name><column-value><![CDATA[");
723 sb.append(getPrimary());
724 sb.append("]]></column-value></column>");
725
726 sb.append("</model>");
727
728 return sb.toString();
729 }
730
731 private static ClassLoader _classLoader = EmailAddress.class.getClassLoader();
732 private static Class<?>[] _escapedModelInterfaces = new Class[] {
733 EmailAddress.class
734 };
735 private long _emailAddressId;
736 private long _companyId;
737 private long _originalCompanyId;
738 private boolean _setOriginalCompanyId;
739 private long _userId;
740 private String _userUuid;
741 private long _originalUserId;
742 private boolean _setOriginalUserId;
743 private String _userName;
744 private Date _createDate;
745 private Date _modifiedDate;
746 private long _classNameId;
747 private long _originalClassNameId;
748 private boolean _setOriginalClassNameId;
749 private long _classPK;
750 private long _originalClassPK;
751 private boolean _setOriginalClassPK;
752 private String _address;
753 private int _typeId;
754 private boolean _primary;
755 private boolean _originalPrimary;
756 private boolean _setOriginalPrimary;
757 private long _columnBitmask;
758 private EmailAddress _escapedModel;
759 }