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 javax.persistence.CascadeType;
19  import javax.persistence.Column;
20  import javax.persistence.Entity;
21  import javax.persistence.GeneratedValue;
22  import javax.persistence.GenerationType;
23  import javax.persistence.Id;
24  import javax.persistence.JoinColumn;
25  import javax.persistence.NamedQueries;
26  import javax.persistence.NamedQuery;
27  import javax.persistence.OneToOne;
28  import javax.persistence.Table;
29  
30  
31  /**
32   * A class representing a Library.
33   * The campus code of the library should match a campus code available in <code>CampusService</code>
34   * @author Kuali Mobility Team (mobility.collab@kuali.org)
35   * @since 2.3.0
36   */
37  @NamedQueries({
38  	// Gets all the libraries ordered by campus code and order
39  	@NamedQuery(
40  		name="Library.getLibraries",
41  		query="SELECT a FROM Library a ORDER BY a.campusCode, a.order ASC "),
42  	// Gets all the libraries in a list of IDs
43  	@NamedQuery(
44  		name="Library.getLibrariesByIds",
45  		query="SELECT a FROM Library a where a.id IN (:libraryIds) ORDER BY a.campusCode, a.order ASC "),
46  	// Gets all the campus codes that has libraries
47  	@NamedQuery(
48  		name="Library.getCampusWithLibraries",
49  		query="SELECT DISTINCT l.campusCode FROM Library l ORDER BY l.campusCode ASC "),
50  	// Gets all the libraries on a campus
51  	@NamedQuery(
52  		name="Library.getLibariesForCampus",
53  		query="SELECT l FROM Library l WHERE l.campusCode = :campusCode ORDER BY l.order ASC ")
54  	
55  	
56  })
57  @Entity
58  @Table(name="LIBRARY")
59  public class Library {
60  	
61  	/** Id of the Library */
62  	@Id
63  	@GeneratedValue(strategy = GenerationType.TABLE)
64  	@Column(name="ID")
65  	private Long id;
66  	
67  	/**
68  	 * Name of the Library
69  	 */
70  	@Column(name="NAME" , nullable=false)
71  	private String name;
72  	
73  	/**
74  	 * Order of the library at a campus level list
75  	 */
76  	@Column(name="ORDR")
77  	private int order;
78  	
79  	/**
80  	 * Campus on which this library resides
81  	 */
82  	@Column(name="CAMPUS_CODE")
83  	private String campusCode;
84  	
85  	/** 
86  	 * Contact details for this library 
87  	 */
88  	@OneToOne(optional=false,cascade=CascadeType.ALL)
89  	@JoinColumn(name="LIBRARY_CONTACT_ID")
90  	private LibraryContactDetail libraryContactDetail;
91  
92  	/**
93  	 * Flag if this library is active
94  	 */
95  	@Column(name="ACTIVE")
96  	private boolean active;
97  
98  	/**
99  	 * Gets the id for this <code>Library</code>.
100 	 * @return the id
101 	 */
102 	public Long getId() {
103 		return id;
104 	}
105 
106 	/**
107 	 * Sets the id for this <code>Library</code>.
108 	 * @param id the id to set
109 	 */
110 	public void setId(Long id) {
111 		this.id = id;
112 	}
113 
114 	/**
115 	 * Gets the name for this <code>Library</code>.
116 	 * @return the name
117 	 */
118 	public String getName() {
119 		return name;
120 	}
121 
122 	/**
123 	 * Sets the name for this <code>Library</code>.
124 	 * @param name the name to set
125 	 */
126 	public void setName(String name) {
127 		this.name = name;
128 	}
129 
130 	/**
131 	 * Gets the order for this <code>Library</code>.
132 	 * @return the order
133 	 */
134 	public int getOrder() {
135 		return order;
136 	}
137 
138 	/**
139 	 * Sets the order for this <code>Library</code>.
140 	 * @param order the order to set
141 	 */
142 	public void setOrder(int order) {
143 		this.order = order;
144 	}
145 
146 	/**
147 	 * Gets the campusCode for this <code>Library</code>.
148 	 * @return the campusCode
149 	 */
150 	public String getCampusCode() {
151 		return campusCode;
152 	}
153 
154 	/**
155 	 * Sets the campusCode for this <code>Library</code>.
156 	 * @param campusCode the campusCode to set
157 	 */
158 	public void setCampusCode(String campusCode) {
159 		this.campusCode = campusCode;
160 	}
161 
162 	/**
163 	 * Gets the libraryContactDetail for this <code>Library</code>.
164 	 * @return the libraryContactDetail
165 	 */
166 	public LibraryContactDetail getLibraryContactDetail() {
167 		return libraryContactDetail;
168 	}
169 
170 	/**
171 	 * Sets the libraryContactDetail for this <code>Library</code>.
172 	 * @param libraryContactDetail the libraryContactDetail to set
173 	 */
174 	public void setLibraryContactDetail(LibraryContactDetail libraryContactDetail) {
175 		this.libraryContactDetail = libraryContactDetail;
176 	}
177 
178 	/**
179 	 * Gets the active for this <code>Library</code>.
180 	 * @return the active.
181 	 */
182 	public boolean isActive() {
183 		return active;
184 	}
185 
186 	/**
187 	 * Sets the active for this <code>Library</code>.
188 	 * @param active the active to set.
189 	 */
190 	public void setActive(boolean active) {
191 		this.active = active;
192 	}
193 	
194 	
195 
196 
197 }