Rev 995 | Rev 1003 | 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 | |||
632 | jmachado | 3 | import jomm.utils.StringsUtils; |
203 | jmachado | 4 | import org.apache.log4j.Logger; |
995 | jmachado | 5 | import org.json.JSONArray; |
6 | import org.json.JSONException; |
||
7 | import org.json.JSONObject; |
||
203 | jmachado | 8 | import pt.estgp.estgweb.domain.*; |
214 | jmachado | 9 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
10 | import pt.estgp.estgweb.services.courseunits.LoadCourseUnitAnnouncements; |
||
203 | jmachado | 11 | |
12 | import java.io.Serializable; |
||
405 | jmachado | 13 | import java.util.*; |
203 | jmachado | 14 | |
15 | /** |
||
16 | * @author Jorge Machado |
||
17 | * @date 2/Mar/2008 |
||
18 | * @time 19:34:49 |
||
19 | * @see pt.estgp.estgweb.domain.views |
||
20 | */ |
||
204 | jmachado | 21 | public class CourseUnitView extends DomainObjectView implements ICanManage |
203 | jmachado | 22 | { |
23 | 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); |
||
24 | |||
214 | jmachado | 25 | |
26 | LoadCourseUnitAnnouncements loadCourseUnitAnnouncements = new LoadCourseUnitAnnouncements(); |
||
27 | |||
203 | jmachado | 28 | private long id; |
29 | private 1.5.0/docs/api/java/lang/String.html">String name; |
||
30 | private 1.5.0/docs/api/java/lang/String.html">String code; |
||
214 | jmachado | 31 | private long courseId; |
751 | jmachado | 32 | private long coordinatorId; |
749 | jmachado | 33 | private long responsableId; |
203 | jmachado | 34 | private 1.5.0/docs/api/java/lang/String.html">String courseCode; |
35 | private 1.5.0/docs/api/java/lang/String.html">String courseName; |
||
206 | jmachado | 36 | private 1.5.0/docs/api/java/lang/String.html">String semestre; |
37 | private 1.5.0/docs/api/java/lang/String.html">String importYear; |
||
489 | jmachado | 38 | private 1.5.0/docs/api/java/lang/String.html">String contentsGrants; |
203 | jmachado | 39 | private BlogView blog; |
223 | jmachado | 40 | private 1.5.0/docs/api/java/lang/String.html">String pathIntranet; |
41 | private 1.5.0/docs/api/java/lang/String.html">String normalizedName; |
||
209 | jmachado | 42 | private List<AnnouncementView> announcements; |
358 | jmachado | 43 | private List<CourseUnitSummaryView> summaries; |
995 | jmachado | 44 | private 1.5.0/docs/api/java/lang/String.html">String summariesJson; |
209 | jmachado | 45 | |
203 | jmachado | 46 | private CourseUnit courseUnit; |
749 | jmachado | 47 | private UserView responsableTeacher; |
206 | jmachado | 48 | private Set<UserView> teachers; |
49 | private Set<UserView> students; |
||
405 | jmachado | 50 | private List<UserView> studentsOrderedByName; |
51 | private List<UserView> studentsOrderedByNumber; |
||
206 | jmachado | 52 | |
203 | jmachado | 53 | private 1.5.0/docs/api/java/lang/String.html">String objectives; |
204 | jmachado | 54 | private 1.5.0/docs/api/java/lang/String.html">String programStreamId; |
950 | jmachado | 55 | private 1.5.0/docs/api/java/lang/String.html">String evaluationStreamId; |
343 | jmachado | 56 | private boolean validProgram; |
57 | private UserView validatorUser; |
||
950 | jmachado | 58 | private boolean validEvaluation = false; |
204 | jmachado | 59 | private int programSize; |
60 | private 1.5.0/docs/api/java/lang/String.html">String extension; |
||
207 | jmachado | 61 | private List<CourseUnitAssignementView> courseUnitAssignements; |
995 | jmachado | 62 | private 1.5.0/docs/api/java/lang/String.html">String sumariosPathFileIntranet; |
203 | jmachado | 63 | |
214 | jmachado | 64 | private boolean notFound = false; |
65 | |||
66 | private CourseView courseView; |
||
67 | |||
203 | jmachado | 68 | public 1.5.0/docs/api/java/lang/Class.html">Class getReferenceClass() |
69 | { |
||
70 | return CourseUnitImpl.class; |
||
71 | } |
||
72 | |||
73 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() |
||
74 | { |
||
75 | return id; |
||
76 | } |
||
77 | |||
78 | public CourseUnitView() |
||
79 | { |
||
80 | } |
||
206 | jmachado | 81 | public CourseUnitView(CourseUnit courseUnit, boolean initTeachers, boolean initStudents ) |
82 | { |
||
83 | super(courseUnit); |
||
343 | jmachado | 84 | init(courseUnit, initTeachers, initStudents,false,false); |
206 | jmachado | 85 | } |
209 | jmachado | 86 | |
208 | jmachado | 87 | public CourseUnitView(CourseUnit courseUnit, boolean initTeachers, boolean initStudents, boolean initBlog ) |
88 | { |
||
89 | super(courseUnit); |
||
343 | jmachado | 90 | init(courseUnit, initTeachers, initStudents, initBlog,false); |
208 | jmachado | 91 | } |
203 | jmachado | 92 | |
343 | jmachado | 93 | public CourseUnitView(CourseUnit courseUnit, boolean initTeachers, boolean initStudents, boolean initBlog, boolean validatorPerson ) |
94 | { |
||
95 | super(courseUnit); |
||
96 | init(courseUnit, initTeachers, initStudents, initBlog, validatorPerson); |
||
97 | } |
||
98 | |||
203 | jmachado | 99 | public CourseUnitView(CourseUnit courseUnit) |
100 | { |
||
101 | super(courseUnit); |
||
343 | jmachado | 102 | init(courseUnit, false,false,false,false); |
206 | jmachado | 103 | } |
208 | jmachado | 104 | |
105 | public CourseUnitView(CourseUnit courseUnit, BlogView b) |
||
206 | jmachado | 106 | { |
208 | jmachado | 107 | super(courseUnit); |
108 | this.blog = b; |
||
343 | jmachado | 109 | init(courseUnit, false,false,false,false); |
208 | jmachado | 110 | } |
214 | jmachado | 111 | |
749 | jmachado | 112 | public CourseUnit getCourseUnit() { |
113 | return courseUnit; |
||
114 | } |
||
115 | |||
343 | jmachado | 116 | private void init(CourseUnit courseUnit, boolean initTeachers, boolean initStudents, boolean initBlog, boolean validatorUser) |
208 | jmachado | 117 | { |
223 | jmachado | 118 | this.pathIntranet = courseUnit.getPathIntranet(); |
119 | this.normalizedName = courseUnit.getNormalizedName(); |
||
203 | jmachado | 120 | this.courseUnit = courseUnit; |
121 | this.courseName = courseUnit.getCourseName(); |
||
122 | this.name = courseUnit.getName(); |
||
123 | this.code = courseUnit.getCode(); |
||
206 | jmachado | 124 | this.importYear = courseUnit.getImportYear(); |
125 | this.semestre = courseUnit.getSemestre(); |
||
203 | jmachado | 126 | this.courseCode = courseUnit.getCourseCode(); |
995 | jmachado | 127 | this.summariesJson = courseUnit.getSummariesJson(); |
128 | this.sumariosPathFileIntranet = ((CourseUnitImpl)courseUnit).getSummariosPathFileIntranet(); |
||
749 | jmachado | 129 | |
130 | // this.objectives = courseUnit.getObjectives(); DEPRECATED |
||
131 | if(courseUnit.getCourseUnitProgram() !=null && courseUnit.getCourseUnitProgram().getCourseUnitProgramPart2() != null) |
||
132 | this.objectives = courseUnit.getCourseUnitProgram().getCourseUnitProgramPart2().getObjectivos(); |
||
133 | else |
||
134 | this.objectives = null; |
||
489 | jmachado | 135 | this.contentsGrants = courseUnit.getContentsGrants(); |
209 | jmachado | 136 | if(courseUnit.getProgramStreamId() != null) |
343 | jmachado | 137 | { |
209 | jmachado | 138 | programStreamId = courseUnit.getProgramStreamId(); |
343 | jmachado | 139 | validProgram = courseUnit.isValidProgram(); |
140 | if(validatorUser) |
||
141 | { |
||
142 | if(courseUnit.getValidatorUser() != null) |
||
143 | this.validatorUser = new UserView(courseUnit.getValidatorUser()); |
||
144 | } |
||
145 | } |
||
146 | |||
950 | jmachado | 147 | if(courseUnit.getEvaluationStreamId() != null) |
148 | { |
||
149 | evaluationStreamId = courseUnit.getEvaluationStreamId(); |
||
150 | validEvaluation = courseUnit.getCourseUnitEvaluation().isClosed(); |
||
151 | } |
||
152 | |||
203 | jmachado | 153 | // if(courseUnit.getBlog() != null) |
154 | // this.blog = new BlogView(courseUnit.getBlog()); |
||
155 | this.id = courseUnit.getId(); |
||
206 | jmachado | 156 | teachers = new HashSet<UserView>(); |
157 | students = new HashSet<UserView>(); |
||
158 | if(initTeachers && courseUnit.getTeachers() != null) |
||
159 | { |
||
749 | jmachado | 160 | responsableTeacher = new UserView(courseUnit.getResponsableTeacher()); |
206 | jmachado | 161 | for(TeacherImpl t: courseUnit.getTeachers()) |
162 | { |
||
163 | UserView u = new UserView(t); |
||
164 | teachers.add(u); |
||
165 | } |
||
166 | } |
||
167 | if(initStudents && courseUnit.getStudents() != null) |
||
168 | { |
||
169 | for(StudentImpl s: courseUnit.getStudents()) |
||
170 | { |
||
171 | UserView u = new UserView(s); |
||
172 | students.add(u); |
||
173 | } |
||
174 | } |
||
208 | jmachado | 175 | if(initBlog) |
176 | { |
||
177 | blog = new BlogView(((CourseUnitImpl)courseUnit).getUnitBlog(),this); |
||
178 | } |
||
214 | jmachado | 179 | if(courseUnit.getCourse() != null) |
180 | { |
||
181 | courseId = courseUnit.getCourse().getId(); |
||
751 | jmachado | 182 | if(courseUnit.getCourse().getCoordinator() != null) |
183 | coordinatorId = courseUnit.getCourse().getCoordinator().getId(); |
||
214 | jmachado | 184 | } |
749 | jmachado | 185 | if(courseUnit.getResponsableTeacher() != null) |
186 | { |
||
187 | responsableId = courseUnit.getResponsableTeacher().getId(); |
||
188 | } |
||
968 | jmachado | 189 | courseView = new CourseView(courseUnit.getCourse(),false); |
203 | jmachado | 190 | } |
191 | |||
950 | jmachado | 192 | public 1.5.0/docs/api/java/lang/String.html">String getEvaluationStreamId() { |
193 | return evaluationStreamId; |
||
194 | } |
||
195 | |||
196 | |||
995 | jmachado | 197 | public 1.5.0/docs/api/java/lang/String.html">String getSumariosPathFileIntranet() { |
198 | return sumariosPathFileIntranet; |
||
199 | } |
||
950 | jmachado | 200 | |
201 | public boolean isValidEvaluation() { |
||
202 | return validEvaluation; |
||
203 | } |
||
204 | |||
205 | |||
751 | jmachado | 206 | public long getCoordinatorId() { |
207 | return coordinatorId; |
||
208 | } |
||
209 | |||
210 | public void setCoordinatorId(long coordinatorId) { |
||
211 | this.coordinatorId = coordinatorId; |
||
212 | } |
||
213 | |||
749 | jmachado | 214 | public long getResponsableId() { |
215 | return responsableId; |
||
216 | } |
||
217 | |||
218 | public void setResponsableId(long responsableId) { |
||
219 | this.responsableId = responsableId; |
||
220 | } |
||
221 | |||
214 | jmachado | 222 | public long getCourseId() |
223 | { |
||
224 | return courseId; |
||
225 | } |
||
226 | |||
227 | public void setCourseId(long courseId) |
||
228 | { |
||
229 | this.courseId = courseId; |
||
230 | } |
||
231 | |||
232 | public CourseView getCourseView() |
||
233 | { |
||
234 | return courseView; |
||
235 | } |
||
236 | |||
223 | jmachado | 237 | public 1.5.0/docs/api/java/lang/String.html">String getNormalizedName() |
238 | { |
||
239 | return normalizedName; |
||
240 | } |
||
241 | |||
242 | public void setNormalizedName(1.5.0/docs/api/java/lang/String.html">String normalizedName) |
||
243 | { |
||
244 | this.normalizedName = normalizedName; |
||
245 | } |
||
246 | |||
247 | public 1.5.0/docs/api/java/lang/String.html">String getPathIntranet() |
||
248 | { |
||
249 | return pathIntranet; |
||
250 | } |
||
251 | |||
252 | public void setPathIntranet(1.5.0/docs/api/java/lang/String.html">String pathIntranet) |
||
253 | { |
||
254 | this.pathIntranet = pathIntranet; |
||
255 | } |
||
256 | |||
214 | jmachado | 257 | public void setCourseView(CourseView courseView) |
258 | { |
||
259 | this.courseView = courseView; |
||
260 | } |
||
261 | |||
262 | public void setNotFound(boolean notFound) |
||
263 | { |
||
264 | this.notFound = notFound; |
||
265 | } |
||
266 | |||
267 | public boolean isNotFound() |
||
268 | { |
||
269 | return notFound; |
||
270 | } |
||
271 | |||
209 | jmachado | 272 | public void setAnnouncements(List<AnnouncementView> announcements) |
273 | { |
||
274 | this.announcements = announcements; |
||
275 | } |
||
276 | |||
206 | jmachado | 277 | public int getTeachersSize() |
278 | { |
||
279 | if(teachers != null) |
||
280 | return teachers.size(); |
||
281 | return 0; |
||
282 | } |
||
205 | jmachado | 283 | |
206 | jmachado | 284 | public int getStudentsSize() |
285 | { |
||
286 | if(students != null) |
||
287 | return students.size(); |
||
288 | return 0; |
||
289 | } |
||
214 | jmachado | 290 | |
207 | jmachado | 291 | public void setCourseUnitAssignements(List<CourseUnitAssignementView> courseUnitAssignements) |
205 | jmachado | 292 | { |
293 | this.courseUnitAssignements = courseUnitAssignements; |
||
294 | } |
||
295 | |||
207 | jmachado | 296 | public List<CourseUnitAssignementView> getCourseUnitAssignements() |
205 | jmachado | 297 | { |
298 | return courseUnitAssignements; |
||
299 | } |
||
300 | |||
489 | jmachado | 301 | public 1.5.0/docs/api/java/lang/String.html">String getContentsGrants() { |
302 | return contentsGrants; |
||
303 | } |
||
304 | |||
305 | public void setContentsGrants(1.5.0/docs/api/java/lang/String.html">String contentsGrants) { |
||
306 | this.contentsGrants = contentsGrants; |
||
307 | } |
||
308 | |||
204 | jmachado | 309 | public void setId(long id) |
203 | jmachado | 310 | { |
204 | jmachado | 311 | this.id = id; |
312 | } |
||
203 | jmachado | 313 | |
204 | jmachado | 314 | public void setName(1.5.0/docs/api/java/lang/String.html">String name) |
315 | { |
||
316 | this.name = name; |
||
203 | jmachado | 317 | } |
318 | |||
204 | jmachado | 319 | public void setCode(1.5.0/docs/api/java/lang/String.html">String code) |
320 | { |
||
321 | this.code = code; |
||
322 | } |
||
323 | |||
324 | public void setCourseCode(1.5.0/docs/api/java/lang/String.html">String courseCode) |
||
325 | { |
||
326 | this.courseCode = courseCode; |
||
327 | } |
||
328 | |||
329 | public void setCourseName(1.5.0/docs/api/java/lang/String.html">String courseName) |
||
330 | { |
||
331 | this.courseName = courseName; |
||
332 | } |
||
333 | |||
334 | public void persistViewInObject(CourseUnit c) |
||
335 | { |
||
336 | c.setObjectives(objectives); |
||
489 | jmachado | 337 | c.setContentsGrants(contentsGrants); |
204 | jmachado | 338 | } |
339 | |||
206 | jmachado | 340 | public void persistViewAdminInObject(CourseUnit c) |
341 | { |
||
342 | c.setImportYear(importYear); |
||
343 | c.setName(name); |
||
344 | c.setCode(code); |
||
345 | c.setSemestre(semestre); |
||
214 | jmachado | 346 | if(courseId > 0) |
347 | { |
||
348 | c.setCourse(DaoFactory.getCourseDaoImpl().load(courseId)); |
||
748 | jmachado | 349 | c.setCourseCode(c.getCourse().getCode()); |
350 | c.setCourseName(c.getCourse().getName()); |
||
214 | jmachado | 351 | } |
749 | jmachado | 352 | if(responsableId > 0) |
353 | { |
||
354 | c.setResponsableTeacher(DaoFactory.getTeacherDaoImpl().load(responsableId)); |
||
355 | } |
||
206 | jmachado | 356 | } |
357 | |||
203 | jmachado | 358 | public 1.5.0/docs/api/java/lang/String.html">String getObjectives() |
359 | { |
||
360 | return objectives; |
||
361 | } |
||
362 | |||
485 | jmachado | 363 | public 1.5.0/docs/api/java/lang/String.html">String getFormatedObjectives() |
364 | { |
||
365 | return StringsUtils.getFormatedText(objectives); |
||
366 | } |
||
367 | |||
203 | jmachado | 368 | public void setObjectives(1.5.0/docs/api/java/lang/String.html">String objectives) |
369 | { |
||
370 | this.objectives = objectives; |
||
371 | } |
||
372 | |||
204 | jmachado | 373 | public 1.5.0/docs/api/java/lang/String.html">String getProgramStreamId() |
203 | jmachado | 374 | { |
204 | jmachado | 375 | return programStreamId; |
203 | jmachado | 376 | } |
377 | |||
204 | jmachado | 378 | public void setProgramStreamId(1.5.0/docs/api/java/lang/String.html">String programStreamId) |
203 | jmachado | 379 | { |
204 | jmachado | 380 | this.programStreamId = programStreamId; |
203 | jmachado | 381 | } |
382 | |||
383 | public long getId() |
||
384 | { |
||
385 | return id; |
||
386 | } |
||
387 | |||
388 | public 1.5.0/docs/api/java/lang/String.html">String getName() |
||
389 | { |
||
390 | return name; |
||
391 | } |
||
392 | |||
393 | public 1.5.0/docs/api/java/lang/String.html">String getCode() |
||
394 | { |
||
395 | return code; |
||
396 | } |
||
397 | |||
206 | jmachado | 398 | public 1.5.0/docs/api/java/lang/String.html">String getSemestre() |
399 | { |
||
343 | jmachado | 400 | if(semestre == null) |
401 | { |
||
402 | logger.error("Unit" + getId() + " " + getName() + "" + " - " + getCourseName() + " " + getImportYear() + " with no SEMESTRE SET, returning S1"); |
||
403 | return "S1"; |
||
404 | } |
||
206 | jmachado | 405 | return semestre; |
406 | } |
||
407 | |||
408 | public void setSemestre(1.5.0/docs/api/java/lang/String.html">String semestre) |
||
409 | { |
||
410 | this.semestre = semestre; |
||
411 | } |
||
412 | |||
413 | public 1.5.0/docs/api/java/lang/String.html">String getImportYear() |
||
414 | { |
||
415 | return importYear; |
||
416 | } |
||
417 | |||
418 | public void setImportYear(1.5.0/docs/api/java/lang/String.html">String importYear) |
||
419 | { |
||
420 | this.importYear = importYear; |
||
421 | } |
||
422 | |||
203 | jmachado | 423 | public 1.5.0/docs/api/java/lang/String.html">String getCourseCode() |
424 | { |
||
425 | return courseCode; |
||
426 | } |
||
427 | |||
428 | public 1.5.0/docs/api/java/lang/String.html">String getCourseName() |
||
429 | { |
||
430 | return courseName; |
||
431 | } |
||
432 | |||
433 | public BlogView getBlog() |
||
434 | { |
||
435 | return blog; |
||
436 | } |
||
437 | |||
438 | |||
204 | jmachado | 439 | public int getProgramSize() |
440 | { |
||
441 | return programSize; |
||
442 | } |
||
443 | |||
444 | public void setProgramSize(int programSize) |
||
445 | { |
||
446 | this.programSize = programSize; |
||
447 | } |
||
448 | |||
449 | |||
450 | public 1.5.0/docs/api/java/lang/String.html">String getExtension() |
||
451 | { |
||
452 | return extension; |
||
453 | } |
||
454 | |||
455 | public void setExtension(1.5.0/docs/api/java/lang/String.html">String extension) |
||
456 | { |
||
457 | this.extension = extension; |
||
458 | } |
||
459 | |||
209 | jmachado | 460 | public List<AnnouncementView> getAnnouncements() |
203 | jmachado | 461 | { |
462 | return announcements; |
||
463 | } |
||
464 | |||
206 | jmachado | 465 | public Set<UserView> getTeachers() |
203 | jmachado | 466 | { |
467 | return teachers; |
||
468 | } |
||
469 | |||
206 | jmachado | 470 | public Set<UserView> getStudents() |
203 | jmachado | 471 | { |
472 | return students; |
||
473 | } |
||
204 | jmachado | 474 | |
995 | jmachado | 475 | public 1.5.0/docs/api/java/lang/String.html">String getSummariesJson() { |
476 | return summariesJson; |
||
477 | } |
||
478 | |||
479 | List<CourseUnitSummaryView> summariesFromJson = null; |
||
480 | /** |
||
481 | * |
||
482 | * @return sumaries or null if there are no summaries in Json |
||
483 | */ |
||
484 | |||
485 | |||
486 | public List<CourseUnitSummaryView> getSummariesFromJson() { |
||
487 | if(summariesFromJson != null) |
||
488 | return summariesFromJson; |
||
489 | summariesFromJson = new ArrayList<CourseUnitSummaryView>(); |
||
490 | if(summariesJson != null && summariesJson.length() > 0) |
||
491 | { |
||
492 | try { |
||
493 | JSONObject jsonObject = new JSONObject(summariesJson); |
||
494 | JSONArray summaries = jsonObject.getJSONArray("summary"); |
||
495 | for(int i = 0; i < summaries.length();i++) |
||
496 | { |
||
497 | JSONObject summary = summaries.getJSONObject(i); |
||
498 | CourseUnitSummaryImpl sum = DomainObjectFactory.createCourseUnitSummaryImpl(); |
||
499 | sum.updateWithJson(summary); |
||
500 | CourseUnitSummaryView view = new CourseUnitSummaryView(sum); |
||
501 | summariesFromJson.add(view); |
||
502 | } |
||
503 | } catch (JSONException e) { |
||
504 | logger.error(e,e); |
||
505 | } |
||
506 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(summariesFromJson,new Comparator<CourseUnitSummaryView>() { |
||
507 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
508 | public int compare(CourseUnitSummaryView courseUnitSummaryView, CourseUnitSummaryView courseUnitSummaryView2) { |
||
509 | if(courseUnitSummaryView.getNumber() > courseUnitSummaryView2.getNumber()) |
||
1002 | jmachado | 510 | return -1; |
511 | else if(courseUnitSummaryView.getNumber() > courseUnitSummaryView2.getNumber()) |
||
995 | jmachado | 512 | return 1; |
513 | return 0; |
||
514 | } |
||
515 | }); |
||
516 | return summariesFromJson; |
||
517 | } |
||
518 | return null; |
||
519 | } |
||
520 | |||
521 | public void setSummariesJson(1.5.0/docs/api/java/lang/String.html">String summariesJson) { |
||
522 | this.summariesJson = summariesJson; |
||
523 | } |
||
524 | |||
204 | jmachado | 525 | public boolean isOwnedBy(GenericUser u) |
526 | { |
||
208 | jmachado | 527 | return isOwnedBy(u, false); |
204 | jmachado | 528 | } |
214 | jmachado | 529 | |
208 | jmachado | 530 | public boolean isOwnedBy(GenericUser u, boolean transaction) |
531 | { |
||
632 | jmachado | 532 | //return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId(), transaction); |
533 | |||
534 | //ALTERACOES REUNIAO BACO CODIGO 01062011 |
||
535 | //TESTE A COMISSAO DE CURSO NAS CADEIRAS |
||
536 | |||
208 | jmachado | 537 | return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId(), transaction); |
538 | } |
||
204 | jmachado | 539 | |
995 | jmachado | 540 | |
204 | jmachado | 541 | /** |
542 | * Not implemented can be variuous teachers |
||
543 | * @return null |
||
544 | * use isOwnedBy in this class |
||
545 | */ |
||
546 | public GenericUser getOwner() |
||
547 | { |
||
548 | return null; |
||
549 | } |
||
550 | |||
551 | /** |
||
552 | * Not implemented |
||
553 | * @return |
||
554 | */ |
||
555 | public List<String> getOwnerRoles() |
||
556 | { |
||
557 | return null; |
||
558 | } |
||
206 | jmachado | 559 | |
204 | jmachado | 560 | /** |
561 | * Not implemented |
||
562 | * @return |
||
563 | */ |
||
564 | public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole() |
||
565 | { |
||
566 | return null; |
||
567 | } |
||
568 | |||
569 | public boolean isInternal() |
||
570 | { |
||
571 | return true; |
||
572 | } |
||
573 | |||
574 | public boolean isValid() |
||
575 | { |
||
576 | return true; |
||
577 | } |
||
206 | jmachado | 578 | |
579 | |||
343 | jmachado | 580 | public boolean isValidProgram() |
581 | { |
||
582 | return validProgram; |
||
583 | } |
||
206 | jmachado | 584 | |
343 | jmachado | 585 | public void setValidProgram(boolean validProgram) |
586 | { |
||
587 | this.validProgram = validProgram; |
||
588 | } |
||
589 | |||
590 | public UserView getValidatorUser() |
||
591 | { |
||
592 | return validatorUser; |
||
593 | } |
||
594 | |||
595 | public void setValidatorUser(UserView validatorUser) |
||
596 | { |
||
597 | this.validatorUser = validatorUser; |
||
598 | } |
||
599 | |||
749 | jmachado | 600 | public UserView getResponsableTeacher() { |
601 | return responsableTeacher; |
||
602 | } |
||
358 | jmachado | 603 | |
749 | jmachado | 604 | public void setResponsableTeacher(UserView responsableTeacher) { |
605 | this.responsableTeacher = responsableTeacher; |
||
606 | } |
||
607 | |||
358 | jmachado | 608 | public void setSummaries(List<CourseUnitSummaryView> summaries) |
609 | { |
||
610 | this.summaries = summaries; |
||
611 | } |
||
612 | |||
613 | public List<CourseUnitSummaryView> getSummaries() |
||
614 | { |
||
615 | return summaries; |
||
616 | } |
||
617 | |||
343 | jmachado | 618 | public 1.5.0/docs/api/java/lang/String.html">String getTeachersSnipet() |
619 | { |
||
376 | jmachado | 620 | 1.5.0/docs/api/java/lang/String.html">String sep = ""; |
343 | jmachado | 621 | 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder strBuilder = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder(); |
622 | if(teachers != null && teachers.size() > 0) |
||
623 | { |
||
624 | for(UserView userView: teachers) |
||
625 | { |
||
626 | strBuilder |
||
376 | jmachado | 627 | .append(sep) |
628 | .append(" ") |
||
343 | jmachado | 629 | .append(" <a href=\"mailto:") |
630 | .append(userView.getEmail()) |
||
631 | .append("\">") |
||
632 | .append(userView.getName()) |
||
633 | .append("</a>") |
||
634 | |||
376 | jmachado | 635 | ; |
636 | sep = ","; |
||
343 | jmachado | 637 | } |
638 | } |
||
639 | return strBuilder.toString(); |
||
640 | } |
||
405 | jmachado | 641 | |
642 | |||
643 | public List<UserView> getStudentsOrderedByNumber() |
||
644 | { |
||
645 | if(studentsOrderedByNumber == null && students != null) |
||
646 | { |
||
647 | studentsOrderedByNumber = new 1.5.0/docs/api/java/util/ArrayList.html">ArrayList(students); |
||
648 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(studentsOrderedByNumber,new Comparator<UserView>() |
||
649 | { |
||
650 | |||
651 | public int compare(UserView o1, UserView o2) |
||
652 | { |
||
653 | if(o1 == null) |
||
654 | return 1; |
||
655 | if(o2 == null) |
||
656 | return -1; |
||
657 | if(o1.getCode() > o2.getCode()) |
||
658 | return 1; |
||
659 | else if(o1.getCode() < o2.getCode()) |
||
660 | return -1; |
||
661 | else |
||
662 | return 0; |
||
663 | } |
||
664 | } |
||
665 | ); |
||
666 | } |
||
667 | return studentsOrderedByNumber; |
||
668 | } |
||
669 | |||
670 | public List<UserView> getStudentsOrderedByName() |
||
671 | { |
||
672 | if(studentsOrderedByName == null && students != null) |
||
673 | { |
||
674 | studentsOrderedByName = new 1.5.0/docs/api/java/util/ArrayList.html">ArrayList(students); |
||
675 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(studentsOrderedByName,new Comparator<UserView>() |
||
676 | { |
||
677 | |||
678 | public int compare(UserView o1, UserView o2) |
||
679 | { |
||
680 | if(o1 == null || o1.getName() == null) |
||
681 | return 1; |
||
682 | if(o2 == null || o2.getName() == null) |
||
683 | return -1; |
||
684 | return o1.getName().compareTo(o2.getName()); |
||
685 | } |
||
686 | } |
||
687 | ); |
||
688 | } |
||
689 | return studentsOrderedByName; |
||
690 | } |
||
203 | jmachado | 691 | } |