View Javadoc
1   /**
2    * Copyright 2005-2014 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.bo.ui;
17  
18  import java.util.List;
19  
20  import javax.persistence.CascadeType;
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.GeneratedValue;
24  import javax.persistence.Id;
25  import javax.persistence.JoinColumn;
26  import javax.persistence.JoinColumns;
27  import javax.persistence.OneToMany;
28  import javax.persistence.Table;
29  import javax.persistence.Transient;
30  
31  import org.kuali.rice.core.api.delegation.DelegationType;
32  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
33  import org.springframework.util.AutoPopulatingList;
34  
35  /**
36   * This is a description of what this class does - kellerj don't forget to fill this in.
37   *
38   * @author Kuali Rice Team (kuali-rice@googleroles.com)
39   *
40   */
41  @Entity
42  @Table(name = "KRIM_PND_DLGN_T")
43  public class RoleDocumentDelegation extends KimDocumentBoActivatableBase {
44  
45      private static final long serialVersionUID = 1L;
46  
47      @PortableSequenceGenerator(name = "KRIM_DLGN_ID_S")
48      @GeneratedValue(generator = "KRIM_DLGN_ID_S")
49      @Id
50      @Column(name = "DLGN_ID")
51      protected String delegationId;
52  
53      @Column(name = "ROLE_ID")
54      protected String roleId;
55  
56      @Column(name = "KIM_TYP_ID")
57      protected String kimTypeId;
58  
59      @Column(name = "DLGN_TYP_CD")
60      protected String delegationTypeCode;
61  
62      @OneToMany(targetEntity = RoleDocumentDelegationMember.class, orphanRemoval = true, cascade = { CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.PERSIST })
63      @JoinColumns({ 
64          @JoinColumn(name = "FDOC_NBR", referencedColumnName = "FDOC_NBR", insertable = false, updatable = false), 
65          @JoinColumn(name = "DLGN_ID", referencedColumnName = "DLGN_ID", insertable = false, updatable = false) })
66      private List<RoleDocumentDelegationMember> members = new AutoPopulatingList<RoleDocumentDelegationMember>(RoleDocumentDelegationMember.class);
67  
68      @Transient
69      private RoleDocumentDelegationMember member = new RoleDocumentDelegationMember();
70  
71      @Transient
72      protected List<KimDocumentRoleQualifier> qualifiers = new AutoPopulatingList<KimDocumentRoleQualifier>(KimDocumentRoleQualifier.class);
73  
74      public String getRoleId() {
75          return this.roleId;
76      }
77  
78      public void setRoleId(String roleId) {
79          this.roleId = roleId;
80      }
81  
82      public String getKimTypeId() {
83          return this.kimTypeId;
84      }
85  
86      public void setKimTypeId(String typeId) {
87          this.kimTypeId = typeId;
88      }
89  
90      public String getDelegationTypeCode() {
91          return this.delegationTypeCode;
92      }
93  
94      public void setDelegationTypeCode(String delegationTypeCode) {
95          this.delegationTypeCode = delegationTypeCode;
96      }
97  
98      public String getDelegationId() {
99          return this.delegationId;
100     }
101 
102     public void setDelegationId(String delegationId) {
103         this.delegationId = delegationId;
104     }
105 
106     /**
107 	 * @return the qualifiers
108 	 */
109     public List<KimDocumentRoleQualifier> getQualifiers() {
110         return this.qualifiers;
111     }
112 
113     /**
114 	 * @param qualifiers the qualifiers to set
115 	 */
116     public void setQualifiers(List<KimDocumentRoleQualifier> qualifiers) {
117         this.qualifiers = qualifiers;
118     }
119 
120     public int getNumberOfQualifiers() {
121         return qualifiers == null ? 0 : qualifiers.size();
122     }
123 
124     /**
125 	 * @return the members
126 	 */
127     public List<RoleDocumentDelegationMember> getMembers() {
128         return this.members;
129     }
130 
131     /**
132 	 * @param members the members to set
133 	 */
134     public void setMembers(List<RoleDocumentDelegationMember> members) {
135         this.members = members;
136     }
137 
138     /**
139 	 * @return the member
140 	 */
141     public RoleDocumentDelegationMember getMember() {
142         return this.member;
143     }
144 
145     /**
146 	 * @param member the member to set
147 	 */
148     public void setMember(RoleDocumentDelegationMember member) {
149         this.member = member;
150     }
151 
152     public boolean isDelegationPrimary() {
153         return DelegationType.PRIMARY.getCode().equals(getDelegationTypeCode());
154     }
155 
156     public boolean isDelegationSecondary() {
157         return DelegationType.SECONDARY.getCode().equals(getDelegationTypeCode());
158     }
159 }