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