View Javadoc
1   /**
2    * Copyright 2005-2015 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.kim.impl.identity.principal;
17  
18  import javax.persistence.Column;
19  import javax.persistence.Convert;
20  import javax.persistence.Entity;
21  import javax.persistence.GeneratedValue;
22  import javax.persistence.Id;
23  import javax.persistence.Table;
24  
25  import org.kuali.rice.kim.api.identity.principal.Principal;
26  import org.kuali.rice.kim.api.identity.principal.PrincipalContract;
27  import org.kuali.rice.krad.bo.DataObjectBase;
28  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
29  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  @Entity
35  @Table(name = "KRIM_PRNCPL_T")
36  public class PrincipalBo extends DataObjectBase implements PrincipalContract {
37      private static final long serialVersionUID = 1L;
38  
39      @PortableSequenceGenerator(name = "KRIM_PRNCPL_ID_S")
40      @GeneratedValue(generator = "KRIM_PRNCPL_ID_S")
41      @Id
42      @Column(name = "PRNCPL_ID")
43      private String principalId;
44  
45      @Column(name = "PRNCPL_NM")
46      private String principalName;
47  
48      @Column(name = "ENTITY_ID")
49      private String entityId;
50  
51      @Column(name = "PRNCPL_PSWD")
52      private String password;
53  
54      @Column(name = "ACTV_IND")
55      @Convert(converter = BooleanYNConverter.class)
56      private boolean active;
57  
58      public static Principal to(PrincipalBo bo) {
59          if (bo == null) {
60              return null;
61          }
62          return Principal.Builder.create(bo).build();
63      }
64  
65      /**
66       * Creates a PrincipalBo business object from an immutable representation of a Principal.
67       *
68       * @param immutable an immutable Principal
69       * @return a PrincipalBo
70       */
71      public static PrincipalBo from(Principal immutable) {
72          if (immutable == null) {
73              return null;
74          }
75          PrincipalBo bo = new PrincipalBo();
76          bo.active = immutable.isActive();
77          bo.principalId = immutable.getPrincipalId();
78          bo.entityId = immutable.getEntityId();
79          bo.principalName = immutable.getPrincipalName();
80          bo.active = immutable.isActive();
81          bo.setVersionNumber(immutable.getVersionNumber());
82          bo.setObjectId(immutable.getObjectId());
83          return bo;
84      }
85  
86      @Override
87      public String getPrincipalId() {
88          return principalId;
89      }
90  
91      public void setPrincipalId(String principalId) {
92          this.principalId = principalId;
93      }
94  
95      @Override
96      public String getPrincipalName() {
97          return principalName;
98      }
99  
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 }