001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: Class.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.entity.entitytest03;
025:
026: import java.util.Collection;
027: import java.util.Date;
028:
029: import javax.persistence.Entity;
030: import javax.persistence.Id;
031: import javax.persistence.IdClass;
032: import javax.persistence.ManyToMany;
033: import javax.persistence.ManyToOne;
034: import javax.persistence.PrimaryKeyJoinColumn;
035: import javax.persistence.Temporal;
036: import javax.persistence.TemporalType;
037:
038: /**
039: * Contains the information about the class. Each course can have more than one class.
040: * @author Gisele Pinheiro Souza
041: * @author Eduardo Studzinski Estima de Castro
042: *
043: */
044: /**
045: * @author Gisele Pinheiro Souza
046: * @author Eduardo Studzinski Estima de Castro
047: *
048: */
049: @IdClass(ClassPK.class)
050: @Entity
051: @PrimaryKeyJoinColumn(name="course",referencedColumnName="courseId")
052: public class Class {
053:
054: /**
055: * The course identifier.
056: */
057: private Course course;
058:
059: /**
060: * The class year.
061: */
062: private String classYear;
063:
064: /**
065: * The class name.
066: */
067: private String className;
068:
069: /**
070: * The class room.
071: */
072: private ClassRoom classRoom;
073:
074: /**
075: * The professor identifier.
076: */
077: private Professor professor;
078:
079: /**
080: * The class students.
081: */
082: private Collection<Student> students;
083:
084: /**
085: * The begin date for the class.
086: */
087: private Date startDate;
088:
089: /**
090: * The end date for the class.
091: */
092: private Date endDate;
093:
094: /**
095: * Returns the end date for the classes.
096: * @return the date.
097: */
098: @Temporal(TemporalType.DATE)
099: public Date getEndDate() {
100: return endDate;
101: }
102:
103: /**
104: * Sets the end date for the classes.
105: * @param endDate the date.
106: */
107: public void setEndDate(final Date endDate) {
108: this .endDate = endDate;
109: }
110:
111: /**
112: * Returns the start date for the classes.
113: * @return the date.
114: */
115: @Temporal(TemporalType.DATE)
116: public Date getStartDate() {
117: return startDate;
118: }
119:
120: /**
121: * Sets the start date for the classes.
122: * @param startDate the date.
123: */
124: public void setStartDate(final Date startDate) {
125: this .startDate = startDate;
126: }
127:
128: /**
129: * Returns the class room.
130: * @return the room.
131: */
132: @ManyToOne
133: public ClassRoom getClassRoom() {
134: return classRoom;
135: }
136:
137: /**
138: * Sets the class room.
139: * @param classRoom the room.
140: */
141: public void setClassRoom(final ClassRoom classRoom) {
142: this .classRoom = classRoom;
143: }
144:
145: /**
146: * Sets the students that are in this class.
147: * @param students the students.
148: */
149: public void setStudents(final Collection<Student> students) {
150: this .students = students;
151: }
152:
153: /**
154: * Returns the class name.
155: * @return the name.
156: */
157: @Id
158: public String getClassName() {
159: return className;
160: }
161:
162: /**
163: * Sets the class name.
164: * @param className the name.
165: */
166: public void setClassName(final String className) {
167: this .className = className;
168: }
169:
170: /**
171: * Returns the class year.
172: * @return the year.
173: */
174: @Id
175: public String getClassYear() {
176: return classYear;
177: }
178:
179: /**
180: * Sets the class year.
181: * @param classYear the year.
182: */
183: public void setClassYear(final String classYear) {
184: this .classYear = classYear;
185: }
186:
187: /**
188: * Returns the class course.
189: * @return the course.
190: */
191: @ManyToOne
192: public Course getCourse() {
193: return course;
194: }
195:
196: /**
197: * Sets the course.
198: * @param course the course.
199: */
200: public void setCourse(final Course course) {
201: this .course = course;
202: }
203:
204: /**
205: * Returns the class professor.
206: * @return the professor.
207: */
208: @ManyToOne
209: public Professor getProfessor() {
210: return professor;
211: }
212:
213: /**
214: * Sets the class professor.
215: * @param professor the professor.
216: */
217: public void setProfessor(final Professor professor) {
218: this .professor = professor;
219: }
220:
221: /**
222: * Returns the class students.
223: * @return the students.
224: */
225: @ManyToMany(mappedBy="currentCours")
226: public Collection<Student> getStudents() {
227: return students;
228: }
229:
230: }
|