001 /** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kim.bo.ui; 017 018 import java.util.List; 019 020 import javax.persistence.CascadeType; 021 import javax.persistence.Column; 022 import javax.persistence.Entity; 023 import javax.persistence.FetchType; 024 import javax.persistence.GeneratedValue; 025 import javax.persistence.Id; 026 import javax.persistence.IdClass; 027 import javax.persistence.JoinColumn; 028 import javax.persistence.JoinColumns; 029 import javax.persistence.OneToMany; 030 import javax.persistence.Table; 031 import javax.persistence.Transient; 032 033 import org.hibernate.annotations.Fetch; 034 import org.hibernate.annotations.FetchMode; 035 import org.hibernate.annotations.GenericGenerator; 036 import org.hibernate.annotations.Parameter; 037 import org.kuali.rice.core.api.delegation.DelegationType; 038 import org.springframework.util.AutoPopulatingList; 039 040 /** 041 * This is a description of what this class does - kellerj don't forget to fill this in. 042 * 043 * @author Kuali Rice Team (kuali-rice@googleroles.com) 044 * 045 */ 046 @IdClass(RoleDocumentDelegationId.class) 047 @Entity 048 @Table(name="KRIM_PND_DLGN_T") 049 public class RoleDocumentDelegation extends KimDocumentBoActivatableBase { 050 051 private static final long serialVersionUID = 1L; 052 053 @Id 054 @GeneratedValue(generator="KRIM_DLGN_ID_S") 055 @GenericGenerator(name="KRIM_DLGN_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={ 056 @Parameter(name="sequence_name",value="KRIM_DLGN_ID_S"), 057 @Parameter(name="value_column",value="id") 058 }) 059 @Column(name="DLGN_ID") 060 protected String delegationId; 061 062 @Column(name="ROLE_ID") 063 protected String roleId; 064 065 @Column(name="KIM_TYP_ID") 066 protected String kimTypeId; 067 068 @Column(name="DLGN_TYP_CD") 069 protected String delegationTypeCode; 070 071 @OneToMany(targetEntity=RoleDocumentDelegationMember.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) 072 @Fetch(value = FetchMode.SELECT) 073 @JoinColumns({ 074 @JoinColumn(name="dlgn_id",insertable=false,updatable=false), 075 @JoinColumn(name="fdoc_nbr", insertable=false, updatable=false) 076 }) 077 private List<RoleDocumentDelegationMember> members = new AutoPopulatingList(RoleDocumentDelegationMember.class); 078 079 @Transient 080 private RoleDocumentDelegationMember member = new RoleDocumentDelegationMember(); 081 082 @Transient 083 protected List<KimDocumentRoleQualifier> qualifiers = new AutoPopulatingList(KimDocumentRoleQualifier.class); 084 085 public String getRoleId() { 086 return this.roleId; 087 } 088 089 public void setRoleId(String roleId) { 090 this.roleId = roleId; 091 } 092 093 public String getKimTypeId() { 094 return this.kimTypeId; 095 } 096 097 public void setKimTypeId(String typeId) { 098 this.kimTypeId = typeId; 099 } 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 }