1
22
23 package com.liferay.portlet.addressbook.model;
24
25 import com.liferay.portal.util.PropsUtil;
26 import com.liferay.portal.util.Recipient;
27 import com.liferay.util.StringPool;
28 import com.liferay.util.Validator;
29
30 import java.util.Date;
31
32
39 public class ABContact extends ABContactModel implements Recipient {
40
41 public static final String[] JOB_CLASSES =
42 PropsUtil.getArray(PropsUtil.ADDRESS_BOOK_CONTACT_JOB_CLASSES);
43
44 public ABContact(String contactId) {
45 super(contactId);
46 }
47
48 public ABContact(String firstName, String lastName, String emailAddress) {
49 super(null, null, firstName, null, lastName, null, emailAddress, null,
50 null, null, null, null, null, null, null, null, null, null, null,
51 null, null, null, null, null, null, null, null, null, null, null,
52 null, null, null, null, null, null, null, null, null);
53 }
54
55 public ABContact(String contactId, String userId, String firstName,
56 String middleName, String lastName, String nickName,
57 String emailAddress, String homeStreet, String homeCity,
58 String homeState, String homeZip, String homeCountry,
59 String homePhone, String homeFax, String homeCell,
60 String homePager, String homeTollFree,
61 String homeEmailAddress, String businessCompany,
62 String businessStreet, String businessCity,
63 String businessState, String businessZip,
64 String businessCountry, String businessPhone,
65 String businessFax, String businessCell,
66 String businessPager, String businessTollFree,
67 String businessEmailAddress, String employeeNumber,
68 String jobTitle, String jobClass, String hoursOfOperation,
69 Date birthday, String timeZoneId, String instantMessenger,
70 String website, String comments) {
71
72 super(contactId, userId, firstName, middleName, lastName, nickName,
73 emailAddress, homeStreet, homeCity, homeState, homeZip,
74 homeCountry, homePhone, homeFax, homeCell, homePager,
75 homeTollFree, homeEmailAddress, businessCompany, businessStreet,
76 businessCity, businessState, businessZip, businessCountry,
77 businessPhone, businessFax, businessCell, businessPager,
78 businessTollFree, businessEmailAddress, employeeNumber, jobTitle,
79 jobClass, hoursOfOperation, birthday, timeZoneId,
80 instantMessenger, website, comments);
81 }
82
83 public String getFullName() {
84 String firstName = getFirstName();
85 String middleName = getMiddleName();
86 String lastName = getLastName();
87
88 if (Validator.isNull(middleName)) {
89 return firstName + StringPool.SPACE + lastName;
90 }
91 else {
92 return firstName + StringPool.SPACE + middleName +
93 StringPool.SPACE + lastName;
94 }
95 }
96
97 public String getRecipientId() {
98 return getContactId();
99 }
100
101 public String getRecipientName() {
102 return getFullName();
103 }
104
105 public String getRecipientAddress() {
106 return getEmailAddress();
107 }
108
109 public String getRecipientInternetAddress() {
110 return getFullName() + " <" + getEmailAddress() + ">";
111 }
112
113 public boolean isMultipleRecipients() {
114 return false;
115 }
116
117 }