001package org.kuali.mobility.library.entity; 002 003import java.util.List; 004 005import javax.persistence.CascadeType; 006import javax.persistence.Column; 007import javax.persistence.Entity; 008import javax.persistence.FetchType; 009import javax.persistence.GeneratedValue; 010import javax.persistence.GenerationType; 011import javax.persistence.Id; 012import javax.persistence.JoinColumn; 013import javax.persistence.ManyToOne; 014import javax.persistence.NamedQueries; 015import javax.persistence.NamedQuery; 016import javax.persistence.OneToMany; 017import javax.persistence.OrderBy; 018import javax.persistence.Table; 019 020/** 021 * A class representing an hourset. 022 * An hour set is a grouping of hours when the library is open. 023 * Hours sets are grouped by an <code>LibraryHourPeriod</code> which defined the period for the hour set. 024 * 025 * @author Kuali Mobility Team (mobility.collab@kuali.org) 026 * @since 2.3.0 027 */ 028@NamedQueries({ 029 @NamedQuery( 030 name="LibraryHourSet.getHourSets", 031 query="SELECT hs FROM LibraryHourSet hs WHERE libraryId = :libraryId ORDER BY hs.period.order") 032 033}) 034@Entity 035@Table(name="LIBRARY_HOUR_SET") 036public class LibraryHourSet { 037 038 /** 039 * Id of this hour set 040 */ 041 @Id 042 @GeneratedValue(strategy = GenerationType.TABLE) 043 @Column(name="ID") 044 private Long id; 045 046 /** 047 * Library to which this hour set belongs 048 */ 049 @Column(name="LIBRARY_ID") 050 private long libraryId; 051 052 /** 053 * Period this set is for 054 */ 055 @ManyToOne(optional=false) 056 @JoinColumn(name="PERIOD_ID", nullable=false, updatable=false) 057 @OrderBy(value="id DESC") 058 private LibraryHourPeriod period; 059 060 /** 061 * List of hours in this set 062 */ 063 @OneToMany(cascade=CascadeType.ALL, mappedBy="libraryHourSet", fetch=FetchType.EAGER) 064 @OrderBy(value="dayOfWeek ASC") 065 private List<LibraryHour> hours; 066 067 /** 068 * Gets the id for this <code>LibraryHourSet</code>. 069 * @return the id 070 */ 071 public Long getId() { 072 return id; 073 } 074 075 /** 076 * Sets the id for this <code>LibraryHourSet</code>. 077 * @param id the id to set 078 */ 079 public void setId(Long id) { 080 this.id = id; 081 } 082 083 /** 084 * Gets the libraryId for this <code>LibraryHourSet</code>. 085 * @return the libraryId 086 */ 087 public long getLibraryId() { 088 return libraryId; 089 } 090 091 /** 092 * Sets the libraryId for this <code>LibraryHourSet</code>. 093 * @param libraryId the libraryId to set 094 */ 095 public void setLibraryId(long libraryId) { 096 this.libraryId = libraryId; 097 } 098 099 /** 100 * Gets the period for this <code>LibraryHourSet</code>. 101 * @return the period 102 */ 103 public LibraryHourPeriod getPeriod() { 104 return period; 105 } 106 107 /** 108 * Sets the period for this <code>LibraryHourSet</code>. 109 * @param period the period to set 110 */ 111 public void setPeriod(LibraryHourPeriod period) { 112 this.period = period; 113 } 114 115 /** 116 * Gets the hours for this <code>LibraryHourSet</code>. 117 * @return the hours 118 */ 119 public List<LibraryHour> getHours() { 120 return hours; 121 } 122 123 /** 124 * Sets the hours for this <code>LibraryHourSet</code>. 125 * @param hours the hours to set 126 */ 127 public void setHours(List<LibraryHour> hours) { 128 this.hours = hours; 129 } 130 131 132 133 134}