View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.bo.ui;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.persistence.CascadeType;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.GeneratedValue;
25  import javax.persistence.Id;
26  import javax.persistence.JoinColumn;
27  import javax.persistence.JoinColumns;
28  import javax.persistence.ManyToOne;
29  import javax.persistence.OneToMany;
30  import javax.persistence.Table;
31  import javax.persistence.Transient;
32  
33  import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
34  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
35  
36  /**
37   * This is a description of what this class does - shyu don't forget to fill this in. 
38   * 
39   * @author Kuali Rice Team (rice.collab@kuali.org)
40   *
41   */
42  @Entity
43  @Table(name = "KRIM_PND_AFLTN_MT")
44  public class PersonDocumentAffiliation extends PersonDocumentBoDefaultBase {
45  
46      private static final long serialVersionUID = 1L;
47  
48      @PortableSequenceGenerator(name = "KRIM_ENTITY_AFLTN_ID_S")
49      @GeneratedValue(generator = "KRIM_ENTITY_AFLTN_ID_S")
50      @Id
51      @Column(name = "ENTITY_AFLTN_ID")
52      protected String entityAffiliationId;
53  
54      @Column(name = "AFLTN_TYP_CD")
55      protected String affiliationTypeCode;
56  
57      @Column(name = "CAMPUS_CD")
58      protected String campusCode;
59  
60      @ManyToOne(targetEntity = EntityAffiliationTypeBo.class, cascade = { CascadeType.REFRESH })
61      @JoinColumn(name = "AFLTN_TYP_CD", referencedColumnName = "AFLTN_TYP_CD", insertable = false, updatable = false)
62      protected EntityAffiliationTypeBo affiliationType;
63  
64      @Transient
65      protected PersonDocumentEmploymentInfo newEmpInfo;
66  
67      @OneToMany(targetEntity = PersonDocumentEmploymentInfo.class, cascade = { CascadeType.REFRESH, CascadeType.PERSIST })
68      @JoinColumns({ 
69          @JoinColumn(name = "FDOC_NBR", referencedColumnName = "FDOC_NBR", insertable = false, updatable = false), 
70          @JoinColumn(name = "ENTITY_AFLTN_ID", referencedColumnName = "ENTITY_AFLTN_ID", insertable = false, updatable = false) })
71      protected List<PersonDocumentEmploymentInfo> empInfos;
72  
73      public PersonDocumentAffiliation() {
74          empInfos = new ArrayList<PersonDocumentEmploymentInfo>();
75          setNewEmpInfo(new PersonDocumentEmploymentInfo());
76      }
77  
78      /**
79  	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getAffiliationTypeCode()
80  	 */
81      public String getAffiliationTypeCode() {
82          if (affiliationTypeCode == null) {
83              return "";
84          }
85          return affiliationTypeCode;
86      }
87  
88      /**
89  	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getCampusCode()
90  	 */
91      public String getCampusCode() {
92          return campusCode;
93      }
94  
95      /**
96  	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getEntityAffiliationId()
97  	 */
98      public String getEntityAffiliationId() {
99          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 }