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