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.api.campus.CampusType;
021import org.kuali.rice.location.framework.campus.CampusTypeEbo;
022
023import javax.persistence.Column;
024import javax.persistence.Convert;
025import javax.persistence.Entity;
026import javax.persistence.Id;
027import javax.persistence.Table;
028
029@Entity
030@Table(name = "KRLC_CMP_TYP_T")
031public class CampusTypeBo extends PersistableBusinessObjectBase implements CampusTypeEbo {
032
033    private static final long serialVersionUID = 7644401997723042733L;
034
035    @Id
036    @Column(name = "CAMPUS_TYP_CD")
037    private String code;
038
039    @Column(name = "CMP_TYP_NM")
040    private String name;
041
042    @Column(name = "ACTV_IND")
043    @Convert(converter = BooleanYNConverter.class)
044    private boolean active;
045
046    @Override
047    public String getCode() {
048        return code;
049    }
050
051    public void setCode(String code) {
052        this.code = code;
053    }
054
055    @Override
056    public String getName() {
057        return name;
058    }
059
060    public void setName(String name) {
061        this.name = name;
062    }
063
064    @Override
065    public boolean isActive() {
066        return active;
067    }
068
069    @Override
070    public void setActive(boolean active) {
071        this.active = active;
072    }
073
074    /**
075     * Converts a mutable CountryBo to an immutable Country representation.
076     * @param bo
077     * @return an immutable Country
078     */
079    public static CampusType to(CampusTypeBo bo) {
080        if (bo == null) {
081            return null;
082        }
083        return CampusType.Builder.create(bo).build();
084    }
085
086    /**
087     * Creates a CountryBo business object from an immutable representation of a Country.
088     * @param im immutable Country
089     * @return a CountryBo
090     */
091    static CampusTypeBo from(CampusType im) {
092        if (im == null) {
093            return null;
094        }
095
096        CampusTypeBo bo = new CampusTypeBo();
097        bo.code = im.getCode();
098        bo.name = im.getName();
099        bo.active = im.isActive();
100        bo.versionNumber = im.getVersionNumber();
101        bo.objectId = im.getObjectId();
102
103        return bo;
104    }
105}