001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.kim.bo.ui; 017 018import org.eclipse.persistence.annotations.JoinFetch; 019import org.eclipse.persistence.annotations.JoinFetchType; 020import org.kuali.rice.core.api.delegation.DelegationType; 021import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 022import org.springframework.util.AutoPopulatingList; 023 024import javax.persistence.CascadeType; 025import javax.persistence.Column; 026import javax.persistence.Entity; 027import javax.persistence.GeneratedValue; 028import javax.persistence.Id; 029import javax.persistence.JoinColumn; 030import javax.persistence.JoinColumns; 031import javax.persistence.OneToMany; 032import javax.persistence.Table; 033import javax.persistence.Transient; 034import java.util.List; 035 036/** 037 * This is a description of what this class does - kellerj don't forget to fill this in. 038 * 039 * @author Kuali Rice Team (kuali-rice@googleroles.com) 040 * 041 */ 042@Entity 043@Table(name = "KRIM_PND_DLGN_T") 044public class RoleDocumentDelegation extends KimDocumentBoActivatableBase { 045 046 private static final long serialVersionUID = 1L; 047 048 @PortableSequenceGenerator(name = "KRIM_DLGN_ID_S") 049 @GeneratedValue(generator = "KRIM_DLGN_ID_S") 050 @Id 051 @Column(name = "DLGN_ID") 052 protected String delegationId; 053 054 @Column(name = "ROLE_ID") 055 protected String roleId; 056 057 @Column(name = "KIM_TYP_ID") 058 protected String kimTypeId; 059 060 @Column(name = "DLGN_TYP_CD") 061 protected String delegationTypeCode; 062 063 @JoinFetch(value= JoinFetchType.OUTER) 064 @OneToMany(targetEntity = RoleDocumentDelegationMember.class, orphanRemoval = true, cascade = CascadeType.ALL) 065 @JoinColumns({ 066 @JoinColumn(name = "FDOC_NBR", referencedColumnName = "FDOC_NBR", insertable = false, updatable = false), 067 @JoinColumn(name = "DLGN_ID", referencedColumnName = "DLGN_ID", insertable = false, updatable = false) }) 068 private List<RoleDocumentDelegationMember> members = new AutoPopulatingList<RoleDocumentDelegationMember>(RoleDocumentDelegationMember.class); 069 070 @Transient 071 private RoleDocumentDelegationMember member = new RoleDocumentDelegationMember(); 072 073 @Transient 074 protected List<KimDocumentRoleQualifier> qualifiers = new AutoPopulatingList<KimDocumentRoleQualifier>(KimDocumentRoleQualifier.class); 075 076 public String getRoleId() { 077 return this.roleId; 078 } 079 080 public void setRoleId(String roleId) { 081 this.roleId = roleId; 082 } 083 084 public String getKimTypeId() { 085 return this.kimTypeId; 086 } 087 088 public void setKimTypeId(String typeId) { 089 this.kimTypeId = typeId; 090 } 091 092 public String getDelegationTypeCode() { 093 return this.delegationTypeCode; 094 } 095 096 public void setDelegationTypeCode(String delegationTypeCode) { 097 this.delegationTypeCode = delegationTypeCode; 098 } 099 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}