View Javadoc

1   /**
2    * Copyright 2005-2011 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 org.hibernate.annotations.Fetch;
19  import org.hibernate.annotations.FetchMode;
20  import org.hibernate.annotations.GenericGenerator;
21  import org.hibernate.annotations.Parameter;
22  import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
23  import org.kuali.rice.krad.util.ObjectUtils;
24  
25  import javax.persistence.CascadeType;
26  import javax.persistence.Column;
27  import javax.persistence.Entity;
28  import javax.persistence.FetchType;
29  import javax.persistence.GeneratedValue;
30  import javax.persistence.Id;
31  import javax.persistence.IdClass;
32  import javax.persistence.JoinColumn;
33  import javax.persistence.JoinColumns;
34  import javax.persistence.ManyToOne;
35  import javax.persistence.OneToMany;
36  import javax.persistence.Table;
37  import javax.persistence.Transient;
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * This is a description of what this class does - shyu don't forget to fill this in. 
43   * 
44   * @author Kuali Rice Team (rice.collab@kuali.org)
45   *
46   */
47  @IdClass(PersonDocumentAffiliationId.class)
48  @Entity
49  @Table(name = "KRIM_PND_AFLTN_MT")
50  public class PersonDocumentAffiliation extends PersonDocumentBoDefaultBase {
51  	private static final long serialVersionUID = 1L;
52  
53  	@Id
54  	@GeneratedValue(generator="KRIM_ENTITY_AFLTN_ID_S")
55  	@GenericGenerator(name="KRIM_ENTITY_AFLTN_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
56  			@Parameter(name="sequence_name",value="KRIM_ENTITY_AFLTN_ID_S"),
57  			@Parameter(name="value_column",value="id")
58  		})
59  	@Column(name = "ENTITY_AFLTN_ID")
60  	protected String entityAffiliationId;
61  
62  	@Column(name = "AFLTN_TYP_CD")
63  	protected String affiliationTypeCode;
64  
65  	@Column(name = "CAMPUS_CD")
66  	protected String campusCode;
67  
68  	@ManyToOne(targetEntity=EntityAffiliationTypeBo.class, fetch = FetchType.EAGER, cascade = {})
69  	@JoinColumn(name = "AFLTN_TYP_CD", insertable = false, updatable = false)
70  	protected EntityAffiliationTypeBo affiliationType;
71  	@Transient
72  	protected PersonDocumentEmploymentInfo newEmpInfo;
73  
74  	@OneToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.EAGER)
75  	//@JoinColumn(name="ENTITY_AFLTN_ID", insertable=false, updatable=false)
76  	@Fetch(value = FetchMode.SELECT)
77  	@JoinColumns({
78  		@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false),
79  		@JoinColumn(name="ENTITY_AFLTN_ID", insertable=false, updatable=false)
80  	})
81  	protected List<PersonDocumentEmploymentInfo> empInfos;
82  
83  	public PersonDocumentAffiliation() {
84  		empInfos = new ArrayList<PersonDocumentEmploymentInfo>();
85  		setNewEmpInfo(new PersonDocumentEmploymentInfo());
86  		this.active = true;
87  	}
88  
89  	/**
90  	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getAffiliationTypeCode()
91  	 */
92  	public String getAffiliationTypeCode() {
93  		if(ObjectUtils.isNull(affiliationTypeCode))
94  			return "";
95  		return affiliationTypeCode;
96  	}
97  
98  	/**
99  	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getCampusCode()
100 	 */
101 	public String getCampusCode() {
102 		return campusCode;
103 	}
104 
105 	/**
106 	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#getEntityAffiliationId()
107 	 */
108 	public String getEntityAffiliationId() {
109 		if(ObjectUtils.isNull(entityAffiliationId))
110 			return "";
111 		return entityAffiliationId;
112 	}
113 
114 	/**
115 	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#setAffiliationTypeCode(java.lang.String)
116 	 */
117 	public void setAffiliationTypeCode(String affiliationTypeCode) {
118 		this.affiliationTypeCode = affiliationTypeCode;
119 	}
120 
121 	/**
122 	 * @see org.kuali.rice.kim.api.identity.EntityAffiliationContract#setCampusCode(java.lang.String)
123 	 */
124 	public void setCampusCode(String campusCode) {
125 		this.campusCode = campusCode;
126 	}
127 
128 	public void setEntityAffiliationId(String entityAffiliationId) {
129 		this.entityAffiliationId = entityAffiliationId;
130 	}
131 
132 	public PersonDocumentEmploymentInfo getNewEmpInfo() {
133 		return this.newEmpInfo;
134 	}
135 
136 	public void setNewEmpInfo(PersonDocumentEmploymentInfo newEmpInfo) {
137 		this.newEmpInfo = newEmpInfo;
138 	}
139 
140 	public List<PersonDocumentEmploymentInfo> getEmpInfos() {
141 		return this.empInfos;
142 	}
143 
144 	public void setEmpInfos(List<PersonDocumentEmploymentInfo> empInfos) {
145 		this.empInfos = empInfos;
146 	}
147 
148 	public EntityAffiliationTypeBo getAffiliationType() {
149 		if(ObjectUtils.isNull(affiliationType))
150 			return null;
151 		return this.affiliationType;
152 	}
153 
154 	public boolean isEmploymentAffiliationType() {
155 		if(ObjectUtils.isNull(affiliationType))
156 			return false;
157 		return this.affiliationType.isEmploymentAffiliationType();
158 	}
159 	 
160 	public void setAffiliationType(EntityAffiliationTypeBo affiliationType) {
161 		this.affiliationType = affiliationType;
162 	}
163 
164 }