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.location.impl.campus;
17  
18  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
19  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
20  import org.kuali.rice.location.framework.campus.CampusEbo;
21  
22  import javax.persistence.Column;
23  import javax.persistence.Convert;
24  import javax.persistence.Entity;
25  import javax.persistence.FetchType;
26  import javax.persistence.Id;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.OneToOne;
29  import javax.persistence.Table;
30  
31  @Entity
32  @Table(name = "KRLC_CMP_T")
33  public class CampusBo extends PersistableBusinessObjectBase implements CampusEbo {
34  
35      private static final long serialVersionUID = 787567094298971223L;
36  
37      @Id
38      @Column(name = "CAMPUS_CD")
39      private String code;
40  
41      @Column(name = "CAMPUS_NM")
42      private String name;
43  
44      @Column(name = "CAMPUS_SHRT_NM")
45      private String shortName;
46  
47      @Column(name = "CAMPUS_TYP_CD")
48      private String campusTypeCode;
49  
50      @Column(name = "ACTV_IND")
51      @Convert(converter = BooleanYNConverter.class)
52      private boolean active;
53  
54      @OneToOne(fetch = FetchType.EAGER)
55      @JoinColumn(name = "CAMPUS_TYP_CD", insertable = false, updatable = false)
56      private CampusTypeBo campusType;
57  
58      @Override
59      public String getCode() {
60          return code;
61      }
62  
63      public void setCode(String code) {
64          this.code = code;
65      }
66  
67      @Override
68      public String getName() {
69          return name;
70      }
71  
72      public void setName(String name) {
73          this.name = name;
74      }
75  
76      @Override
77      public String getShortName() {
78          return shortName;
79      }
80  
81      public void setShortName(String shortName) {
82          this.shortName = shortName;
83      }
84  
85      public String getCampusTypeCode() {
86          return campusTypeCode;
87      }
88  
89      public void setCampusTypeCode(String campusTypeCode) {
90          this.campusTypeCode = campusTypeCode;
91      }
92  
93      @Override
94      public boolean isActive() {
95          return active;
96      }
97  
98      @Override
99      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 }