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 public static long CREATEDATE_COLUMN_BITMASK = 32L;
103
104
110 public static EmailAddress toModel(EmailAddressSoap soapModel) {
111 if (soapModel == null) {
112 return null;
113 }
114
115 EmailAddress model = new EmailAddressImpl();
116
117 model.setEmailAddressId(soapModel.getEmailAddressId());
118 model.setCompanyId(soapModel.getCompanyId());
119 model.setUserId(soapModel.getUserId());
120 model.setUserName(soapModel.getUserName());
121 model.setCreateDate(soapModel.getCreateDate());
122 model.setModifiedDate(soapModel.getModifiedDate());
123 model.setClassNameId(soapModel.getClassNameId());
124 model.setClassPK(soapModel.getClassPK());
125 model.setAddress(soapModel.getAddress());
126 model.setTypeId(soapModel.getTypeId());
127 model.setPrimary(soapModel.getPrimary());
128
129 return model;
130 }
131
132
138 public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
139 if (soapModels == null) {
140 return null;
141 }
142
143 List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
144
145 for (EmailAddressSoap soapModel : soapModels) {
146 models.add(toModel(soapModel));
147 }
148
149 return models;
150 }
151
152 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
153 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
154
155 public EmailAddressModelImpl() {
156 }
157
158 public long getPrimaryKey() {
159 return _emailAddressId;
160 }
161
162 public void setPrimaryKey(long primaryKey) {
163 setEmailAddressId(primaryKey);
164 }
165
166 public Serializable getPrimaryKeyObj() {
167 return new Long(_emailAddressId);
168 }
169
170 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
171 setPrimaryKey(((Long)primaryKeyObj).longValue());
172 }
173
174 public Class<?> getModelClass() {
175 return EmailAddress.class;
176 }
177
178 public String getModelClassName() {
179 return EmailAddress.class.getName();
180 }
181
182 @Override
183 public Map<String, Object> getModelAttributes() {
184 Map<String, Object> attributes = new HashMap<String, Object>();
185
186 attributes.put("emailAddressId", getEmailAddressId());
187 attributes.put("companyId", getCompanyId());
188 attributes.put("userId", getUserId());
189 attributes.put("userName", getUserName());
190 attributes.put("createDate", getCreateDate());
191 attributes.put("modifiedDate", getModifiedDate());
192 attributes.put("classNameId", getClassNameId());
193 attributes.put("classPK", getClassPK());
194 attributes.put("address", getAddress());
195 attributes.put("typeId", getTypeId());
196 attributes.put("primary", getPrimary());
197
198 return attributes;
199 }
200
201 @Override
202 public void setModelAttributes(Map<String, Object> attributes) {
203 Long emailAddressId = (Long)attributes.get("emailAddressId");
204
205 if (emailAddressId != null) {
206 setEmailAddressId(emailAddressId);
207 }
208
209 Long companyId = (Long)attributes.get("companyId");
210
211 if (companyId != null) {
212 setCompanyId(companyId);
213 }
214
215 Long userId = (Long)attributes.get("userId");
216
217 if (userId != null) {
218 setUserId(userId);
219 }
220
221 String userName = (String)attributes.get("userName");
222
223 if (userName != null) {
224 setUserName(userName);
225 }
226
227 Date createDate = (Date)attributes.get("createDate");
228
229 if (createDate != null) {
230 setCreateDate(createDate);
231 }
232
233 Date modifiedDate = (Date)attributes.get("modifiedDate");
234
235 if (modifiedDate != null) {
236 setModifiedDate(modifiedDate);
237 }
238
239 Long classNameId = (Long)attributes.get("classNameId");
240
241 if (classNameId != null) {
242 setClassNameId(classNameId);
243 }
244
245 Long classPK = (Long)attributes.get("classPK");
246
247 if (classPK != null) {
248 setClassPK(classPK);
249 }
250
251 String address = (String)attributes.get("address");
252
253 if (address != null) {
254 setAddress(address);
255 }
256
257 Integer typeId = (Integer)attributes.get("typeId");
258
259 if (typeId != null) {
260 setTypeId(typeId);
261 }
262
263 Boolean primary = (Boolean)attributes.get("primary");
264
265 if (primary != null) {
266 setPrimary(primary);
267 }
268 }
269
270 @JSON
271 public long getEmailAddressId() {
272 return _emailAddressId;
273 }
274
275 public void setEmailAddressId(long emailAddressId) {
276 _emailAddressId = emailAddressId;
277 }
278
279 @JSON
280 public long getCompanyId() {
281 return _companyId;
282 }
283
284 public void setCompanyId(long companyId) {
285 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
286
287 if (!_setOriginalCompanyId) {
288 _setOriginalCompanyId = true;
289
290 _originalCompanyId = _companyId;
291 }
292
293 _companyId = companyId;
294 }
295
296 public long getOriginalCompanyId() {
297 return _originalCompanyId;
298 }
299
300 @JSON
301 public long getUserId() {
302 return _userId;
303 }
304
305 public void setUserId(long userId) {
306 _columnBitmask |= USERID_COLUMN_BITMASK;
307
308 if (!_setOriginalUserId) {
309 _setOriginalUserId = true;
310
311 _originalUserId = _userId;
312 }
313
314 _userId = userId;
315 }
316
317 public String getUserUuid() throws SystemException {
318 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
319 }
320
321 public void setUserUuid(String userUuid) {
322 _userUuid = userUuid;
323 }
324
325 public long getOriginalUserId() {
326 return _originalUserId;
327 }
328
329 @JSON
330 public String getUserName() {
331 if (_userName == null) {
332 return StringPool.BLANK;
333 }
334 else {
335 return _userName;
336 }
337 }
338
339 public void setUserName(String userName) {
340 _userName = userName;
341 }
342
343 @JSON
344 public Date getCreateDate() {
345 return _createDate;
346 }
347
348 public void setCreateDate(Date createDate) {
349 _columnBitmask = -1L;
350
351 _createDate = createDate;
352 }
353
354 @JSON
355 public Date getModifiedDate() {
356 return _modifiedDate;
357 }
358
359 public void setModifiedDate(Date modifiedDate) {
360 _modifiedDate = modifiedDate;
361 }
362
363 public String getClassName() {
364 if (getClassNameId() <= 0) {
365 return StringPool.BLANK;
366 }
367
368 return PortalUtil.getClassName(getClassNameId());
369 }
370
371 public void setClassName(String className) {
372 long classNameId = 0;
373
374 if (Validator.isNotNull(className)) {
375 classNameId = PortalUtil.getClassNameId(className);
376 }
377
378 setClassNameId(classNameId);
379 }
380
381 @JSON
382 public long getClassNameId() {
383 return _classNameId;
384 }
385
386 public void setClassNameId(long classNameId) {
387 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
388
389 if (!_setOriginalClassNameId) {
390 _setOriginalClassNameId = true;
391
392 _originalClassNameId = _classNameId;
393 }
394
395 _classNameId = classNameId;
396 }
397
398 public long getOriginalClassNameId() {
399 return _originalClassNameId;
400 }
401
402 @JSON
403 public long getClassPK() {
404 return _classPK;
405 }
406
407 public void setClassPK(long classPK) {
408 _columnBitmask |= CLASSPK_COLUMN_BITMASK;
409
410 if (!_setOriginalClassPK) {
411 _setOriginalClassPK = true;
412
413 _originalClassPK = _classPK;
414 }
415
416 _classPK = classPK;
417 }
418
419 public long getOriginalClassPK() {
420 return _originalClassPK;
421 }
422
423 @JSON
424 public String getAddress() {
425 if (_address == null) {
426 return StringPool.BLANK;
427 }
428 else {
429 return _address;
430 }
431 }
432
433 public void setAddress(String address) {
434 _address = address;
435 }
436
437 @JSON
438 public int getTypeId() {
439 return _typeId;
440 }
441
442 public void setTypeId(int typeId) {
443 _typeId = typeId;
444 }
445
446 @JSON
447 public boolean getPrimary() {
448 return _primary;
449 }
450
451 public boolean isPrimary() {
452 return _primary;
453 }
454
455 public void setPrimary(boolean primary) {
456 _columnBitmask |= PRIMARY_COLUMN_BITMASK;
457
458 if (!_setOriginalPrimary) {
459 _setOriginalPrimary = true;
460
461 _originalPrimary = _primary;
462 }
463
464 _primary = primary;
465 }
466
467 public boolean getOriginalPrimary() {
468 return _originalPrimary;
469 }
470
471 public long getColumnBitmask() {
472 return _columnBitmask;
473 }
474
475 @Override
476 public ExpandoBridge getExpandoBridge() {
477 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
478 EmailAddress.class.getName(), getPrimaryKey());
479 }
480
481 @Override
482 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
483 ExpandoBridge expandoBridge = getExpandoBridge();
484
485 expandoBridge.setAttributes(serviceContext);
486 }
487
488 @Override
489 public EmailAddress toEscapedModel() {
490 if (_escapedModel == null) {
491 _escapedModel = (EmailAddress)ProxyUtil.newProxyInstance(_classLoader,
492 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
493 }
494
495 return _escapedModel;
496 }
497
498 @Override
499 public Object clone() {
500 EmailAddressImpl emailAddressImpl = new EmailAddressImpl();
501
502 emailAddressImpl.setEmailAddressId(getEmailAddressId());
503 emailAddressImpl.setCompanyId(getCompanyId());
504 emailAddressImpl.setUserId(getUserId());
505 emailAddressImpl.setUserName(getUserName());
506 emailAddressImpl.setCreateDate(getCreateDate());
507 emailAddressImpl.setModifiedDate(getModifiedDate());
508 emailAddressImpl.setClassNameId(getClassNameId());
509 emailAddressImpl.setClassPK(getClassPK());
510 emailAddressImpl.setAddress(getAddress());
511 emailAddressImpl.setTypeId(getTypeId());
512 emailAddressImpl.setPrimary(getPrimary());
513
514 emailAddressImpl.resetOriginalValues();
515
516 return emailAddressImpl;
517 }
518
519 public int compareTo(EmailAddress emailAddress) {
520 int value = 0;
521
522 value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
523
524 if (value != 0) {
525 return value;
526 }
527
528 return 0;
529 }
530
531 @Override
532 public boolean equals(Object obj) {
533 if (obj == null) {
534 return false;
535 }
536
537 EmailAddress emailAddress = null;
538
539 try {
540 emailAddress = (EmailAddress)obj;
541 }
542 catch (ClassCastException cce) {
543 return false;
544 }
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 }