001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kim.impl.identity.phone; 017 018import org.eclipse.persistence.annotations.JoinFetch; 019import org.eclipse.persistence.annotations.JoinFetchType; 020import org.kuali.rice.kim.api.identity.phone.EntityPhone; 021import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 022 023import javax.persistence.Column; 024import javax.persistence.Entity; 025import javax.persistence.FetchType; 026import javax.persistence.GeneratedValue; 027import javax.persistence.Id; 028import javax.persistence.JoinColumn; 029import javax.persistence.ManyToOne; 030import javax.persistence.Table; 031 032@Entity 033@Table(name = "KRIM_ENTITY_PHONE_T") 034public class EntityPhoneBo extends EntityPhoneBase { 035 private static final long serialVersionUID = 1L; 036 037 @Id 038 @GeneratedValue(generator = "KRIM_ENTITY_PHONE_ID_S") 039 @PortableSequenceGenerator(name = "KRIM_ENTITY_PHONE_ID_S") 040 @Column(name = "ENTITY_PHONE_ID") 041 private String id; 042 043 @JoinFetch(value= JoinFetchType.OUTER) 044 @ManyToOne(targetEntity = EntityPhoneTypeBo.class, fetch = FetchType.EAGER, cascade = {}) 045 @JoinColumn(name = "PHONE_TYP_CD", insertable = false, updatable = false) 046 private EntityPhoneTypeBo phoneType; 047 048 public static EntityPhone to(EntityPhoneBo bo) { 049 if (bo == null) { 050 return null; 051 } 052 053 return EntityPhone.Builder.create(bo).build(); 054 } 055 056 /** 057 * Creates a CountryBo business object from an immutable representation of a Country. 058 * 059 * @param immutable immutable Country 060 * @return a CountryBo 061 */ 062 public static EntityPhoneBo from(EntityPhone immutable) { 063 if (immutable == null) { 064 return null; 065 } 066 067 EntityPhoneBo bo = new EntityPhoneBo(); 068 bo.setId(immutable.getId()); 069 bo.setActive(immutable.isActive()); 070 071 bo.setEntityId(immutable.getEntityId()); 072 bo.setEntityTypeCode(immutable.getEntityTypeCode()); 073 if (immutable.getPhoneType() != null) { 074 bo.setPhoneTypeCode(immutable.getPhoneType().getCode()); 075 } 076 077 bo.setPhoneType(EntityPhoneTypeBo.from(immutable.getPhoneType())); 078 bo.setDefaultValue(immutable.isDefaultValue()); 079 bo.setCountryCode(immutable.getCountryCodeUnmasked()); 080 bo.setPhoneNumber(immutable.getPhoneNumberUnmasked()); 081 bo.setExtensionNumber(immutable.getExtensionNumberUnmasked()); 082 bo.setVersionNumber(immutable.getVersionNumber()); 083 bo.setObjectId(immutable.getObjectId()); 084 085 return bo; 086 } 087 088 @Override 089 public String getId() { 090 return id; 091 } 092 093 public void setId(String id) { 094 this.id = id; 095 } 096 097 @Override 098 public EntityPhoneTypeBo getPhoneType() { 099 return this.phoneType; 100 } 101 102 public void setPhoneType(EntityPhoneTypeBo phoneType) { 103 this.phoneType = phoneType; 104 } 105 106 107}