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.external;
017
018import javax.persistence.AttributeOverride;
019import javax.persistence.AttributeOverrides;
020import javax.persistence.Column;
021import javax.persistence.Convert;
022import javax.persistence.Entity;
023import javax.persistence.Table;
024import org.kuali.rice.kim.api.identity.CodedAttribute;
025import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierType;
026import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierTypeContract;
027import org.kuali.rice.kim.framework.identity.external.EntityExternalIdentifierTypeEbo;
028import org.kuali.rice.kim.impl.identity.CodedAttributeBo;
029import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
030
031@AttributeOverrides({ @AttributeOverride(name = "code", column = @Column(name = "EXT_ID_TYP_CD")) })
032@Entity
033@Table(name = "KRIM_EXT_ID_TYP_T")
034public class EntityExternalIdentifierTypeBo extends CodedAttributeBo implements EntityExternalIdentifierTypeEbo, EntityExternalIdentifierTypeContract {
035
036    private static final long serialVersionUID = 1058518958597912170L;
037
038    @Column(name = "ENCR_REQ_IND")
039    @Convert(converter = BooleanYNConverter.class)
040    private boolean encryptionRequired;
041
042    @Override
043    public boolean isEncryptionRequired() {
044        return encryptionRequired;
045    }
046
047    public void setEncryptionRequired(boolean encryptionRequired) {
048        this.encryptionRequired = encryptionRequired;
049    }
050
051    public static EntityExternalIdentifierTypeBo from(EntityExternalIdentifierType immutable) {
052        EntityExternalIdentifierTypeBo bo = CodedAttributeBo.from(EntityExternalIdentifierTypeBo.class, CodedAttribute.Builder.create(immutable).build());
053        bo.setEncryptionRequired(immutable.isEncryptionRequired());
054        return bo;
055    }
056
057    public static EntityExternalIdentifierType to(EntityExternalIdentifierTypeBo bo) {
058        if (bo == null) {
059            return null;
060        }
061        return EntityExternalIdentifierType.Builder.create(bo).build();
062    }
063}