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.core.entity.Amount;
40  import org.kuali.student.core.entity.AttributeOwner;
41  import org.kuali.student.core.entity.TimeAmount;
42  import org.kuali.student.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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.core.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  })
100 public class Clu extends VersionEntity implements AttributeOwner<CluAttribute> {
101 
102     @OneToOne(cascade=CascadeType.ALL)
103     @JoinColumn(name = "OFFIC_CLU_ID")
104     private CluIdentifier officialIdentifier;
105     
106     @OneToMany(cascade=CascadeType.ALL)
107     @JoinTable(name = "KSLU_CLU_JN_CLU_IDENT", joinColumns = @JoinColumn(name = "CLU_ID"), inverseJoinColumns = @JoinColumn(name = "ALT_CLU_ID"))
108     private List<CluIdentifier> alternateIdentifiers;
109 
110     @Column(name = "STDY_SUBJ_AREA")
111     private String studySubjectArea;
112     
113     @ManyToOne(cascade=CascadeType.ALL)
114     @JoinColumn(name = "RT_DESCR_ID")
115     private LuRichText descr;
116 
117     @OneToMany(cascade=CascadeType.ALL, mappedBy = "clu")
118     private List<CluCampusLocation> campusLocations;
119     
120     @OneToMany(cascade=CascadeType.ALL)
121     @JoinTable(name = "KSLU_CLU_JN_ACCRED", joinColumns = @JoinColumn(name = "CLU_ID"), inverseJoinColumns = @JoinColumn(name = "CLU_ACCRED_ID"))
122     private List<CluAccreditation> accreditations;
123     
124     @OneToMany(cascade = CascadeType.ALL, mappedBy = "clu")
125     private List<CluAdminOrg> adminOrgs;
126     
127     @ManyToOne(cascade=CascadeType.ALL)
128     @JoinColumn(name="PRI_INSTR_ID")
129     private CluInstructor primaryInstructor;
130     
131     @OneToMany(cascade=CascadeType.ALL)
132     @JoinTable(name = "KSLU_CLU_JN_CLU_INSTR", joinColumns = @JoinColumn(name = "CLU_ID"), inverseJoinColumns = @JoinColumn(name = "CLU_INSTR_ID"))
133     private List<CluInstructor> instructors;
134         
135     @Column(name = "EXP_FIRST_ATP")
136     private String expectedFirstAtp;
137 
138     @Column(name = "LAST_ATP")
139     private String lastAtp;
140 
141     @Column(name = "LAST_ADMIT_ATP")
142     private String lastAdmitAtp;
143     
144     @Temporal(TemporalType.TIMESTAMP)
145     @Column(name = "EFF_DT")
146     private Date effectiveDate;
147 
148     @Temporal(TemporalType.TIMESTAMP)
149     @Column(name = "EXPIR_DT")
150     private Date expirationDate;
151 
152     @Embedded
153     @AttributeOverrides({
154         @AttributeOverride(name="unitType", column=@Column(name="CLU_INTSTY_TYPE")),
155         @AttributeOverride(name="unitQuantity", column=@Column(name="CLU_INTSTY_QTY")
156         )})
157      private Amount intensity;
158 
159     @Embedded
160     @Column(name = "STD_DUR")
161     private TimeAmount stdDuration;
162     
163     @Column(name = "CAN_CREATE_LUI")
164     private boolean canCreateLui;
165 
166     @Column(name = "REF_URL")
167     private String referenceURL;
168 
169     @OneToMany(cascade = CascadeType.ALL, mappedBy="clu")
170     private List<LuCode> luCodes;
171         
172     @Column(name = "NEXT_REVIEW_PRD")
173     private String nextReviewPeriod;
174 
175     @Column(name = "IS_ENRL")
176     private boolean enrollable;
177     
178     @OneToMany(cascade=CascadeType.ALL, mappedBy="clu")
179     private List<CluAtpTypeKey> offeredAtpTypes;
180     
181     @Column(name = "HAS_EARLY_DROP_DEDLN")
182     private boolean hasEarlyDropDeadline;
183 
184     @Column(name = "DEF_ENRL_EST")
185     private int defaultEnrollmentEstimate;
186 
187     @Column(name = "DEF_MAX_ENRL")
188     private int defaultMaximumEnrollment;
189 
190     @Column(name = "IS_HAZR_DISBLD_STU")
191     private boolean hazardousForDisabledStudents;
192 
193     @OneToOne(cascade=CascadeType.ALL)
194     @JoinColumn(name = "FEE_ID")
195     private CluFee fee;
196     
197     @OneToOne(cascade=CascadeType.ALL)
198     @JoinColumn(name = "ACCT_ID")
199     private CluAccounting accounting;
200     
201     @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
202     private List<CluAttribute> attributes;
203 
204     @ManyToOne
205     @JoinColumn(name = "LUTYPE_ID")
206     private LuType luType;
207     
208     @Column(name = "ST")
209     private String state;
210     
211     public LuType getLuType() {
212         return luType;
213     }
214 
215     public void setLuType(LuType luType) {
216         this.luType = luType;
217     }
218 
219     @Override
220     public List<CluAttribute> getAttributes() {
221         return attributes;
222     }
223 
224     @Override
225     public void setAttributes(List<CluAttribute> attributes) {
226         this.attributes = attributes;
227     }
228 
229     public CluIdentifier getOfficialIdentifier() {
230         return officialIdentifier;
231     }
232 
233     public void setOfficialIdentifier(CluIdentifier officialIdentifier) {
234         this.officialIdentifier = officialIdentifier;
235     }
236 
237     public List<CluIdentifier> getAlternateIdentifiers() {
238         return alternateIdentifiers;
239     }
240 
241     public void setAlternateIdentifiers(List<CluIdentifier> alternateIdentifiers) {
242         this.alternateIdentifiers = alternateIdentifiers;
243     }
244 
245     public String getStudySubjectArea() {
246         return studySubjectArea;
247     }
248 
249     public void setStudySubjectArea(String studySubjectArea) {
250         this.studySubjectArea = studySubjectArea;
251     }
252 
253     public LuRichText getDescr() {
254         return descr;
255     }
256 
257     public void setDescr(LuRichText descr) {
258         this.descr = descr;
259     }
260 
261     public List<CluInstructor> getInstructors() {
262         return instructors;
263     }
264 
265     public void setInstructors(List<CluInstructor> instructors) {
266         this.instructors = instructors;
267     }
268 
269     public Date getEffectiveDate() {
270         return effectiveDate;
271     }
272 
273     public void setEffectiveDate(Date effectiveDate) {
274         this.effectiveDate = effectiveDate;
275     }
276 
277     public Date getExpirationDate() {
278         return expirationDate;
279     }
280 
281     public void setExpirationDate(Date expirationDate) {
282         this.expirationDate = expirationDate;
283     }
284 
285     public TimeAmount getStdDuration() {
286         return stdDuration;
287     }
288 
289     public void setStdDuration(TimeAmount stdDuration) {
290         this.stdDuration = stdDuration;
291     }
292 
293     public boolean isCanCreateLui() {
294         return canCreateLui;
295     }
296 
297     public void setCanCreateLui(boolean canCreateLui) {
298         this.canCreateLui = canCreateLui;
299     }
300 
301     public String getReferenceURL() {
302         return referenceURL;
303     }
304 
305     public void setReferenceURL(String referenceURL) {
306         this.referenceURL = referenceURL;
307     }
308 
309     public List<LuCode> getLuCodes() {
310         return luCodes;
311     }
312 
313     public void setLuCodes(List<LuCode> luCodes) {
314         this.luCodes = luCodes;
315     }
316 
317      public String getNextReviewPeriod() {
318          return nextReviewPeriod;
319      }
320 
321      public void setNextReviewPeriod(String nextReviewPeriod) {
322          this.nextReviewPeriod = nextReviewPeriod;
323      }
324 
325      public boolean isEnrollable() {
326          return enrollable;
327      }
328 
329      public void setEnrollable(boolean enrollable) {
330          this.enrollable = enrollable;
331      }
332 
333      public List<CluAtpTypeKey> getOfferedAtpTypes() {
334          return offeredAtpTypes;
335      }
336 
337      public void setOfferedAtpTypes(List<CluAtpTypeKey> offeredAtpTypes) {
338          this.offeredAtpTypes = offeredAtpTypes;
339      }
340 
341      public boolean isHasEarlyDropDeadline() {
342          return hasEarlyDropDeadline;
343      }
344 
345      public void setHasEarlyDropDeadline(boolean hasEarlyDropDeadline) {
346          this.hasEarlyDropDeadline = hasEarlyDropDeadline;
347      }
348 
349      public int getDefaultEnrollmentEstimate() {
350          return defaultEnrollmentEstimate;
351      }
352 
353      public void setDefaultEnrollmentEstimate(int defaultEnrollmentEstimate) {
354          this.defaultEnrollmentEstimate = defaultEnrollmentEstimate;
355      }
356 
357      public int getDefaultMaximumEnrollment() {
358          return defaultMaximumEnrollment;
359      }
360 
361      public void setDefaultMaximumEnrollment(int defaultMaximumEnrollment) {
362          this.defaultMaximumEnrollment = defaultMaximumEnrollment;
363      }
364 
365      public boolean isHazardousForDisabledStudents() {
366          return hazardousForDisabledStudents;
367      }
368 
369      public void setHazardousForDisabledStudents(
370              boolean hazardousForDisabledStudents) {
371          this.hazardousForDisabledStudents = hazardousForDisabledStudents;
372      }
373 
374      public CluFee getFee() {
375          return fee;
376      }
377 
378      public void setFee(CluFee fee) {
379          this.fee = fee;
380      }
381 
382      public CluAccounting getAccounting() {
383          return accounting;
384      }
385 
386      public void setAccounting(CluAccounting accounting) {
387          this.accounting = accounting;
388      }
389 
390      public String getState() {
391          return state;
392      }
393 
394      public void setState(String state) {
395          this.state = state;
396      }
397 
398       public CluInstructor getPrimaryInstructor() {
399           return primaryInstructor;
400       }
401 
402       public void setPrimaryInstructor(CluInstructor primaryInstructor) {
403           this.primaryInstructor = primaryInstructor;
404       }
405 
406       public List<CluCampusLocation> getCampusLocations() {
407           return campusLocations;
408       }
409 
410       public void setCampusLocations(List<CluCampusLocation> campusLocationList) {
411           this.campusLocations = campusLocationList;
412       }
413 
414       public Amount getIntensity() {
415           return intensity;
416       }
417 
418       public void setIntensity(Amount intensity) {
419           this.intensity = intensity;
420       }
421 
422       public List<CluAccreditation> getAccreditations() {
423           return accreditations;
424       }
425 
426       public void setAccreditations(List<CluAccreditation> accreditations) {
427           this.accreditations = accreditations;
428       }
429 
430 
431       public List<CluAdminOrg> getAdminOrgs() {
432           return adminOrgs;
433       }
434 
435       public void setAdminOrgs(List<CluAdminOrg> adminOrgs) {
436           this.adminOrgs = adminOrgs;
437       }
438 
439 	public String getExpectedFirstAtp() {
440 		return expectedFirstAtp;
441 	}
442 
443 	public void setExpectedFirstAtp(String expectedFirstAtp) {
444 		this.expectedFirstAtp = expectedFirstAtp;
445 	}      
446 
447 	public String getLastAtp() {
448 		return lastAtp;
449 }
450 
451 	public void setLastAtp(String lastAtp) {
452 		this.lastAtp = lastAtp;
453 	}
454 
455     public String getLastAdmitAtp() {
456         return lastAdmitAtp;
457     }
458 
459     public void setLastAdmitAtp(String lastAdmitAtp) {
460         this.lastAdmitAtp = lastAdmitAtp;
461     }
462 }