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.role;
17  
18  import javax.persistence.CascadeType;
19  import javax.persistence.Column;
20  import javax.persistence.Convert;
21  import javax.persistence.Entity;
22  import javax.persistence.GeneratedValue;
23  import javax.persistence.Id;
24  import javax.persistence.JoinColumn;
25  import javax.persistence.ManyToOne;
26  import javax.persistence.Table;
27  
28  import org.eclipse.persistence.annotations.JoinFetch;
29  import org.eclipse.persistence.annotations.JoinFetchType;
30  import org.kuali.rice.kim.api.role.RoleResponsibility;
31  import org.kuali.rice.kim.api.role.RoleResponsibilityContract;
32  import org.kuali.rice.kim.impl.responsibility.ResponsibilityBo;
33  import org.kuali.rice.krad.bo.DataObjectBase;
34  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
35  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
36  
37  /**
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  @Entity
41  @Table(name = "KRIM_ROLE_RSP_T")
42  public class RoleResponsibilityBo extends DataObjectBase implements RoleResponsibilityContract {
43  
44      private static final long serialVersionUID = 1L;
45  
46      @PortableSequenceGenerator(name = "KRIM_ROLE_RSP_ID_S")
47      @GeneratedValue(generator = "KRIM_ROLE_RSP_ID_S")
48      @Id
49      @Column(name = "ROLE_RSP_ID")
50      private String roleResponsibilityId;
51  
52      @Column(name = "ROLE_ID")
53      private String roleId;
54  
55      @Column(name = "RSP_ID")
56      private String responsibilityId;
57  
58      @Column(name = "ACTV_IND")
59      @Convert(converter = BooleanYNConverter.class)
60      private boolean active;
61  
62      @JoinFetch(value= JoinFetchType.OUTER)
63      @ManyToOne(targetEntity = ResponsibilityBo.class, cascade = { CascadeType.REFRESH })
64      @JoinColumn(name = "RSP_ID", referencedColumnName = "RSP_ID", insertable = false, updatable = false)
65      private ResponsibilityBo kimResponsibility;
66  
67      public static RoleResponsibility to(RoleResponsibilityBo bo) {
68          if (bo == null) {
69              return null;
70          }
71          return RoleResponsibility.Builder.create(bo).build();
72      }
73  
74      public static RoleResponsibilityBo from(RoleResponsibility immutable) {
75          if (immutable == null) {
76              return null;
77          }
78          RoleResponsibilityBo bo = new RoleResponsibilityBo();
79          bo.roleResponsibilityId = immutable.getRoleResponsibilityId();
80          bo.roleId = immutable.getRoleId();
81          bo.responsibilityId = immutable.getResponsibilityId();
82          bo.active = immutable.isActive();
83          bo.setVersionNumber(immutable.getVersionNumber());
84          return bo;
85      }
86  
87      @Override
88      public String getRoleResponsibilityId() {
89          return roleResponsibilityId;
90      }
91  
92      public void setRoleResponsibilityId(String roleResponsibilityId) {
93          this.roleResponsibilityId = roleResponsibilityId;
94      }
95  
96      @Override
97      public String getRoleId() {
98          return roleId;
99      }
100 
101     public void setRoleId(String roleId) {
102         this.roleId = roleId;
103     }
104 
105     @Override
106     public String getResponsibilityId() {
107         return responsibilityId;
108     }
109 
110     public void setResponsibilityId(String responsibilityId) {
111         this.responsibilityId = responsibilityId;
112     }
113 
114     public boolean getActive() {
115         return active;
116     }
117 
118     @Override
119     public boolean isActive() {
120         return active;
121     }
122 
123     public void setActive(boolean active) {
124         this.active = active;
125     }
126 
127     public ResponsibilityBo getKimResponsibility() {
128         return kimResponsibility;
129     }
130 
131     public void setKimResponsibility(ResponsibilityBo kimResponsibility) {
132         this.kimResponsibility = kimResponsibility;
133     }
134 }