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