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