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.principal; 017 018import javax.persistence.Column; 019import javax.persistence.Convert; 020import javax.persistence.Entity; 021import javax.persistence.GeneratedValue; 022import javax.persistence.Id; 023import javax.persistence.Table; 024 025import org.kuali.rice.kim.api.identity.principal.Principal; 026import org.kuali.rice.kim.api.identity.principal.PrincipalContract; 027import org.kuali.rice.krad.bo.DataObjectBase; 028import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter; 029import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 030 031/** 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034@Entity 035@Table(name = "KRIM_PRNCPL_T") 036public class PrincipalBo extends DataObjectBase implements PrincipalContract { 037 private static final long serialVersionUID = 1L; 038 039 @PortableSequenceGenerator(name = "KRIM_PRNCPL_ID_S") 040 @GeneratedValue(generator = "KRIM_PRNCPL_ID_S") 041 @Id 042 @Column(name = "PRNCPL_ID") 043 private String principalId; 044 045 @Column(name = "PRNCPL_NM") 046 private String principalName; 047 048 @Column(name = "ENTITY_ID") 049 private String entityId; 050 051 @Column(name = "PRNCPL_PSWD") 052 private String password; 053 054 @Column(name = "ACTV_IND") 055 @Convert(converter = BooleanYNConverter.class) 056 private boolean active; 057 058 public static Principal to(PrincipalBo bo) { 059 if (bo == null) { 060 return null; 061 } 062 return Principal.Builder.create(bo).build(); 063 } 064 065 /** 066 * Creates a PrincipalBo business object from an immutable representation of a Principal. 067 * 068 * @param immutable an immutable Principal 069 * @return a PrincipalBo 070 */ 071 public static PrincipalBo from(Principal immutable) { 072 if (immutable == null) { 073 return null; 074 } 075 PrincipalBo bo = new PrincipalBo(); 076 bo.active = immutable.isActive(); 077 bo.principalId = immutable.getPrincipalId(); 078 bo.entityId = immutable.getEntityId(); 079 bo.principalName = immutable.getPrincipalName(); 080 bo.active = immutable.isActive(); 081 bo.setVersionNumber(immutable.getVersionNumber()); 082 bo.setObjectId(immutable.getObjectId()); 083 return bo; 084 } 085 086 @Override 087 public String getPrincipalId() { 088 return principalId; 089 } 090 091 public void setPrincipalId(String principalId) { 092 this.principalId = principalId; 093 } 094 095 @Override 096 public String getPrincipalName() { 097 return principalName; 098 } 099 100 public void setPrincipalName(String principalName) { 101 this.principalName = principalName; 102 } 103 104 @Override 105 public String getEntityId() { 106 return entityId; 107 } 108 109 public void setEntityId(String entityId) { 110 this.entityId = entityId; 111 } 112 113 public String getPassword() { 114 return password; 115 } 116 117 public void setPassword(String password) { 118 this.password = password; 119 } 120 121 public boolean getActive() { 122 return active; 123 } 124 125 @Override 126 public boolean isActive() { 127 return active; 128 } 129 130 public void setActive(boolean active) { 131 this.active = active; 132 } 133}