View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.lum.lu.entity;
17  
18  import java.util.Date;
19  import java.util.List;
20  
21  import javax.persistence.AttributeOverride;
22  import javax.persistence.AttributeOverrides;
23  import javax.persistence.CascadeType;
24  import javax.persistence.Column;
25  import javax.persistence.Embedded;
26  import javax.persistence.Entity;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.JoinTable;
29  import javax.persistence.ManyToOne;
30  import javax.persistence.NamedQueries;
31  import javax.persistence.NamedQuery;
32  import javax.persistence.OneToMany;
33  import javax.persistence.OneToOne;
34  import javax.persistence.Table;
35  import javax.persistence.Temporal;
36  import javax.persistence.TemporalType;
37  import javax.persistence.UniqueConstraint;
38  
39  import org.kuali.student.common.entity.Amount;
40  import org.kuali.student.common.entity.AttributeOwner;
41  import org.kuali.student.common.entity.TimeAmount;
42  import org.kuali.student.common.entity.VersionEntity;
43  
44  @Entity
45  @Table(name = "KSLU_CLU", uniqueConstraints={@UniqueConstraint(columnNames={"VER_IND_ID", "SEQ_NUM"})} )
46  @NamedQueries( {
47  	//FIXME dates should be either set from the DB time as part of the insert statement, or set from the application.
48  	//DB timestamp (CURRENT_TIMESTAMP) is preferred
49      @NamedQuery(name = "Clu.findCurrentVersionInfo", query = "SELECT " +
50      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
51      		"FROM Clu c " +
52      		"WHERE c.version.versionIndId = :versionIndId " +
53      		"AND c.version.currentVersionStart <= :currentTime AND (c.version.currentVersionEnd > :currentTime OR c.version.currentVersionEnd IS NULL)"),
54  	@NamedQuery(name = "Clu.findCurrentVersionOnDate", query = "SELECT " +
55      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
56      		"FROM Clu c " +
57      		"WHERE c.version.versionIndId = :versionIndId " +
58      		"AND c.version.currentVersionStart <= :date AND (c.version.currentVersionEnd > :date OR c.version.currentVersionEnd IS NULL)"),
59  	@NamedQuery(name = "Clu.findFirstVersion", query = "SELECT " +
60      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
61      		"FROM Clu c " +
62      		"WHERE c.version.versionIndId = :versionIndId " +
63      		"AND c.version.sequenceNumber IN (SELECT MIN(nc.version.sequenceNumber) FROM Clu nc WHERE nc.version.versionIndId = :versionIndId)"),
64      @NamedQuery(name = "Clu.findLatestVersion", query = "SELECT " +
65   	    	"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
66      	    "FROM Clu c " +
67      	    "WHERE c.version.versionIndId = :versionIndId " +
68      	    "AND c.version.sequenceNumber IN (SELECT MAX(nc.version.sequenceNumber) FROM Clu nc WHERE nc.version.versionIndId = :versionIndId)"),
69      @NamedQuery(name = "Clu.findVersionBySequence", query = "SELECT " +
70      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
71      		"FROM Clu c " +
72      		"WHERE c.version.versionIndId = :versionIndId " +
73      		"AND c.version.sequenceNumber = :sequenceNumber"),
74  	@NamedQuery(name = "Clu.findVersions", query = "SELECT " +
75      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
76      		"FROM Clu c " +
77      		"WHERE c.version.versionIndId = :versionIndId"),
78  	@NamedQuery(name = "Clu.findVersionsInDateRange", query = "SELECT " +
79      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
80      		"FROM Clu c " +
81      		"WHERE c.version.versionIndId = :versionIndId " +
82      		"AND ( (c.version.currentVersionStart >= :from AND c.version.currentVersionStart < :to)" +
83      		"   OR (c.version.currentVersionStart < :from AND c.version.currentVersionEnd > :from) )"),
84  	@NamedQuery(name = "Clu.findVersionsBeforeDate", query = "SELECT " +
85      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
86      		"FROM Clu c " +
87      		"WHERE c.version.versionIndId = :versionIndId " +
88      		"AND c.version.currentVersionStart <= :date"),
89  	@NamedQuery(name = "Clu.findVersionsAfterDate", query = "SELECT " +
90      		"NEW org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo(c.id, c.version.versionIndId, c.version.sequenceNumber, c.version.currentVersionStart, c.version.currentVersionEnd, c.version.versionComment, c.version.versionedFromId) " +
91      		"FROM Clu c " +
92      		"WHERE c.version.versionIndId = :versionIndId " +
93      		"AND c.version.currentVersionStart >= :date"),
94      @NamedQuery(name = "Clu.findLatestClu", query = "SELECT c FROM Clu c WHERE c.version.versionIndId = :versionIndId AND c.version.sequenceNumber IN (SELECT MAX(nc.version.sequenceNumber) FROM Clu nc WHERE nc.version.versionIndId = :versionIndId)"),
95      @NamedQuery(name = "Clu.findCurrentClu", query = "SELECT c FROM Clu c WHERE c.version.versionIndId = :versionIndId AND c.version.currentVersionStart <= :currentTime AND (c.version.currentVersionEnd > :currentTime OR c.version.currentVersionEnd IS NULL)"),
96      @NamedQuery(name = "Clu.findClusByIdList", query = "SELECT c FROM Clu c WHERE c.id IN (:idList)"),
97      @NamedQuery(name = "Clu.getClusByLuType", query = "SELECT c FROM Clu c WHERE c.state = :luState AND c.luType.id = :luTypeKey"),
98      @NamedQuery(name = "Clu.getClusByRelation", query = "SELECT c FROM Clu c WHERE c.id IN (SELECT ccr.relatedClu.id FROM CluCluRelation ccr WHERE ccr.clu.id = :parentCluId AND ccr.luLuRelationType.id = :luLuRelationTypeKey)"),
99      @NamedQuery(name = "Clu.getCrossListedClusByCodes", query = "SELECT c FROM Clu c WHERE c.state='Active' AND c.officialIdentifier.code IN (:crossListedCodes) ")
100    
101 })
102 public class Clu extends VersionEntity implements AttributeOwner<CluAttribute> {
103 
104     @OneToOne(cascade=CascadeType.ALL)
105     @JoinColumn(name = "OFFIC_CLU_ID")
106     private CluIdentifier officialIdentifier;
107     
108     @OneToMany(cascade=CascadeType.ALL)
109     @JoinTable(name = "KSLU_CLU_JN_CLU_IDENT", joinColumns = @JoinColumn(name = "CLU_ID"), inverseJoinColumns = @JoinColumn(name = "ALT_CLU_ID"))
110     private List<CluIdentifier> alternateIdentifiers;
111 
112     @Column(name = "STDY_SUBJ_AREA")
113     private String studySubjectArea;
114     
115     @ManyToOne(cascade=CascadeType.ALL)
116     @JoinColumn(name = "RT_DESCR_ID")
117     private LuRichText descr;
118 
119     @OneToMany(cascade=CascadeType.ALL, mappedBy = "clu")
120     private List<CluCampusLocation> campusLocations;
121     
122     @OneToMany(cascade=CascadeType.ALL)
123     @JoinTable(name = "KSLU_CLU_JN_ACCRED", joinColumns = @JoinColumn(name = "CLU_ID"), inverseJoinColumns = @JoinColumn(name = "CLU_ACCRED_ID"))
124     private List<CluAccreditation> accreditations;
125     
126     @OneToMany(cascade = CascadeType.ALL, mappedBy = "clu")
127     private List<CluAdminOrg> adminOrgs;
128     
129     @ManyToOne(cascade=CascadeType.ALL)
130     @JoinColumn(name="PRI_INSTR_ID")
131     private CluInstructor primaryInstructor;
132     
133     @OneToMany(cascade=CascadeType.ALL)
134     @JoinTable(name = "KSLU_CLU_JN_CLU_INSTR", joinColumns = @JoinColumn(name = "CLU_ID"), inverseJoinColumns = @JoinColumn(name = "CLU_INSTR_ID"))
135     private List<CluInstructor> instructors;
136         
137     @Column(name = "EXP_FIRST_ATP")
138     private String expectedFirstAtp;
139 
140     @Column(name = "LAST_ATP")
141     private String lastAtp;
142 
143     @Column(name = "LAST_ADMIT_ATP")
144     private String lastAdmitAtp;
145     
146     @Temporal(TemporalType.TIMESTAMP)
147     @Column(name = "EFF_DT")
148     private Date effectiveDate;
149 
150     @Temporal(TemporalType.TIMESTAMP)
151     @Column(name = "EXPIR_DT")
152     private Date expirationDate;
153 
154     @Embedded
155     @AttributeOverrides({
156         @AttributeOverride(name="unitType", column=@Column(name="CLU_INTSTY_TYPE")),
157         @AttributeOverride(name="unitQuantity", column=@Column(name="CLU_INTSTY_QTY")
158         )})
159      private Amount intensity;
160 
161     @Embedded
162     @Column(name = "STD_DUR")
163     private TimeAmount stdDuration;
164     
165     @Column(name = "CAN_CREATE_LUI")
166     private boolean canCreateLui;
167 
168     @Column(name = "REF_URL")
169     private String referenceURL;
170 
171     @OneToMany(cascade = CascadeType.ALL, mappedBy="clu")
172     private List<LuCode> luCodes;
173         
174     @Column(name = "NEXT_REVIEW_PRD")
175     private String nextReviewPeriod;
176 
177     @Column(name = "IS_ENRL")
178     private boolean enrollable;
179     
180     @OneToMany(cascade=CascadeType.ALL, mappedBy="clu")
181     private List<CluAtpTypeKey> offeredAtpTypes;
182     
183     @Column(name = "HAS_EARLY_DROP_DEDLN")
184     private boolean hasEarlyDropDeadline;
185 
186     @Column(name = "DEF_ENRL_EST")
187     private int defaultEnrollmentEstimate;
188 
189     @Column(name = "DEF_MAX_ENRL")
190     private int defaultMaximumEnrollment;
191 
192     @Column(name = "IS_HAZR_DISBLD_STU")
193     private boolean hazardousForDisabledStudents;
194 
195     @OneToOne(cascade=CascadeType.ALL)
196     @JoinColumn(name = "FEE_ID")
197     private CluFee fee;
198     
199     @OneToOne(cascade=CascadeType.ALL)
200     @JoinColumn(name = "ACCT_ID")
201     private CluAccounting accounting;
202     
203     @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
204     private List<CluAttribute> attributes;
205 
206     @ManyToOne
207     @JoinColumn(name = "LUTYPE_ID")
208     private LuType luType;
209     
210     @Column(name = "ST")
211     private String state;
212     
213     public LuType getLuType() {
214         return luType;
215     }
216 
217     public void setLuType(LuType luType) {
218         this.luType = luType;
219     }
220 
221     @Override
222     public List<CluAttribute> getAttributes() {
223         return attributes;
224     }
225 
226     @Override
227     public void setAttributes(List<CluAttribute> attributes) {
228         this.attributes = attributes;
229     }
230 
231     public CluIdentifier getOfficialIdentifier() {
232         return officialIdentifier;
233     }
234 
235     public void setOfficialIdentifier(CluIdentifier officialIdentifier) {
236         this.officialIdentifier = officialIdentifier;
237     }
238 
239     public List<CluIdentifier> getAlternateIdentifiers() {
240         return alternateIdentifiers;
241     }
242 
243     public void setAlternateIdentifiers(List<CluIdentifier> alternateIdentifiers) {
244         this.alternateIdentifiers = alternateIdentifiers;
245     }
246 
247     public String getStudySubjectArea() {
248         return studySubjectArea;
249     }
250 
251     public void setStudySubjectArea(String studySubjectArea) {
252         this.studySubjectArea = studySubjectArea;
253     }
254 
255     public LuRichText getDescr() {
256         return descr;
257     }
258 
259     public void setDescr(LuRichText descr) {
260         this.descr = descr;
261     }
262 
263     public List<CluInstructor> getInstructors() {
264         return instructors;
265     }
266 
267     public void setInstructors(List<CluInstructor> instructors) {
268         this.instructors = instructors;
269     }
270 
271     public Date getEffectiveDate() {
272         return effectiveDate;
273     }
274 
275     public void setEffectiveDate(Date effectiveDate) {
276         this.effectiveDate = effectiveDate;
277     }
278 
279     public Date getExpirationDate() {
280         return expirationDate;
281     }
282 
283     public void setExpirationDate(Date expirationDate) {
284         this.expirationDate = expirationDate;
285     }
286 
287     public TimeAmount getStdDuration() {
288         return stdDuration;
289     }
290 
291     public void setStdDuration(TimeAmount stdDuration) {
292         this.stdDuration = stdDuration;
293     }
294 
295     public boolean isCanCreateLui() {
296         return canCreateLui;
297     }
298 
299     public void setCanCreateLui(boolean canCreateLui) {
300         this.canCreateLui = canCreateLui;
301     }
302 
303     public String getReferenceURL() {
304         return referenceURL;
305     }
306 
307     public void setReferenceURL(String referenceURL) {
308         this.referenceURL = referenceURL;
309     }
310 
311     public List<LuCode> getLuCodes() {
312         return luCodes;
313     }
314 
315     public void setLuCodes(List<LuCode> luCodes) {
316         this.luCodes = luCodes;
317     }
318 
319      public String getNextReviewPeriod() {
320          return nextReviewPeriod;
321      }
322 
323      public void setNextReviewPeriod(String nextReviewPeriod) {
324          this.nextReviewPeriod = nextReviewPeriod;
325      }
326 
327      public boolean isEnrollable() {
328          return enrollable;
329      }
330 
331      public void setEnrollable(boolean enrollable) {
332          this.enrollable = enrollable;
333      }
334 
335      public List<CluAtpTypeKey> getOfferedAtpTypes() {
336          return offeredAtpTypes;
337      }
338 
339      public void setOfferedAtpTypes(List<CluAtpTypeKey> offeredAtpTypes) {
340          this.offeredAtpTypes = offeredAtpTypes;
341      }
342 
343      public boolean isHasEarlyDropDeadline() {
344          return hasEarlyDropDeadline;
345      }
346 
347      public void setHasEarlyDropDeadline(boolean hasEarlyDropDeadline) {
348          this.hasEarlyDropDeadline = hasEarlyDropDeadline;
349      }
350 
351      public int getDefaultEnrollmentEstimate() {
352          return defaultEnrollmentEstimate;
353      }
354 
355      public void setDefaultEnrollmentEstimate(int defaultEnrollmentEstimate) {
356          this.defaultEnrollmentEstimate = defaultEnrollmentEstimate;
357      }
358 
359      public int getDefaultMaximumEnrollment() {
360          return defaultMaximumEnrollment;
361      }
362 
363      public void setDefaultMaximumEnrollment(int defaultMaximumEnrollment) {
364          this.defaultMaximumEnrollment = defaultMaximumEnrollment;
365      }
366 
367      public boolean isHazardousForDisabledStudents() {
368          return hazardousForDisabledStudents;
369      }
370 
371      public void setHazardousForDisabledStudents(
372              boolean hazardousForDisabledStudents) {
373          this.hazardousForDisabledStudents = hazardousForDisabledStudents;
374      }
375 
376      public CluFee getFee() {
377          return fee;
378      }
379 
380      public void setFee(CluFee fee) {
381          this.fee = fee;
382      }
383 
384      public CluAccounting getAccounting() {
385          return accounting;
386      }
387 
388      public void setAccounting(CluAccounting accounting) {
389          this.accounting = accounting;
390      }
391 
392      public String getState() {
393          return state;
394      }
395 
396      public void setState(String state) {
397          this.state = state;
398      }
399 
400       public CluInstructor getPrimaryInstructor() {
401           return primaryInstructor;
402       }
403 
404       public void setPrimaryInstructor(CluInstructor primaryInstructor) {
405           this.primaryInstructor = primaryInstructor;
406       }
407 
408       public List<CluCampusLocation> getCampusLocations() {
409           return campusLocations;
410       }
411 
412       public void setCampusLocations(List<CluCampusLocation> campusLocationList) {
413           this.campusLocations = campusLocationList;
414       }
415 
416       public Amount getIntensity() {
417           return intensity;
418       }
419 
420       public void setIntensity(Amount intensity) {
421           this.intensity = intensity;
422       }
423 
424       public List<CluAccreditation> getAccreditations() {
425           return accreditations;
426       }
427 
428       public void setAccreditations(List<CluAccreditation> accreditations) {
429           this.accreditations = accreditations;
430       }
431 
432 
433       public List<CluAdminOrg> getAdminOrgs() {
434           return adminOrgs;
435       }
436 
437       public void setAdminOrgs(List<CluAdminOrg> adminOrgs) {
438           this.adminOrgs = adminOrgs;
439       }
440 
441 	public String getExpectedFirstAtp() {
442 		return expectedFirstAtp;
443 	}
444 
445 	public void setExpectedFirstAtp(String expectedFirstAtp) {
446 		this.expectedFirstAtp = expectedFirstAtp;
447 	}      
448 
449 	public String getLastAtp() {
450 		return lastAtp;
451 }
452 
453 	public void setLastAtp(String lastAtp) {
454 		this.lastAtp = lastAtp;
455 	}
456 
457     public String getLastAdmitAtp() {
458         return lastAdmitAtp;
459     }
460 
461     public void setLastAdmitAtp(String lastAdmitAtp) {
462         this.lastAdmitAtp = lastAdmitAtp;
463     }
464 }