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