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