View Javadoc
1   /**
2    * Copyright 2005-2015 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.impl.identity.phone;
17  
18  import org.eclipse.persistence.annotations.JoinFetch;
19  import org.eclipse.persistence.annotations.JoinFetchType;
20  import org.kuali.rice.kim.api.identity.phone.EntityPhone;
21  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
22  
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.FetchType;
26  import javax.persistence.GeneratedValue;
27  import javax.persistence.Id;
28  import javax.persistence.JoinColumn;
29  import javax.persistence.ManyToOne;
30  import javax.persistence.Table;
31  
32  @Entity
33  @Table(name = "KRIM_ENTITY_PHONE_T")
34  public class EntityPhoneBo extends EntityPhoneBase {
35      private static final long serialVersionUID = 1L;
36  
37      @Id
38      @GeneratedValue(generator = "KRIM_ENTITY_PHONE_ID_S")
39      @PortableSequenceGenerator(name = "KRIM_ENTITY_PHONE_ID_S")
40      @Column(name = "ENTITY_PHONE_ID")
41      private String id;
42  
43      @JoinFetch(value= JoinFetchType.OUTER)
44      @ManyToOne(targetEntity = EntityPhoneTypeBo.class, fetch = FetchType.EAGER, cascade = {})
45      @JoinColumn(name = "PHONE_TYP_CD", insertable = false, updatable = false)
46      private EntityPhoneTypeBo phoneType;
47  
48      public static EntityPhone to(EntityPhoneBo bo) {
49          if (bo == null) {
50              return null;
51          }
52  
53          return EntityPhone.Builder.create(bo).build();
54      }
55  
56      /**
57       * Creates a CountryBo business object from an immutable representation of a Country.
58       *
59       * @param immutable immutable Country
60       * @return a CountryBo
61       */
62      public static EntityPhoneBo from(EntityPhone immutable) {
63          if (immutable == null) {
64              return null;
65          }
66  
67          EntityPhoneBo bo = new EntityPhoneBo();
68          bo.setId(immutable.getId());
69          bo.setActive(immutable.isActive());
70  
71          bo.setEntityId(immutable.getEntityId());
72          bo.setEntityTypeCode(immutable.getEntityTypeCode());
73          if (immutable.getPhoneType() != null) {
74              bo.setPhoneTypeCode(immutable.getPhoneType().getCode());
75          }
76  
77          bo.setPhoneType(EntityPhoneTypeBo.from(immutable.getPhoneType()));
78          bo.setDefaultValue(immutable.isDefaultValue());
79          bo.setCountryCode(immutable.getCountryCodeUnmasked());
80          bo.setPhoneNumber(immutable.getPhoneNumberUnmasked());
81          bo.setExtensionNumber(immutable.getExtensionNumberUnmasked());
82          bo.setVersionNumber(immutable.getVersionNumber());
83          bo.setObjectId(immutable.getObjectId());
84  
85          return bo;
86      }
87  
88      @Override
89      public String getId() {
90          return id;
91      }
92  
93      public void setId(String id) {
94          this.id = id;
95      }
96  
97      @Override
98      public EntityPhoneTypeBo getPhoneType() {
99          return this.phoneType;
100     }
101 
102     public void setPhoneType(EntityPhoneTypeBo phoneType) {
103         this.phoneType = phoneType;
104     }
105 
106 
107 }