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