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.location.impl.campus; 017 018import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 019import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter; 020import org.kuali.rice.location.framework.campus.CampusEbo; 021 022import javax.persistence.Column; 023import javax.persistence.Convert; 024import javax.persistence.Entity; 025import javax.persistence.FetchType; 026import javax.persistence.Id; 027import javax.persistence.JoinColumn; 028import javax.persistence.OneToOne; 029import javax.persistence.Table; 030 031@Entity 032@Table(name = "KRLC_CMP_T") 033public class CampusBo extends PersistableBusinessObjectBase implements CampusEbo { 034 035 private static final long serialVersionUID = 787567094298971223L; 036 037 @Id 038 @Column(name = "CAMPUS_CD") 039 private String code; 040 041 @Column(name = "CAMPUS_NM") 042 private String name; 043 044 @Column(name = "CAMPUS_SHRT_NM") 045 private String shortName; 046 047 @Column(name = "CAMPUS_TYP_CD") 048 private String campusTypeCode; 049 050 @Column(name = "ACTV_IND") 051 @Convert(converter = BooleanYNConverter.class) 052 private boolean active; 053 054 @OneToOne(fetch = FetchType.EAGER) 055 @JoinColumn(name = "CAMPUS_TYP_CD", insertable = false, updatable = false) 056 private CampusTypeBo campusType; 057 058 @Override 059 public String getCode() { 060 return code; 061 } 062 063 public void setCode(String code) { 064 this.code = code; 065 } 066 067 @Override 068 public String getName() { 069 return name; 070 } 071 072 public void setName(String name) { 073 this.name = name; 074 } 075 076 @Override 077 public String getShortName() { 078 return shortName; 079 } 080 081 public void setShortName(String shortName) { 082 this.shortName = shortName; 083 } 084 085 public String getCampusTypeCode() { 086 return campusTypeCode; 087 } 088 089 public void setCampusTypeCode(String campusTypeCode) { 090 this.campusTypeCode = campusTypeCode; 091 } 092 093 @Override 094 public boolean isActive() { 095 return active; 096 } 097 098 @Override 099 public void setActive(boolean active) { 100 this.active = active; 101 } 102 103 @Override 104 public CampusTypeBo getCampusType() { 105 return campusType; 106 } 107 108 public void setCampusType(CampusTypeBo campusType) { 109 this.campusType = campusType; 110 } 111 112 /** 113 * Converts a mutable bo to its immutable counterpart 114 * @param bo the mutable business object 115 * @return the immutable object 116 */ 117 public static org.kuali.rice.location.api.campus.Campus to(CampusBo bo) { 118 if (bo == null) { 119 return null; 120 } 121 return org.kuali.rice.location.api.campus.Campus.Builder.create(bo).build(); 122 } 123 124 /** 125 * Converts a immutable object to its mutable counterpart 126 * @param im immutable object 127 * @return the mutable bo 128 */ 129 public static CampusBo from(org.kuali.rice.location.api.campus.Campus im) { 130 if (im == null) { 131 return null; 132 } 133 134 CampusBo bo = new CampusBo(); 135 bo.code = im.getCode(); 136 bo.name = im.getName(); 137 bo.shortName = im.getShortName(); 138 bo.active = im.isActive(); 139 if (im.getCampusType() != null) { 140 bo.campusTypeCode = im.getCampusType().getCode(); 141 } 142 bo.campusType = CampusTypeBo.from(im.getCampusType()); 143 bo.versionNumber = im.getVersionNumber(); 144 bo.objectId = im.getObjectId(); 145 146 return bo; 147 } 148 149}