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 java.util.ArrayList;
019import java.util.List;
020
021import javax.persistence.CascadeType;
022import javax.persistence.Column;
023import javax.persistence.Entity;
024import javax.persistence.GeneratedValue;
025import javax.persistence.Id;
026import javax.persistence.JoinColumn;
027import javax.persistence.JoinColumns;
028import javax.persistence.ManyToOne;
029import javax.persistence.OneToMany;
030import javax.persistence.Table;
031import javax.persistence.Transient;
032
033import org.eclipse.persistence.annotations.JoinFetch;
034import org.eclipse.persistence.annotations.JoinFetchType;
035import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
036import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
037
038/**
039 * This is a description of what this class does - shyu don't forget to fill this in. 
040 * 
041 * @author Kuali Rice Team (rice.collab@kuali.org)
042 *
043 */
044@Entity
045@Table(name = "KRIM_PND_AFLTN_MT")
046public class PersonDocumentAffiliation extends PersonDocumentBoDefaultBase {
047
048    private static final long serialVersionUID = 1L;
049
050    @PortableSequenceGenerator(name = "KRIM_ENTITY_AFLTN_ID_S")
051    @GeneratedValue(generator = "KRIM_ENTITY_AFLTN_ID_S")
052    @Id
053    @Column(name = "ENTITY_AFLTN_ID")
054    protected String entityAffiliationId;
055
056    @Column(name = "AFLTN_TYP_CD")
057    protected String affiliationTypeCode;
058
059    @Column(name = "CAMPUS_CD")
060    protected String campusCode;
061
062    @JoinFetch(value= JoinFetchType.OUTER)
063    @ManyToOne(targetEntity = EntityAffiliationTypeBo.class, cascade = { CascadeType.REFRESH })
064    @JoinColumn(name = "AFLTN_TYP_CD", referencedColumnName = "AFLTN_TYP_CD", insertable = false, updatable = false)
065    protected EntityAffiliationTypeBo affiliationType;
066
067    @Transient
068    protected PersonDocumentEmploymentInfo newEmpInfo;
069
070    @JoinFetch(value= JoinFetchType.OUTER)
071    @OneToMany(targetEntity = PersonDocumentEmploymentInfo.class, cascade = { CascadeType.REFRESH, CascadeType.PERSIST })
072    @JoinColumns({ 
073        @JoinColumn(name = "FDOC_NBR", referencedColumnName = "FDOC_NBR", insertable = false, updatable = false), 
074        @JoinColumn(name = "ENTITY_AFLTN_ID", referencedColumnName = "ENTITY_AFLTN_ID", insertable = false, updatable = false) })
075    protected List<PersonDocumentEmploymentInfo> empInfos;
076
077    public PersonDocumentAffiliation() {
078        empInfos = new ArrayList<PersonDocumentEmploymentInfo>();
079        setNewEmpInfo(new PersonDocumentEmploymentInfo());
080    }
081
082    /**
083         * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getAffiliationTypeCode()
084         */
085    public String getAffiliationTypeCode() {
086        if (affiliationTypeCode == null) {
087            return "";
088        }
089        return affiliationTypeCode;
090    }
091
092    /**
093         * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getCampusCode()
094         */
095    public String getCampusCode() {
096        return campusCode;
097    }
098
099    /**
100         * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getEntityAffiliationId()
101         */
102    public String getEntityAffiliationId() {
103        if (entityAffiliationId == null) {
104            return "";
105        }
106        return entityAffiliationId;
107    }
108
109    /**
110         * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#setAffiliationTypeCode(java.lang.String)
111         */
112    public void setAffiliationTypeCode(String affiliationTypeCode) {
113        this.affiliationTypeCode = affiliationTypeCode;
114    }
115
116    /**
117         * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#setCampusCode(java.lang.String)
118         */
119    public void setCampusCode(String campusCode) {
120        this.campusCode = campusCode;
121    }
122
123    public void setEntityAffiliationId(String entityAffiliationId) {
124        this.entityAffiliationId = entityAffiliationId;
125    }
126
127    public PersonDocumentEmploymentInfo getNewEmpInfo() {
128        return this.newEmpInfo;
129    }
130
131    public void setNewEmpInfo(PersonDocumentEmploymentInfo newEmpInfo) {
132        this.newEmpInfo = newEmpInfo;
133    }
134
135    public List<PersonDocumentEmploymentInfo> getEmpInfos() {
136        return this.empInfos;
137    }
138
139    public void setEmpInfos(List<PersonDocumentEmploymentInfo> empInfos) {
140        this.empInfos = empInfos;
141    }
142
143    public EntityAffiliationTypeBo getAffiliationType() {
144        return this.affiliationType;
145    }
146
147    public boolean isEmploymentAffiliationType() {
148        if (affiliationType == null) {
149            return false;
150        }
151        return this.affiliationType.isEmploymentAffiliationType();
152    }
153
154    public void setAffiliationType(EntityAffiliationTypeBo affiliationType) {
155        this.affiliationType = affiliationType;
156    }
157}