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