View Javadoc

1   /*
2    * Copyright 2007-2008 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.bo.ui;
17  
18  import java.util.LinkedHashMap;
19  
20  import javax.persistence.Column;
21  import javax.persistence.Entity;
22  import javax.persistence.FetchType;
23  import javax.persistence.Id;
24  import javax.persistence.JoinColumn;
25  import javax.persistence.ManyToOne;
26  import javax.persistence.Table;
27  
28  import org.apache.commons.lang.StringUtils;
29  import org.kuali.rice.kim.bo.reference.PhoneType;
30  import org.kuali.rice.kim.bo.reference.impl.PhoneTypeImpl;
31  
32  /**
33   * This is a description of what this class does - shyu don't forget to fill this in. 
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   *
37   */
38  @Entity
39  @Table(name = "KRIM_PND_PHONE_MT")
40  public class PersonDocumentPhone extends PersonDocumentBoDefaultBase {
41  	@Id
42  	@Column(name = "ENTITY_PHONE_ID")
43  	protected String entityPhoneId;
44  		
45  	@Column(name = "ENT_TYP_CD")
46  	protected String entityTypeCode;
47  	
48  	@Column(name = "PHONE_TYP_CD")
49  	protected String phoneTypeCode;
50  	
51  	@Column(name = "PHONE_NBR")
52  	protected String phoneNumber;
53  	
54  	@Column(name = "PHONE_EXTN_NBR")
55  	protected String extensionNumber;
56  	
57  	@Column(name = "POSTAL_CNTRY_CD")
58  	protected String countryCode;
59  	
60  	@ManyToOne(targetEntity=PhoneTypeImpl.class, fetch = FetchType.EAGER, cascade = {})
61  	@JoinColumn(name = "PHONE_TYP_CD", insertable = false, updatable = false)
62  	protected PhoneType phoneType;
63  
64  	// Waiting until we pull in from KFS
65  	// protected Country country;
66  	public PersonDocumentPhone() {
67  		this.active = true;
68  	}
69  	
70  	/**
71  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getCountryCode()
72  	 */
73  	public String getCountryCode() {
74  		return countryCode;
75  	}
76  
77  	/**
78  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getEntityPhoneId()
79  	 */
80  	public String getEntityPhoneId() {
81  		return entityPhoneId;
82  	}
83  
84  	/**
85  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getExtensionNumber()
86  	 */
87  	public String getExtensionNumber() {
88  		return extensionNumber;
89  	}
90  
91  	/**
92  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getPhoneNumber()
93  	 */
94  	public String getPhoneNumber() {
95  		return phoneNumber;
96  	}
97  
98  	/**
99  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getPhoneTypeCode()
100 	 */
101 	public String getPhoneTypeCode() {
102 		return phoneTypeCode;
103 	}
104 
105 	/**
106 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setCountryCode(java.lang.String)
107 	 */
108 	public void setCountryCode(String countryCode) {
109 		this.countryCode = countryCode;
110 	}
111 
112 	/**
113 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setExtensionNumber(java.lang.String)
114 	 */
115 	public void setExtensionNumber(String extensionNumber) {
116 		this.extensionNumber = extensionNumber;
117 	}
118 
119 	/**
120 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setPhoneNumber(java.lang.String)
121 	 */
122 	public void setPhoneNumber(String phoneNumber) {
123 		this.phoneNumber = phoneNumber;
124 	}
125 
126 	/**
127 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setPhoneTypeCode(java.lang.String)
128 	 */
129 	public void setPhoneTypeCode(String phoneTypeCode) {
130 		this.phoneTypeCode = phoneTypeCode;
131 	}
132 
133 	/**
134 	 * @see org.kuali.rice.kim.bo.entity.KimDefaultableEntityTypeData#getEntityTypeCode()
135 	 */
136 	public String getEntityTypeCode() {
137 		return entityTypeCode;
138 	}
139 
140 	/**
141 	 * @see org.kuali.rice.kim.bo.entity.KimDefaultableEntityTypeData#setEntityTypeCode(java.lang.String)
142 	 */
143 	public void setEntityTypeCode(String entityTypeCode) {
144 		this.entityTypeCode = entityTypeCode;
145 	}
146 
147 	/**
148 	 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
149 	 */
150 	@SuppressWarnings("unchecked")
151 	@Override
152 	protected LinkedHashMap toStringMapper() {
153 		LinkedHashMap m = super.toStringMapper();
154 		m.put( "entityPhoneId", entityPhoneId );
155 		m.put( "phoneNumber", phoneNumber );
156 		m.put( "extensionNumber", extensionNumber );
157 		m.put( "countryCode", countryCode );
158 		return m;
159 	}
160 
161 	public PhoneType getPhoneType() {
162 		return this.phoneType;
163 	}
164 
165 	public void setPhoneType(PhoneType phoneType) {
166 		this.phoneType = phoneType;
167 	}
168 
169 	public void setEntityPhoneId(String entityPhoneId) {
170 		this.entityPhoneId = entityPhoneId;
171 	}
172 
173 	public String getFormattedPhoneNumber() {
174 		StringBuffer sb = new StringBuffer( 30 );
175 		
176 		// TODO: get extension from country code table
177 		// TODO: append "+xxx" if country is not the default country
178 		sb.append( getPhoneNumber() );
179 		if ( StringUtils.isNotBlank( getExtensionNumber() ) ) {
180 			sb.append( " x" );
181 			sb.append( getExtensionNumber() );
182 		}
183 		
184 		return sb.toString();
185 	}
186 
187 	@Override
188 	public boolean isActive(){
189 		return this.active;
190 	}
191 
192 }