View Javadoc

1   /**
2    * Copyright 2011-2012 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.mobility.library.entity;
17  
18  import java.util.Date;
19  
20  import javax.persistence.Column;
21  import javax.persistence.Entity;
22  import javax.persistence.GeneratedValue;
23  import javax.persistence.GenerationType;
24  import javax.persistence.Id;
25  import javax.persistence.JoinColumn;
26  import javax.persistence.ManyToOne;
27  import javax.persistence.Table;
28  import javax.persistence.Transient;
29  
30  /**
31   * A class representing an hour range which the library is open
32   * @author Kuali Mobility Team (mobility.collab@kuali.org)
33   * @since 2.3.0
34   */
35  @Entity
36  @Table(name="LIBRARY_HOUR")
37  public class LibraryHour {
38  	
39  	public static final int DAY_MONDAY 			= 1;
40  	public static final int DAY_TUESDAY 		= 2;
41  	public static final int DAY_WEDNESDAY		= 3;
42  	public static final int DAY_THURSDAY 		= 4;
43  	public static final int DAY_FRIDAY 			= 5;
44  	public static final int DAY_SATURDAY		= 6;
45  	public static final int DAY_SUNDAY			= 7;
46  	public static final int DAY_PUBLIC_HOLIDAY	= 8;
47  
48  	/** Id of the Library */
49  	@Id
50  	@GeneratedValue(strategy = GenerationType.TABLE)
51  	@Column(name="ID")
52  	private long id;
53  
54  	/**
55  	 * Day of week this hour applies to
56  	 * 1 - 7 = Monday to Sunday
57  	 * 8 = Public holiday
58  	 */
59  	@Column(name="DAY_OF_WEEK")
60  	private int dayOfWeek ;
61  
62  	/**
63  	 * Starting time
64  	 */
65  	@Column(name="FROM_TIME")
66  	private Date fromTime;
67  
68  	/**
69  	 * Ending time
70  	 */
71  	@Column(name="TO_TIME")
72  	private Date toTime;
73  
74  	/**
75  	 * Hour set this hour is placed in
76  	 */
77  	@ManyToOne(optional=false) 
78  	@JoinColumn(name="HOUR_SET_ID", nullable=false, updatable=false)
79  	private LibraryHourSet libraryHourSet;
80  	
81  	/**
82  	 * Label to display on the hours page
83  	 * This field is not persisted
84  	 */
85  	@Transient
86  	private transient String displayLabel;
87  
88  	
89  	
90  	/**
91  	 * Gets the id for this <code>LibraryHour</code>.
92  	 * @return the id
93  	 */
94  	public long getId() {
95  		return id;
96  	}
97  
98  	/**
99  	 * Sets the id for this <code>LibraryHour</code>.
100 	 * @param id the id to set
101 	 */
102 	public void setId(long id) {
103 		this.id = id;
104 	}
105 
106 	/**
107 	 * Gets the dayOfWeek for this <code>LibraryHour</code>.
108 	 * @return the dayOfWeek
109 	 */
110 	public int getDayOfWeek() {
111 		return dayOfWeek;
112 	}
113 
114 	/**
115 	 * Sets the dayOfWeek for this <code>LibraryHour</code>.
116 	 * @param dayOfWeek the dayOfWeek to set
117 	 */
118 	public void setDayOfWeek(int dayOfWeek) {
119 		this.dayOfWeek = dayOfWeek;
120 	}
121 
122 	/**
123 	 * Gets the fromTime for this <code>LibraryHour</code>.
124 	 * @return the fromTime
125 	 */
126 	public Date getFromTime() {
127 		return fromTime;
128 	}
129 
130 	/**
131 	 * Sets the fromTime for this <code>LibraryHour</code>.
132 	 * @param fromTime the fromTime to set
133 	 */
134 	public void setFromTime(Date fromTime) {
135 		this.fromTime = fromTime;
136 	}
137 
138 	/**
139 	 * Gets the toTime for this <code>LibraryHour</code>.
140 	 * @return the toTime
141 	 */
142 	public Date getToTime() {
143 		return toTime;
144 	}
145 
146 	/**
147 	 * Sets the toTime for this <code>LibraryHour</code>.
148 	 * @param toTime the toTime to set
149 	 */
150 	public void setToTime(Date toTime) {
151 		this.toTime = toTime;
152 	}
153 
154 	/**
155 	 * Gets the libraryHourSet for this <code>LibraryHour</code>.
156 	 * @return the libraryHourSet
157 	 */
158 	public LibraryHourSet getLibraryHourSet() {
159 		return libraryHourSet;
160 	}
161 
162 	/**
163 	 * Sets the libraryHourSet for this <code>LibraryHour</code>.
164 	 * @param libraryHourSet the libraryHourSet to set
165 	 */
166 	public void setLibraryHourSet(LibraryHourSet libraryHourSet) {
167 		this.libraryHourSet = libraryHourSet;
168 	}
169 
170 	/**
171 	 * Gets the displayLabel for this <code>LibraryHour</code>.
172 	 * @return the displayLabel
173 	 */
174 	public String getDisplayLabel() {
175 		return displayLabel;
176 	}
177 
178 	/**
179 	 * Sets the displayLabel for this <code>LibraryHour</code>.
180 	 * @param displayLabel the displayLabel to set
181 	 */
182 	public void setDisplayLabel(String displayLabel) {
183 		this.displayLabel = displayLabel;
184 	}
185 
186 	/**
187 	 * Returns true if the library is closed for this hour range
188 	 * @return True if the library is closed.
189 	 */
190 	public boolean isClosed(){
191 		return this.toTime == null || this.fromTime == null;
192 	}
193 
194 	
195 }