View Javadoc

1   package org.kuali.mobility.library.entity;
2   
3   import java.util.List;
4   
5   import javax.persistence.CascadeType;
6   import javax.persistence.Column;
7   import javax.persistence.Entity;
8   import javax.persistence.FetchType;
9   import javax.persistence.GeneratedValue;
10  import javax.persistence.GenerationType;
11  import javax.persistence.Id;
12  import javax.persistence.JoinColumn;
13  import javax.persistence.ManyToOne;
14  import javax.persistence.NamedQueries;
15  import javax.persistence.NamedQuery;
16  import javax.persistence.OneToMany;
17  import javax.persistence.OrderBy;
18  import javax.persistence.Table;
19  
20  /**
21   * A class representing an hourset.
22   * An hour set is a grouping of hours when the library is open.
23   * Hours sets are grouped by an <code>LibraryHourPeriod</code> which defined the period for the hour set.
24   * 
25   * @author Kuali Mobility Team (mobility.collab@kuali.org)
26   * @since 2.3.0
27   */
28  @NamedQueries({
29  	@NamedQuery(
30  		name="LibraryHourSet.getHourSets",
31  		query="SELECT hs FROM LibraryHourSet hs WHERE libraryId = :libraryId ORDER BY hs.period.order")
32  	
33  })
34  @Entity
35  @Table(name="LIBRARY_HOUR_SET")
36  public class LibraryHourSet {
37  
38  	/**
39  	 * Id of this hour set
40  	 */
41  	@Id
42  	@GeneratedValue(strategy = GenerationType.TABLE)
43  	@Column(name="ID")
44  	private Long id;
45  	
46  	/**
47  	 * Library to which this hour set belongs
48  	 */
49  	@Column(name="LIBRARY_ID")
50  	private long libraryId;
51  	
52  	/**
53  	 * Period this set is for
54  	 */
55  	@ManyToOne(optional=false) 
56      @JoinColumn(name="PERIOD_ID", nullable=false, updatable=false)
57  	@OrderBy(value="id DESC")
58  	private LibraryHourPeriod period;
59  	
60  	/**
61  	 * List of hours in this set
62  	 */
63  	@OneToMany(cascade=CascadeType.ALL, mappedBy="libraryHourSet", fetch=FetchType.EAGER)
64  	@OrderBy(value="dayOfWeek ASC")
65  	private List<LibraryHour> hours;
66  
67  	/**
68  	 * Gets the id for this <code>LibraryHourSet</code>.
69  	 * @return the id
70  	 */
71  	public Long getId() {
72  		return id;
73  	}
74  
75  	/**
76  	 * Sets the id for this <code>LibraryHourSet</code>.
77  	 * @param id the id to set
78  	 */
79  	public void setId(Long id) {
80  		this.id = id;
81  	}
82  
83  	/**
84  	 * Gets the libraryId for this <code>LibraryHourSet</code>.
85  	 * @return the libraryId
86  	 */
87  	public long getLibraryId() {
88  		return libraryId;
89  	}
90  
91  	/**
92  	 * Sets the libraryId for this <code>LibraryHourSet</code>.
93  	 * @param libraryId the libraryId to set
94  	 */
95  	public void setLibraryId(long libraryId) {
96  		this.libraryId = libraryId;
97  	}
98  
99  	/**
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 }