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 */
016package org.kuali.rice.kim.bo.ui;
017
018import java.util.List;
019
020import javax.persistence.CascadeType;
021import javax.persistence.Column;
022import javax.persistence.Entity;
023import javax.persistence.GeneratedValue;
024import javax.persistence.Id;
025import javax.persistence.JoinColumn;
026import javax.persistence.JoinColumns;
027import javax.persistence.OneToMany;
028import javax.persistence.Table;
029import javax.persistence.Transient;
030
031import org.kuali.rice.core.api.delegation.DelegationType;
032import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
033import org.springframework.util.AutoPopulatingList;
034
035/**
036 * This is a description of what this class does - kellerj don't forget to fill this in.
037 *
038 * @author Kuali Rice Team (kuali-rice@googleroles.com)
039 *
040 */
041@Entity
042@Table(name = "KRIM_PND_DLGN_T")
043public class RoleDocumentDelegation extends KimDocumentBoActivatableBase {
044
045    private static final long serialVersionUID = 1L;
046
047    @PortableSequenceGenerator(name = "KRIM_DLGN_ID_S")
048    @GeneratedValue(generator = "KRIM_DLGN_ID_S")
049    @Id
050    @Column(name = "DLGN_ID")
051    protected String delegationId;
052
053    @Column(name = "ROLE_ID")
054    protected String roleId;
055
056    @Column(name = "KIM_TYP_ID")
057    protected String kimTypeId;
058
059    @Column(name = "DLGN_TYP_CD")
060    protected String delegationTypeCode;
061
062    @OneToMany(targetEntity = RoleDocumentDelegationMember.class, orphanRemoval = true, cascade = { CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.PERSIST })
063    @JoinColumns({ 
064        @JoinColumn(name = "FDOC_NBR", referencedColumnName = "FDOC_NBR", insertable = false, updatable = false), 
065        @JoinColumn(name = "DLGN_ID", referencedColumnName = "DLGN_ID", insertable = false, updatable = false) })
066    private List<RoleDocumentDelegationMember> members = new AutoPopulatingList<RoleDocumentDelegationMember>(RoleDocumentDelegationMember.class);
067
068    @Transient
069    private RoleDocumentDelegationMember member = new RoleDocumentDelegationMember();
070
071    @Transient
072    protected List<KimDocumentRoleQualifier> qualifiers = new AutoPopulatingList<KimDocumentRoleQualifier>(KimDocumentRoleQualifier.class);
073
074    public String getRoleId() {
075        return this.roleId;
076    }
077
078    public void setRoleId(String roleId) {
079        this.roleId = roleId;
080    }
081
082    public String getKimTypeId() {
083        return this.kimTypeId;
084    }
085
086    public void setKimTypeId(String typeId) {
087        this.kimTypeId = typeId;
088    }
089
090    public String getDelegationTypeCode() {
091        return this.delegationTypeCode;
092    }
093
094    public void setDelegationTypeCode(String delegationTypeCode) {
095        this.delegationTypeCode = delegationTypeCode;
096    }
097
098    public String getDelegationId() {
099        return this.delegationId;
100    }
101
102    public void setDelegationId(String delegationId) {
103        this.delegationId = delegationId;
104    }
105
106    /**
107         * @return the qualifiers
108         */
109    public List<KimDocumentRoleQualifier> getQualifiers() {
110        return this.qualifiers;
111    }
112
113    /**
114         * @param qualifiers the qualifiers to set
115         */
116    public void setQualifiers(List<KimDocumentRoleQualifier> qualifiers) {
117        this.qualifiers = qualifiers;
118    }
119
120    public int getNumberOfQualifiers() {
121        return qualifiers == null ? 0 : qualifiers.size();
122    }
123
124    /**
125         * @return the members
126         */
127    public List<RoleDocumentDelegationMember> getMembers() {
128        return this.members;
129    }
130
131    /**
132         * @param members the members to set
133         */
134    public void setMembers(List<RoleDocumentDelegationMember> members) {
135        this.members = members;
136    }
137
138    /**
139         * @return the member
140         */
141    public RoleDocumentDelegationMember getMember() {
142        return this.member;
143    }
144
145    /**
146         * @param member the member to set
147         */
148    public void setMember(RoleDocumentDelegationMember member) {
149        this.member = member;
150    }
151
152    public boolean isDelegationPrimary() {
153        return DelegationType.PRIMARY.getCode().equals(getDelegationTypeCode());
154    }
155
156    public boolean isDelegationSecondary() {
157        return DelegationType.SECONDARY.getCode().equals(getDelegationTypeCode());
158    }
159}