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