1   /**
2    * Copyright (c) 2000-2004 Liferay, LLC. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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  /**
33   * <a href="ABContact.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author  Brian Wing Shun Chan
36   * @version $Revision: 1.10 $
37   *
38   */
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 }