View Javadoc

1   /**
2    * Copyright 2005-2013 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 org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.kim.impl.identity.phone.EntityPhoneTypeBo;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.FetchType;
24  import javax.persistence.GeneratedValue;
25  import javax.persistence.Id;
26  import javax.persistence.IdClass;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.ManyToOne;
29  import javax.persistence.Table;
30  
31  /**
32   * This is a description of what this class does - shyu don't forget to fill this in. 
33   * 
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   *
36   */
37  @IdClass(PersonDocumentPhoneId.class)
38  @Entity
39  @Table(name = "KRIM_PND_PHONE_MT")
40  public class PersonDocumentPhone extends PersonDocumentBoDefaultBase {
41  	@Id
42  	@GeneratedValue(generator="KRIM_ENTITY_PHONE_ID_S")
43  	@Column(name = "ENTITY_PHONE_ID")
44  	protected String entityPhoneId;
45  		
46  	@Column(name = "ENT_TYP_CD")
47  	protected String entityTypeCode;
48  	
49  	@Column(name = "PHONE_TYP_CD")
50  	protected String phoneTypeCode;
51  	
52  	@Column(name = "PHONE_NBR")
53  	protected String phoneNumber;
54  	
55  	@Column(name = "PHONE_EXTN_NBR")
56  	protected String extensionNumber;
57  	
58  	@Column(name = "POSTAL_CNTRY_CD")
59  	protected String countryCode;
60  	
61  	@ManyToOne(targetEntity=EntityPhoneTypeBo.class, fetch = FetchType.EAGER, cascade = {})
62  	@JoinColumn(name = "PHONE_TYP_CD", insertable = false, updatable = false)
63  	protected EntityPhoneTypeBo phoneType;
64  
65  	// Waiting until we pull in from KFS
66  	// protected Country country;
67  	public PersonDocumentPhone() {
68  		this.active = true;
69  	}
70  	
71  	/**
72  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getCountryCode()
73  	 */
74  	public String getCountryCode() {
75  		return countryCode;
76  	}
77  
78  	/**
79  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getEntityPhoneId()
80  	 */
81  	public String getEntityPhoneId() {
82  		return entityPhoneId;
83  	}
84  
85  	/**
86  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getExtensionNumber()
87  	 */
88  	public String getExtensionNumber() {
89  		return extensionNumber;
90  	}
91  
92  	/**
93  	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getPhoneNumber()
94  	 */
95  	public String getPhoneNumber() {
96  		return phoneNumber;
97  	}
98  
99  	/**
100 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#getPhoneTypeCode()
101 	 */
102 	public String getPhoneTypeCode() {
103 		return phoneTypeCode;
104 	}
105 
106 	/**
107 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setCountryCode(java.lang.String)
108 	 */
109 	public void setCountryCode(String countryCode) {
110 		this.countryCode = countryCode;
111 	}
112 
113 	/**
114 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setExtensionNumber(java.lang.String)
115 	 */
116 	public void setExtensionNumber(String extensionNumber) {
117 		this.extensionNumber = extensionNumber;
118 	}
119 
120 	/**
121 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setPhoneNumber(java.lang.String)
122 	 */
123 	public void setPhoneNumber(String phoneNumber) {
124 		this.phoneNumber = phoneNumber;
125 	}
126 
127 	/**
128 	 * @see org.kuali.rice.kim.bo.entity.KimEntityPhone#setPhoneTypeCode(java.lang.String)
129 	 */
130 	public void setPhoneTypeCode(String phoneTypeCode) {
131 		this.phoneTypeCode = phoneTypeCode;
132 	}
133 
134 	/**
135 	 * @see org.kuali.rice.kim.bo.entity.KimDefaultableEntityTypeData#getEntityTypeCode()
136 	 */
137 	public String getEntityTypeCode() {
138 		return entityTypeCode;
139 	}
140 
141 	/**
142 	 * @see org.kuali.rice.kim.bo.entity.KimDefaultableEntityTypeData#setEntityTypeCode(java.lang.String)
143 	 */
144 	public void setEntityTypeCode(String entityTypeCode) {
145 		this.entityTypeCode = entityTypeCode;
146 	}
147 
148 	public EntityPhoneTypeBo getPhoneType() {
149 		return this.phoneType;
150 	}
151 
152 	public void setPhoneType(EntityPhoneTypeBo phoneType) {
153 		this.phoneType = phoneType;
154 	}
155 
156 	public void setEntityPhoneId(String entityPhoneId) {
157 		this.entityPhoneId = entityPhoneId;
158 	}
159 
160 	public String getFormattedPhoneNumber() {
161 		StringBuffer sb = new StringBuffer( 30 );
162 		
163 		// TODO: get extension from country code table
164 		// TODO: append "+xxx" if country is not the default country
165 		sb.append( getPhoneNumber() );
166 		if ( StringUtils.isNotBlank( getExtensionNumber() ) ) {
167 			sb.append( " x" );
168 			sb.append( getExtensionNumber() );
169 		}
170 		
171 		return sb.toString();
172 	}
173 
174 }