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 */
016/**
017 * Copyright 2005-2014 The Kuali Foundation
018 *
019 * Licensed under the Educational Community License, Version 2.0 (the "License");
020 * you may not use this file except in compliance with the License.
021 * You may obtain a copy of the License at
022 *
023 * http://www.opensource.org/licenses/ecl2.php
024 *
025 * Unless required by applicable law or agreed to in writing, software
026 * distributed under the License is distributed on an "AS IS" BASIS,
027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
028 * See the License for the specific language governing permissions and
029 * limitations under the License.
030 */
031package org.kuali.rice.kim.impl.identity.affiliation;
032
033import org.kuali.rice.kim.api.identity.CodedAttribute;
034import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationType;
035import org.kuali.rice.kim.framework.identity.affiliation.EntityAffiliationTypeEbo;
036import org.kuali.rice.kim.impl.identity.CodedAttributeBo;
037import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
038
039import javax.persistence.AttributeOverride;
040import javax.persistence.AttributeOverrides;
041import javax.persistence.Column;
042import javax.persistence.Convert;
043import javax.persistence.Entity;
044import javax.persistence.Table;
045
046@AttributeOverrides({@AttributeOverride(name="code",column=@Column(name="AFLTN_TYP_CD"))})
047@Entity
048@Table(name = "KRIM_AFLTN_TYP_T")
049public class EntityAffiliationTypeBo extends CodedAttributeBo implements EntityAffiliationTypeEbo {
050
051    private static final long serialVersionUID = 4973602240626940004L;
052
053    @Column(name = "EMP_AFLTN_TYP_IND")
054    @Convert(converter = BooleanYNConverter.class)
055    private boolean employmentAffiliationType;
056
057    public static EntityAffiliationTypeBo from(EntityAffiliationType immutable) {
058        EntityAffiliationTypeBo bo = CodedAttributeBo.from(EntityAffiliationTypeBo.class, CodedAttribute.Builder.create(immutable).build());
059        bo.setEmploymentAffiliationType(immutable.isEmploymentAffiliationType());
060        return bo;
061    }
062
063    public static EntityAffiliationType to(EntityAffiliationTypeBo bo) {
064        if (bo == null) {
065            return null;
066        }
067        return EntityAffiliationType.Builder.create(bo).build();
068    }
069
070    @Override
071    public boolean isEmploymentAffiliationType() {
072        return employmentAffiliationType;
073    }
074
075    public void setEmploymentAffiliationType(boolean employmentAffiliationType) {
076        this.employmentAffiliationType = employmentAffiliationType;
077    }
078}