1 package com.germinus.merlin.model;
2
3
4
5 import java.util.ArrayList;
6 import java.util.Date;
7 import java.util.HashSet;
8 import java.util.List;
9 import java.util.Set;
10 import javax.persistence.CascadeType;
11 import javax.persistence.Column;
12 import javax.persistence.Entity;
13 import javax.persistence.FetchType;
14 import javax.persistence.Id;
15 import javax.persistence.OneToMany;
16 import javax.persistence.Table;
17 import javax.persistence.Temporal;
18 import javax.persistence.TemporalType;
19
20 import org.hibernate.annotations.IndexColumn;
21 import org.springframework.core.style.ToStringCreator;
22
23 import com.germinus.merlin.model.assignment.Assignment;
24
25
26
27
28 @Entity
29 @Table(name = "Courses")
30 public class Course implements java.io.Serializable {
31
32
33
34
35
36 private static final long serialVersionUID = -4231327733990039797L;
37 private long groupId;
38 private String name;
39 private String description;
40 private Date startDate;
41 private Date endDate;
42 private Set<Page> page = new HashSet<Page>(0);
43 private Set<Teacher> teacher = new HashSet<Teacher>(0);
44 private Set<Student> student = new HashSet<Student>(0);
45 private List<ResourceContainer> resourceContainers = new ArrayList<ResourceContainer>();
46 private Set<Assignment> assignments = new HashSet<Assignment>(0);
47
48 public Course() {
49 }
50
51 public Course(long groupid, String name, String description, Date startDate, Date endDate) {
52 this.groupId = groupid;
53 this.name = name;
54 this.startDate = startDate;
55 this.endDate = endDate;
56 this.endDate = endDate;
57 this.description = description;
58 }
59
60 public Course(long groupId, String name, String description, Date startDate,
61 Date endDate, Set<Page> page, Set<Teacher> teacher,
62 Set<Student> student, List<ResourceContainer> resourceContainers,
63 Set<Assignment> assignments) {
64 super();
65 this.groupId = groupId;
66 this.name = name;
67 this.description = description;
68 this.startDate = startDate;
69 this.endDate = endDate;
70 this.page = page;
71 this.teacher = teacher;
72 this.student = student;
73 this.resourceContainers = resourceContainers;
74 this.assignments = assignments;
75 }
76
77 @Id
78 @Column(name = "groupid", unique = true, nullable = false)
79 public long getGroupId() {
80 return this.groupId;
81 }
82
83 public void setGroupId(long groupid) {
84 this.groupId = groupid;
85 }
86
87 @Column(name = "name", nullable = false, length = 75)
88 public String getName() {
89 return this.name;
90 }
91
92 public void setName(String name) {
93 this.name = name;
94 }
95
96 @Column(name = "summary", length = 255)
97 public String getDescription() {
98 return this.description;
99 }
100
101 public void setDescription(String description) {
102 this.description = description;
103 }
104
105 @Temporal(TemporalType.TIMESTAMP)
106 @Column(name = "start_date", nullable = false, length = 19)
107 public Date getStartDate() {
108 return this.startDate;
109 }
110
111 public void setStartDate(Date startDate) {
112 this.startDate = startDate;
113 }
114
115 @Temporal(TemporalType.TIMESTAMP)
116 @Column(name = "end_date", nullable = false, length = 19)
117 public Date getEndDate() {
118 return this.endDate;
119 }
120
121 public void setEndDate(Date endDate) {
122 this.endDate = endDate;
123 }
124
125 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "course")
126 public Set<Teacher> getTeachers() {
127 return this.teacher;
128 }
129
130 public void setTeachers(Set<Teacher> teacher) {
131 this.teacher = teacher;
132 }
133
134 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "course")
135 public Set<Student> getStudents() {
136 return this.student;
137 }
138
139 public void setStudents(Set<Student> student) {
140 this.student = student;
141 }
142
143 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "course")
144 @IndexColumn(name = "resourceposition", base = 0)
145 public List<ResourceContainer> getResourceContainers() {
146 return this.resourceContainers;
147 }
148
149 public void setResourceContainers(List<ResourceContainer> resourceContainers) {
150 this.resourceContainers = resourceContainers;
151 }
152
153 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "course")
154 public Set<Assignment> getAssignments() {
155 return this.assignments;
156 }
157
158 public void setAssignments(Set<Assignment> assignments) {
159 this.assignments = assignments;
160 }
161
162 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "course")
163 public Set<Page> getPages() {
164 return this.page;
165 }
166
167 public void setPages(Set<Page> page) {
168 this.page = page;
169 }
170
171
172 public String toString()
173 {
174 return new ToStringCreator(this)
175 .append("id", this.getGroupId())
176 .append("name", this.getName())
177 .append("description", this.getDescription())
178 .append("start_date", this.getStartDate())
179 .append("end_date", this.getEndDate())
180 .toString();
181
182 }
183
184 }