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