Rev 206 | Rev 208 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
203 | jmachado | 1 | package pt.estgp.estgweb.domain.views; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | import pt.estgp.estgweb.domain.*; |
||
5 | |||
6 | import java.io.Serializable; |
||
7 | import java.util.Set; |
||
204 | jmachado | 8 | import java.util.List; |
206 | jmachado | 9 | import java.util.ArrayList; |
10 | import java.util.HashSet; |
||
203 | jmachado | 11 | |
12 | /** |
||
13 | * @author Jorge Machado |
||
14 | * @date 2/Mar/2008 |
||
15 | * @time 19:34:49 |
||
16 | * @see pt.estgp.estgweb.domain.views |
||
17 | */ |
||
204 | jmachado | 18 | public class CourseUnitView extends DomainObjectView implements ICanManage |
203 | jmachado | 19 | { |
20 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseUnitView.class); |
||
21 | |||
22 | private long id; |
||
23 | private 1.5.0/docs/api/java/lang/String.html">String name; |
||
24 | private 1.5.0/docs/api/java/lang/String.html">String code; |
||
25 | private 1.5.0/docs/api/java/lang/String.html">String courseCode; |
||
26 | private 1.5.0/docs/api/java/lang/String.html">String courseName; |
||
206 | jmachado | 27 | private 1.5.0/docs/api/java/lang/String.html">String semestre; |
28 | private 1.5.0/docs/api/java/lang/String.html">String importYear; |
||
203 | jmachado | 29 | private BlogView blog; |
30 | private Set<CourseUnitAnnouncement> announcements; |
||
31 | private CourseUnit courseUnit; |
||
206 | jmachado | 32 | private Set<UserView> teachers; |
33 | private Set<UserView> students; |
||
34 | |||
203 | jmachado | 35 | private 1.5.0/docs/api/java/lang/String.html">String objectives; |
204 | jmachado | 36 | private 1.5.0/docs/api/java/lang/String.html">String programStreamId; |
37 | private int programSize; |
||
38 | private 1.5.0/docs/api/java/lang/String.html">String extension; |
||
207 | jmachado | 39 | private List<CourseUnitAssignementView> courseUnitAssignements; |
203 | jmachado | 40 | |
41 | public 1.5.0/docs/api/java/lang/Class.html">Class getReferenceClass() |
||
42 | { |
||
43 | return CourseUnitImpl.class; |
||
44 | } |
||
45 | |||
46 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() |
||
47 | { |
||
48 | return id; |
||
49 | } |
||
50 | |||
51 | public CourseUnitView() |
||
52 | { |
||
53 | } |
||
206 | jmachado | 54 | public CourseUnitView(CourseUnit courseUnit, boolean initTeachers, boolean initStudents ) |
55 | { |
||
56 | super(courseUnit); |
||
57 | init(courseUnit, initTeachers, initStudents); |
||
58 | } |
||
203 | jmachado | 59 | |
60 | public CourseUnitView(CourseUnit courseUnit) |
||
61 | { |
||
62 | super(courseUnit); |
||
206 | jmachado | 63 | init(courseUnit, false,false); |
64 | } |
||
65 | private void init(CourseUnit courseUnit, boolean initTeachers, boolean initStudents) |
||
66 | { |
||
203 | jmachado | 67 | this.courseUnit = courseUnit; |
68 | this.courseName = courseUnit.getCourseName(); |
||
69 | this.name = courseUnit.getName(); |
||
70 | this.code = courseUnit.getCode(); |
||
206 | jmachado | 71 | this.importYear = courseUnit.getImportYear(); |
72 | this.semestre = courseUnit.getSemestre(); |
||
73 | this.importYear = courseUnit.getImportYear(); |
||
203 | jmachado | 74 | this.courseCode = courseUnit.getCourseCode(); |
75 | // if(courseUnit.getBlog() != null) |
||
76 | // this.blog = new BlogView(courseUnit.getBlog()); |
||
77 | this.id = courseUnit.getId(); |
||
206 | jmachado | 78 | teachers = new HashSet<UserView>(); |
79 | students = new HashSet<UserView>(); |
||
80 | if(initTeachers && courseUnit.getTeachers() != null) |
||
81 | { |
||
82 | for(TeacherImpl t: courseUnit.getTeachers()) |
||
83 | { |
||
84 | UserView u = new UserView(t); |
||
85 | teachers.add(u); |
||
86 | } |
||
87 | } |
||
88 | if(initStudents && courseUnit.getStudents() != null) |
||
89 | { |
||
90 | for(StudentImpl s: courseUnit.getStudents()) |
||
91 | { |
||
92 | UserView u = new UserView(s); |
||
93 | students.add(u); |
||
94 | } |
||
95 | } |
||
203 | jmachado | 96 | } |
97 | |||
206 | jmachado | 98 | public int getTeachersSize() |
99 | { |
||
100 | if(teachers != null) |
||
101 | return teachers.size(); |
||
102 | return 0; |
||
103 | } |
||
205 | jmachado | 104 | |
206 | jmachado | 105 | public int getStudentsSize() |
106 | { |
||
107 | if(students != null) |
||
108 | return students.size(); |
||
109 | return 0; |
||
110 | } |
||
111 | |||
207 | jmachado | 112 | public void setCourseUnitAssignements(List<CourseUnitAssignementView> courseUnitAssignements) |
205 | jmachado | 113 | { |
114 | this.courseUnitAssignements = courseUnitAssignements; |
||
115 | } |
||
116 | |||
207 | jmachado | 117 | public List<CourseUnitAssignementView> getCourseUnitAssignements() |
205 | jmachado | 118 | { |
119 | return courseUnitAssignements; |
||
120 | } |
||
121 | |||
204 | jmachado | 122 | public void setId(long id) |
203 | jmachado | 123 | { |
204 | jmachado | 124 | this.id = id; |
125 | } |
||
203 | jmachado | 126 | |
204 | jmachado | 127 | public void setName(1.5.0/docs/api/java/lang/String.html">String name) |
128 | { |
||
129 | this.name = name; |
||
203 | jmachado | 130 | } |
131 | |||
204 | jmachado | 132 | public void setCode(1.5.0/docs/api/java/lang/String.html">String code) |
133 | { |
||
134 | this.code = code; |
||
135 | } |
||
136 | |||
137 | public void setCourseCode(1.5.0/docs/api/java/lang/String.html">String courseCode) |
||
138 | { |
||
139 | this.courseCode = courseCode; |
||
140 | } |
||
141 | |||
142 | public void setCourseName(1.5.0/docs/api/java/lang/String.html">String courseName) |
||
143 | { |
||
144 | this.courseName = courseName; |
||
145 | } |
||
146 | |||
147 | public void persistViewInObject(CourseUnit c) |
||
148 | { |
||
149 | c.setObjectives(objectives); |
||
150 | } |
||
151 | |||
206 | jmachado | 152 | public void persistViewAdminInObject(CourseUnit c) |
153 | { |
||
154 | c.setImportYear(importYear); |
||
155 | c.setName(name); |
||
156 | c.setCode(code); |
||
157 | c.setSemestre(semestre); |
||
158 | } |
||
159 | |||
203 | jmachado | 160 | public 1.5.0/docs/api/java/lang/String.html">String getObjectives() |
161 | { |
||
162 | return objectives; |
||
163 | } |
||
164 | |||
165 | public void setObjectives(1.5.0/docs/api/java/lang/String.html">String objectives) |
||
166 | { |
||
167 | this.objectives = objectives; |
||
168 | } |
||
169 | |||
204 | jmachado | 170 | public 1.5.0/docs/api/java/lang/String.html">String getProgramStreamId() |
203 | jmachado | 171 | { |
204 | jmachado | 172 | return programStreamId; |
203 | jmachado | 173 | } |
174 | |||
204 | jmachado | 175 | public void setProgramStreamId(1.5.0/docs/api/java/lang/String.html">String programStreamId) |
203 | jmachado | 176 | { |
204 | jmachado | 177 | this.programStreamId = programStreamId; |
203 | jmachado | 178 | } |
179 | |||
180 | public long getId() |
||
181 | { |
||
182 | return id; |
||
183 | } |
||
184 | |||
185 | public 1.5.0/docs/api/java/lang/String.html">String getName() |
||
186 | { |
||
187 | return name; |
||
188 | } |
||
189 | |||
190 | public 1.5.0/docs/api/java/lang/String.html">String getCode() |
||
191 | { |
||
192 | return code; |
||
193 | } |
||
194 | |||
206 | jmachado | 195 | public 1.5.0/docs/api/java/lang/String.html">String getSemestre() |
196 | { |
||
197 | return semestre; |
||
198 | } |
||
199 | |||
200 | public void setSemestre(1.5.0/docs/api/java/lang/String.html">String semestre) |
||
201 | { |
||
202 | this.semestre = semestre; |
||
203 | } |
||
204 | |||
205 | public 1.5.0/docs/api/java/lang/String.html">String getImportYear() |
||
206 | { |
||
207 | return importYear; |
||
208 | } |
||
209 | |||
210 | public void setImportYear(1.5.0/docs/api/java/lang/String.html">String importYear) |
||
211 | { |
||
212 | this.importYear = importYear; |
||
213 | } |
||
214 | |||
203 | jmachado | 215 | public 1.5.0/docs/api/java/lang/String.html">String getCourseCode() |
216 | { |
||
217 | return courseCode; |
||
218 | } |
||
219 | |||
220 | public 1.5.0/docs/api/java/lang/String.html">String getCourseName() |
||
221 | { |
||
222 | return courseName; |
||
223 | } |
||
224 | |||
225 | public BlogView getBlog() |
||
226 | { |
||
227 | return blog; |
||
228 | } |
||
229 | |||
230 | |||
204 | jmachado | 231 | public int getProgramSize() |
232 | { |
||
233 | return programSize; |
||
234 | } |
||
235 | |||
236 | public void setProgramSize(int programSize) |
||
237 | { |
||
238 | this.programSize = programSize; |
||
239 | } |
||
240 | |||
241 | |||
242 | public 1.5.0/docs/api/java/lang/String.html">String getExtension() |
||
243 | { |
||
244 | return extension; |
||
245 | } |
||
246 | |||
247 | public void setExtension(1.5.0/docs/api/java/lang/String.html">String extension) |
||
248 | { |
||
249 | this.extension = extension; |
||
250 | } |
||
251 | |||
203 | jmachado | 252 | public Set<CourseUnitAnnouncement> getAnnouncements() |
253 | { |
||
254 | return announcements; |
||
255 | } |
||
256 | |||
206 | jmachado | 257 | public Set<UserView> getTeachers() |
203 | jmachado | 258 | { |
259 | return teachers; |
||
260 | } |
||
261 | |||
206 | jmachado | 262 | public Set<UserView> getStudents() |
203 | jmachado | 263 | { |
264 | return students; |
||
265 | } |
||
204 | jmachado | 266 | |
267 | public boolean isOwnedBy(GenericUser u) |
||
268 | { |
||
269 | return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId()); |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * Not implemented can be variuous teachers |
||
274 | * @return null |
||
275 | * use isOwnedBy in this class |
||
276 | */ |
||
277 | public GenericUser getOwner() |
||
278 | { |
||
279 | return null; |
||
280 | } |
||
281 | |||
282 | /** |
||
283 | * Not implemented |
||
284 | * @return |
||
285 | */ |
||
286 | public List<String> getOwnerRoles() |
||
287 | { |
||
288 | return null; |
||
289 | } |
||
206 | jmachado | 290 | |
204 | jmachado | 291 | /** |
292 | * Not implemented |
||
293 | * @return |
||
294 | */ |
||
295 | public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole() |
||
296 | { |
||
297 | return null; |
||
298 | } |
||
299 | |||
300 | public boolean isInternal() |
||
301 | { |
||
302 | return true; |
||
303 | } |
||
304 | |||
305 | public boolean isValid() |
||
306 | { |
||
307 | return true; |
||
308 | } |
||
206 | jmachado | 309 | |
310 | |||
311 | |||
203 | jmachado | 312 | } |