Rev 1338 | Rev 1350 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
112 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
1312 | jmachado | 3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.TransformationException; |
||
5 | import org.apache.log4j.Logger; |
||
995 | jmachado | 6 | import pt.estgp.estgweb.Globals; |
1313 | jmachado | 7 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
489 | jmachado | 8 | import pt.estgp.estgweb.domain.enums.CourseUnitContentsGrants; |
1312 | jmachado | 9 | import pt.estgp.estgweb.domain.test.TestCourseUnit; |
10 | import pt.estgp.estgweb.domain.utils.SimpleClearanceRuledSupport; |
||
11 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
12 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
489 | jmachado | 13 | |
1312 | jmachado | 14 | import java.io.IOException; |
146 | jmachado | 15 | import java.io.Serializable; |
1337 | jmachado | 16 | import java.util.*; |
146 | jmachado | 17 | |
112 | jmachado | 18 | /** |
19 | * Created by IntelliJ IDEA. |
||
20 | * User: Jorge Machado |
||
21 | * Date: 7/Mai/2008 |
||
22 | * Time: 20:21:15 |
||
23 | * To change this template use File | Settings | File Templates. |
||
24 | */ |
||
1312 | jmachado | 25 | public class CourseUnitImpl extends CourseUnit implements ICanManage, ClearanceRuled |
146 | jmachado | 26 | { |
489 | jmachado | 27 | |
1312 | jmachado | 28 | 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(CourseUnitImpl.class); |
29 | |||
489 | jmachado | 30 | CourseUnitContentsGrants courseUnitContentsGrants = null; |
31 | |||
146 | jmachado | 32 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() |
33 | { |
||
34 | return getId(); |
||
35 | } |
||
204 | jmachado | 36 | |
489 | jmachado | 37 | |
38 | public CourseUnitContentsGrants getCourseUnitContentsGrants() { |
||
39 | if(courseUnitContentsGrants == null) |
||
40 | courseUnitContentsGrants = CourseUnitContentsGrants.parse(super.getContentsGrants()); |
||
41 | return courseUnitContentsGrants; |
||
42 | } |
||
43 | |||
44 | public void setCourseUnitContentsGrants(CourseUnitContentsGrants courseUnitContentsGrants) { |
||
45 | super.setContentsGrants(courseUnitContentsGrants.name()); |
||
46 | this.courseUnitContentsGrants = courseUnitContentsGrants; |
||
47 | } |
||
48 | |||
204 | jmachado | 49 | public boolean isValid() |
50 | { |
||
51 | return true; //To change body of implemented methods use File | Settings | File Templates. |
||
52 | } |
||
53 | |||
54 | public boolean isOwnedBy(GenericUser u) |
||
55 | { |
||
208 | jmachado | 56 | return isOwnedBy(u, false); |
204 | jmachado | 57 | } |
58 | |||
208 | jmachado | 59 | public boolean isOwnedBy(GenericUser u, boolean transaction) |
60 | { |
||
61 | return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId(),transaction); |
||
62 | } |
||
63 | |||
204 | jmachado | 64 | /** |
65 | * Not implemented can be variuous teachers |
||
66 | * @return null |
||
67 | * use isOwnedBy in this class |
||
68 | */ |
||
69 | public GenericUser getOwner() |
||
70 | { |
||
71 | return null; |
||
72 | } |
||
73 | /** |
||
74 | * Not implemented |
||
75 | * @return |
||
76 | */ |
||
77 | public List<String> getOwnerRoles() |
||
78 | { |
||
79 | return null; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Not implemented |
||
84 | * @return |
||
85 | */ |
||
86 | public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole() |
||
87 | { |
||
88 | return null; |
||
89 | } |
||
90 | |||
91 | public boolean isInternal() |
||
92 | { |
||
251 | jmachado | 93 | return true; |
204 | jmachado | 94 | } |
208 | jmachado | 95 | |
96 | public CourseUnitBlogImpl getUnitBlog() |
||
97 | { |
||
98 | if(getBlogs()!=null && getBlogs().size() > 0) |
||
99 | return (CourseUnitBlogImpl) getBlogs().iterator().next(); |
||
100 | return null; |
||
101 | } |
||
251 | jmachado | 102 | |
1315 | jmachado | 103 | |
1312 | jmachado | 104 | public boolean equalsSiges(5+0%2Fdocs%2Fapi+Object">Object anotherInstance,boolean turmasSeparadas) |
251 | jmachado | 105 | { |
106 | if(anotherInstance instanceof CourseUnitImpl) |
||
107 | { |
||
108 | CourseUnitImpl anCourseUnit = (CourseUnitImpl) anotherInstance; |
||
1312 | jmachado | 109 | if(turmasSeparadas) |
110 | { |
||
111 | boolean turmaVazia = getCdTurma() == null || getCdTurma().trim().length() == 0; |
||
112 | boolean anotherTurmaVazia = anCourseUnit.getCdTurma() == null || anCourseUnit.getCdTurma().trim().length() == 0; |
||
113 | boolean turmasIguais = (turmaVazia && anotherTurmaVazia) || (!turmaVazia && !anotherTurmaVazia && getCdTurma().equals(anCourseUnit.getCdTurma())); |
||
114 | return equalsIgnoringTurma(anotherInstance) |
||
115 | && |
||
116 | turmasIguais; |
||
117 | } |
||
118 | else |
||
119 | return equalsIgnoringTurma(anotherInstance); |
||
251 | jmachado | 120 | } |
121 | return false; |
||
122 | |||
123 | } |
||
489 | jmachado | 124 | |
1204 | jmachado | 125 | public boolean equalsIgnoringTurma(5+0%2Fdocs%2Fapi+Object">Object anotherInstance) |
126 | { |
||
127 | if(anotherInstance instanceof CourseUnitImpl) |
||
128 | { |
||
129 | CourseUnitImpl anCourseUnit = (CourseUnitImpl) anotherInstance; |
||
130 | |||
131 | return anCourseUnit.getCode() != null && getCode() != null && getCode().equals(anCourseUnit.getCode()) && |
||
132 | anCourseUnit.getCourseCode() != null && getCourseCode() != null && getCourseCode().equals(anCourseUnit.getCourseCode()) && |
||
133 | anCourseUnit.getSemestre() != null && getSemestre() != null && getSemestre().equals(anCourseUnit.getSemestre()) && |
||
134 | anCourseUnit.getImportYear() != null && getImportYear() != null && getImportYear().equals(anCourseUnit.getImportYear()); |
||
135 | } |
||
136 | return false; |
||
137 | |||
138 | } |
||
139 | |||
973 | jmachado | 140 | /** |
141 | * Means that is teacher os responsable teacher or from course commission |
||
142 | * Only works in open transaction |
||
143 | * |
||
144 | * Needs Course and Responsable Teacher loaded |
||
145 | */ |
||
146 | public boolean isFromCourseUnitCommission(UserSession userSession) |
||
147 | { |
||
148 | return userSession.getUser()!= null && |
||
149 | (((UserImpl) userSession.getUser()).isTeacherOfCourseUnit(getId(), true) |
||
150 | || (getResponsableTeacher() != null && getResponsableTeacher().getId() == userSession.getUser().getId()) |
||
151 | || userSession.getUser().hasRole(getCourse().getValidationRole()) |
||
152 | ); |
||
153 | } |
||
489 | jmachado | 154 | |
1312 | jmachado | 155 | public boolean isFromCourseCommission(UserSession userSession) |
156 | { |
||
157 | return userSession.getUser()!= null && |
||
158 | userSession.getUser().hasRole(getCourse().getValidationRole()); |
||
159 | } |
||
973 | jmachado | 160 | |
1312 | jmachado | 161 | |
995 | jmachado | 162 | public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathIntranet() |
163 | { |
||
164 | return Globals.FTP_IONLINE_START_PATH + "/" + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_Sumarios; |
||
165 | } |
||
973 | jmachado | 166 | |
1148 | jmachado | 167 | public 1.5.0/docs/api/java/lang/String.html">String getInqueritosPedagogicosPathIntranet() |
168 | { |
||
169 | return Globals.FTP_IONLINE_START_PATH + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_InqueritoPedagogico; |
||
170 | } |
||
171 | |||
172 | |||
995 | jmachado | 173 | public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathFileIntranet() |
174 | { |
||
175 | return getSummariosPathIntranet() + "/" + getSummariosFileNameIntranet(); |
||
176 | } |
||
177 | |||
178 | public 1.5.0/docs/api/java/lang/String.html">String getSummariosFileNameIntranet(){ |
||
179 | return getCode() + "_" + getNormalizedName() + "_sumarios.pdf"; |
||
180 | } |
||
181 | |||
182 | |||
996 | jmachado | 183 | public 1.5.0/docs/api/java/lang/String.html">String getSigesUniqueIdentifiers() |
184 | { |
||
185 | return "SIGES:" + getCode() + ", COURSE: " + getCourseCode() + |
||
1139 | jmachado | 186 | ", " + getSemestre() + " of " + getImportYear() + " - " + getName() + " Turma - " + getCdTurma(); |
996 | jmachado | 187 | } |
188 | |||
1341 | jmachado | 189 | public int studentsSize() |
190 | { |
||
191 | if(getStudents() !=null) |
||
192 | return getStudents().size(); |
||
193 | return 0; |
||
194 | } |
||
1312 | jmachado | 195 | |
1341 | jmachado | 196 | public int studentsTurmaSize() |
197 | { |
||
198 | int countTotalStudentsTurmas = 0; |
||
199 | if(getTurmas() == null) |
||
200 | return 0; |
||
201 | for(CourseUnitTurma turma: getTurmas()) |
||
202 | { |
||
203 | if(turma.getStudents() != null) |
||
204 | countTotalStudentsTurmas+=turma.getStudents().size(); |
||
205 | } |
||
206 | return countTotalStudentsTurmas; |
||
207 | } |
||
208 | |||
209 | |||
1312 | jmachado | 210 | public boolean hasStudent(long studentId, boolean transaction) |
211 | { |
||
212 | Set<StudentImpl> students; |
||
213 | if(transaction) |
||
214 | students = getStudents(); |
||
215 | else |
||
216 | { |
||
217 | IServiceManager sm; |
||
218 | try { |
||
219 | sm = ServiceManager.getInstance(); |
||
220 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"}; |
||
221 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()}; |
||
222 | students = (Set<StudentImpl>) sm.execute(null, "LoadCourseUnitStudents", args, names); |
||
223 | } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) { |
||
224 | logger.error(e,e); |
||
225 | return false; |
||
226 | } |
||
227 | } |
||
228 | if(students == null) |
||
229 | return false; |
||
230 | for(Student s: students) |
||
231 | { |
||
232 | if(s.getId() == studentId) |
||
233 | return true; |
||
234 | } |
||
235 | return false; |
||
236 | } |
||
237 | |||
238 | public boolean hasTeacher(long teacherId, boolean transaction) |
||
239 | { |
||
240 | Set<TeacherImpl> teachers; |
||
241 | if(transaction) |
||
242 | teachers = getTeachers(); |
||
243 | else |
||
244 | { |
||
245 | IServiceManager sm; |
||
246 | try { |
||
247 | sm = ServiceManager.getInstance(); |
||
248 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"}; |
||
249 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()}; |
||
250 | teachers = (Set<TeacherImpl>) sm.execute(null, "LoadCourseUnitTeachers", args, names); |
||
251 | } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) { |
||
252 | logger.error(e,e); |
||
253 | return false; |
||
254 | } |
||
255 | } |
||
256 | if(teachers == null) |
||
257 | return false; |
||
258 | for(Teacher t: teachers) |
||
259 | { |
||
260 | if(t.getId() == teacherId) |
||
261 | return true; |
||
262 | } |
||
263 | return false; |
||
264 | } |
||
265 | |||
266 | public boolean isResponsibleTeacher(long teacherId, boolean transaction) |
||
267 | { |
||
268 | Teacher t; |
||
269 | if(transaction) |
||
270 | t = getResponsableTeacher(); |
||
271 | else |
||
272 | { |
||
273 | IServiceManager sm; |
||
274 | try { |
||
275 | sm = ServiceManager.getInstance(); |
||
276 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"}; |
||
277 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()}; |
||
278 | t = (Teacher) sm.execute(null, "LoadCourseUnitResponsibleTeacher", args, names); |
||
279 | } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) { |
||
280 | logger.error(e,e); |
||
281 | return false; |
||
282 | } |
||
283 | } |
||
284 | if(t == null) |
||
285 | return false; |
||
286 | if(t.getId() == teacherId) |
||
287 | return true; |
||
288 | return false; |
||
289 | } |
||
290 | |||
291 | SimpleClearanceRuledSupport clearanceRuledSupport = null; |
||
292 | |||
293 | public SimpleClearanceRuledSupport getClearanceRuledSupport() { |
||
294 | return clearanceRuledSupport; |
||
295 | } |
||
296 | |||
297 | public void setClearanceRuledSupport(SimpleClearanceRuledSupport clearanceRuledSupport) { |
||
298 | this.clearanceRuledSupport = clearanceRuledSupport; |
||
299 | } |
||
300 | |||
301 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
302 | public boolean isClearanceInitialized(UserSessionImpl u) { |
||
303 | return clearanceRuledSupport == null ? false : |
||
304 | clearanceRuledSupport.isClearanceInitialized(u); |
||
305 | } |
||
306 | |||
307 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
308 | public boolean isClear(UserSessionImpl u, 1.5.0/docs/api/java/lang/String.html">String OP) { |
||
309 | |||
310 | if(clearanceRuledSupport == null) return false; |
||
311 | if(OP.startsWith("EVALUATION") && !OP.startsWith("EVALUATION_INFO") |
||
312 | && clearanceRuledSupport.isClear(u,CourseUnitClearancesOperation.EVALUATION_ALL.name())) |
||
313 | return true; |
||
314 | return clearanceRuledSupport.isClear(u, OP); |
||
315 | } |
||
316 | |||
1326 | jmachado | 317 | @1.5.0/docs/api/java/lang/Override.html">Override |
318 | public void initClearances(UserSessionImpl usession,boolean force) |
||
319 | { |
||
320 | CourseUnitImpl c = this; |
||
321 | 1.5.0/docs/api/java/lang/String.html">String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear(); |
||
322 | List<String> activeDegrees = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveDegrees(); |
||
323 | List<Long> activeCourseIds = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveCourseIds(); |
||
324 | |||
325 | boolean isActiveYear = activeYear != null && c.getImportYear().equals(activeYear); |
||
326 | boolean isActiveDegree = activeDegrees!=null && activeDegrees.contains(c.getCourse().getDegree()); |
||
327 | boolean isActiveCourseId = activeCourseIds!=null && activeCourseIds.contains(c.getCourse().getId()); |
||
328 | |||
329 | boolean activePeriod = (isActiveYear && (isActiveCourseId || isActiveDegree)); |
||
330 | boolean active = activePeriod || c.isEvaluationOpenByAdmin(); |
||
331 | |||
332 | boolean isComplete = c.getCourseUnitEvaluation() != null && c.getCourseUnitEvaluation().isTeacherComplete() && !c.getCourseUnitEvaluation().isClosed(); |
||
333 | boolean isClosed = c.getCourseUnitEvaluation() != null && c.getCourseUnitEvaluation().isClosed(); |
||
334 | boolean isEdit = !isClosed && !isComplete; |
||
335 | |||
336 | |||
337 | SimpleClearanceRuledSupport s = new SimpleClearanceRuledSupport(); |
||
338 | s.setDirty(); |
||
339 | |||
340 | if(isEdit) |
||
341 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_STATE_EDIT.name(),usession); |
||
342 | else if(isComplete) |
||
343 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_STATE_COMPLETE.name(),usession); |
||
344 | else if(isClosed) |
||
345 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_STATE_CLOSED.name(),usession); |
||
346 | |||
347 | if(activePeriod) |
||
348 | { |
||
349 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_ACTIVE.name(),usession); |
||
350 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_ACTIVE_REGULAR_PERIOD.name(),usession); |
||
351 | } |
||
352 | if(c.isEvaluationOpenByAdmin()) |
||
353 | { |
||
354 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_ACTIVE.name(),usession); |
||
355 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_ACTIVE_SPECIAL_ADMIN.name(),usession); |
||
356 | } |
||
357 | |||
358 | |||
359 | if(usession.getUser() != null && usession.getUser().isSuperuserOrAdmin() |
||
360 | || usession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE)) |
||
361 | { |
||
362 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_ALL.name(),usession); |
||
363 | } |
||
364 | |||
365 | if(usession.getUser() != null && usession.getUser() instanceof Teacher) |
||
366 | { |
||
367 | boolean teacher = ((Teacher)(usession.getUser())).isTeacherOfCourseUnit(c.getId(),true); |
||
368 | boolean responsable = c.getResponsableTeacher()!=null && usession.getUser().getId() == c.getResponsableTeacher().getId(); |
||
369 | if(teacher) |
||
370 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_TEACHER.name(), usession); |
||
371 | if(responsable) |
||
372 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_RESP_TEACHER.name(), usession); |
||
373 | if(teacher || responsable) |
||
374 | { |
||
375 | //s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_TEACHER.name(), usession); |
||
376 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITION.name(),usession); |
||
377 | if(active && isEdit) |
||
378 | { |
||
379 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITSAVE.name(),usession); |
||
380 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_TEACHER_PART.name(),usession); |
||
381 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_COMPLETE.name(),usession); |
||
382 | } |
||
383 | } |
||
384 | } |
||
385 | |||
386 | if(usession.getUser() != null && usession.getUser() instanceof Teacher |
||
387 | && (((usession.getUser())).hasRole(c.getCourse().getValidationRole()) |
||
388 | || |
||
389 | ((usession.getUser()) == c.getCourse().getCoordinator())) |
||
390 | ) |
||
391 | { |
||
392 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_COMMISSION.name(), usession); |
||
393 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITION.name(), usession); |
||
394 | if(active && isEdit) |
||
395 | { |
||
396 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITSAVE.name(),usession); |
||
397 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_TEACHER_PART.name(),usession); |
||
398 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_COMISSION_PART.name(),usession); |
||
399 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_COMPLETE.name(),usession); |
||
400 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_CLOSE.name(),usession); |
||
401 | } |
||
402 | else if(active && isComplete) |
||
403 | { |
||
404 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITSAVE.name(),usession); |
||
405 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_TEACHER_PART.name(),usession); |
||
406 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_COMISSION_PART.name(),usession); |
||
407 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_CLOSE.name(),usession); |
||
408 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_EDIT.name(),usession); |
||
409 | } |
||
410 | else if(active && isClosed) |
||
411 | { |
||
412 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_EDIT.name(),usession); |
||
413 | } |
||
414 | } |
||
415 | c.setClearanceRuledSupport(s); |
||
416 | } |
||
417 | |||
1312 | jmachado | 418 | public static enum CourseUnitClearancesOperation |
419 | { |
||
420 | EVALUATION_ALL, //SPECIAL OPERATION FOR DENY AND PERMIT REPLACE FULL CONTROL |
||
421 | |||
422 | //COURSE UNIT EVALUATION |
||
423 | EVALUATION_PERSIST_TEACHER_PART, //SERVICE PERSIST THIS PART |
||
424 | EVALUATION_PERSIST_COMISSION_PART, //SERVICE PERSIST THIS PART |
||
425 | |||
426 | EVALUATION_EDITION, //CAN SEE EDITION SCREEN |
||
427 | EVALUATION_EDITSAVE, //CAN PRESS SAVE |
||
428 | EVALUATION_TRANSITATE_TO_COMPLETE, //CAN_TRANSITATE |
||
429 | EVALUATION_TRANSITATE_TO_CLOSE, //CAN CLOSE |
||
430 | EVALUATION_TRANSITATE_TO_EDIT, //CAN REVERT |
||
431 | |||
432 | EVALUATION_INFO_ACTIVE, //INFO CLEARANCE WHEN ACTIVE |
||
433 | EVALUATION_INFO_ACTIVE_SPECIAL_ADMIN, //INFO CLEARANCE REASON OF BEING ACTIVE |
||
434 | EVALUATION_INFO_ACTIVE_REGULAR_PERIOD, //INFO CLEARANCE REASON OF BEING ACTIVE |
||
435 | |||
436 | EVALUATION_INFO_STATE_EDIT, //INFO CLEARANCE |
||
437 | EVALUATION_INFO_STATE_COMPLETE, //INFO CLEARANCE |
||
438 | EVALUATION_INFO_STATE_CLOSED, //INFO CLEARANCE |
||
439 | |||
440 | EVALUATION_INFO_USER_TEACHER, //INFO CLEARANCE |
||
441 | EVALUATION_INFO_USER_RESP_TEACHER, //INFO CLEARANCE |
||
442 | EVALUATION_INFO_USER_COMMISSION, //INFO CLEARANCE |
||
443 | |||
444 | ; |
||
445 | |||
446 | public static CourseUnitClearancesOperation parse(1.5.0/docs/api/java/lang/String.html">String clearance) |
||
447 | { |
||
448 | if(clearance == null) |
||
449 | return null; |
||
450 | for(CourseUnitClearancesOperation op: CourseUnitClearancesOperation.values()) |
||
451 | { |
||
452 | if(op.name().equals(clearance)) |
||
453 | return op; |
||
454 | } |
||
455 | return null; |
||
456 | } |
||
457 | } |
||
458 | |||
459 | |||
460 | public Tipologias getTipologiasClass() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
461 | { |
||
462 | return Tipologias.deserialize(getTipologias()); |
||
463 | } |
||
464 | |||
465 | public void setTipologiasClass(Tipologias tipologias) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
466 | { |
||
467 | if(tipologias != null) |
||
468 | setTipologias(tipologias.serialize()); |
||
469 | } |
||
470 | |||
1313 | jmachado | 471 | public TipologiaPersistent loadPersistent(Tipologia myTipo) |
472 | { |
||
473 | TipologiaPersistent tipologiaPersistent = new TipologiaPersistent(); |
||
474 | tipologiaPersistent.setHorRef(myTipo.isHorRef()); |
||
475 | tipologiaPersistent.setExtra(myTipo.isExtra()); |
||
476 | tipologiaPersistent.setTeacher(DaoFactory.getTeacherDaoImpl().loadBySigesCode(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(myTipo.getCdDocente()))); |
||
477 | tipologiaPersistent.setCdTipologia(myTipo.getCdTipologia()); |
||
478 | tipologiaPersistent.setOcorrencias(myTipo.getOcorrencias()); |
||
1326 | jmachado | 479 | tipologiaPersistent.setMarkWarning(myTipo.isMarkWarning()); |
480 | tipologiaPersistent.setUse(myTipo.isUse()); |
||
1313 | jmachado | 481 | |
482 | tipologiaPersistent.setCourseUnitTurma(findTurma(myTipo.getCdTurma())); |
||
483 | if(tipologiaPersistent.getCourseUnitTurma() == null || tipologiaPersistent.getTeacher() == null) |
||
484 | { |
||
1338 | jmachado | 485 | logger.error("Turma ou professor nao encontrados enquanto fazia uma tipologia persistente: turma:" + myTipo.getCdTurma() + " teacher code: " + myTipo.getCdDocente()); |
1313 | jmachado | 486 | return null; |
487 | } |
||
488 | return tipologiaPersistent; |
||
489 | } |
||
490 | |||
491 | public CourseUnitTurma findTurma(1.5.0/docs/api/java/lang/String.html">String turma) |
||
492 | { |
||
493 | if(getTurmas() == null) |
||
494 | return null; |
||
495 | for(CourseUnitTurma t: getTurmas()) |
||
496 | { |
||
497 | if(t.getTurma().equals(turma)) |
||
498 | return t; |
||
499 | } |
||
500 | return null; |
||
501 | } |
||
502 | |||
503 | |||
504 | public static class TipologiaPersistent |
||
505 | { |
||
506 | private Teacher teacher; |
||
507 | private CourseUnitTurma courseUnitTurma; |
||
508 | private 1.5.0/docs/api/java/lang/String.html">String cdTipologia; |
||
509 | private 1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias = 0; |
||
510 | protected boolean extra; |
||
511 | protected boolean horRef; |
||
1326 | jmachado | 512 | protected boolean use; //campo auxiliar para marcar se vai ser ou não usada nas afetacoes especificas |
513 | //por omissão apenas as que têm sumários |
||
514 | protected boolean markWarning; //camp |
||
1313 | jmachado | 515 | |
1326 | jmachado | 516 | public boolean isUse() { |
517 | return use; |
||
518 | } |
||
519 | |||
520 | public void setUse(boolean use) { |
||
521 | this.use = use; |
||
522 | } |
||
523 | |||
524 | public boolean isMarkWarning() { |
||
525 | return markWarning; |
||
526 | } |
||
527 | |||
528 | public void setMarkWarning(boolean markWarning) { |
||
529 | this.markWarning = markWarning; |
||
530 | } |
||
531 | |||
1313 | jmachado | 532 | public boolean isExtra() { |
533 | return extra; |
||
534 | } |
||
535 | |||
536 | public boolean isHorRef() { |
||
537 | return horRef; |
||
538 | } |
||
539 | |||
540 | public boolean isSumario() { |
||
541 | return ocorrencias != null && ocorrencias > 0; |
||
542 | } |
||
543 | |||
544 | public void setExtra(boolean extra) { |
||
545 | this.extra = extra; |
||
546 | } |
||
547 | |||
548 | public void setHorRef(boolean horRef) { |
||
549 | this.horRef = horRef; |
||
550 | } |
||
551 | |||
552 | public Teacher getTeacher() { |
||
553 | return teacher; |
||
554 | } |
||
555 | |||
556 | public void setTeacher(Teacher teacher) { |
||
557 | this.teacher = teacher; |
||
558 | } |
||
559 | |||
560 | public CourseUnitTurma getCourseUnitTurma() { |
||
561 | return courseUnitTurma; |
||
562 | } |
||
563 | |||
564 | public void setCourseUnitTurma(CourseUnitTurma courseUnitTurma) { |
||
565 | this.courseUnitTurma = courseUnitTurma; |
||
566 | } |
||
567 | |||
568 | public 1.5.0/docs/api/java/lang/String.html">String getCdTipologia() { |
||
569 | return cdTipologia; |
||
570 | } |
||
571 | |||
572 | public void setCdTipologia(1.5.0/docs/api/java/lang/String.html">String cdTipologia) { |
||
573 | this.cdTipologia = cdTipologia; |
||
574 | } |
||
575 | |||
576 | public 1.5.0/docs/api/java/lang/Integer.html">Integer getOcorrencias() { |
||
1338 | jmachado | 577 | return ocorrencias == null ? 0:ocorrencias; |
1313 | jmachado | 578 | } |
579 | |||
580 | public void setOcorrencias(1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias) { |
||
581 | this.ocorrencias = ocorrencias; |
||
582 | } |
||
583 | } |
||
1312 | jmachado | 584 | /** |
585 | * Os codigos de tipologia devem ser limitados a T TP OT etc |
||
586 | */ |
||
587 | public static class Tipologia |
||
588 | { |
||
1313 | jmachado | 589 | protected 1.5.0/docs/api/java/lang/String.html">String cdDocente; |
590 | protected 1.5.0/docs/api/java/lang/String.html">String cdTurma; |
||
591 | protected 1.5.0/docs/api/java/lang/String.html">String cdTipologia; |
||
592 | protected 1.5.0/docs/api/java/lang/String.html">String dsTipologia; |
||
1338 | jmachado | 593 | protected 1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias = 0; // apenas faz sentido nos sumarios. no horario ref nao. |
1312 | jmachado | 594 | |
1325 | jmachado | 595 | protected boolean use; //campo auxiliar para marcar se vai ser ou não usada nas afetacoes especificas |
596 | //por omissão apenas as que têm sumários |
||
597 | protected boolean markWarning; //campo auxiliar para marcar se vai ser ou não usada nas afetacoes especificas |
||
598 | |||
1313 | jmachado | 599 | protected boolean extra; |
600 | protected boolean horRef; |
||
601 | |||
1325 | jmachado | 602 | public boolean isUse() { |
603 | return use; |
||
604 | } |
||
605 | |||
606 | public void setUse(boolean use) { |
||
607 | this.use = use; |
||
608 | } |
||
609 | |||
610 | public boolean isMarkWarning() { |
||
611 | return markWarning; |
||
612 | } |
||
613 | |||
614 | public void setMarkWarning(boolean markWarning) { |
||
615 | this.markWarning = markWarning; |
||
616 | } |
||
617 | |||
1312 | jmachado | 618 | public 1.5.0/docs/api/java/lang/Integer.html">Integer getOcorrencias() { |
1338 | jmachado | 619 | return ocorrencias == null ? 0:ocorrencias; |
1312 | jmachado | 620 | } |
621 | |||
1338 | jmachado | 622 | public boolean hasOcorrencias() { |
623 | return ocorrencias != null && ocorrencias > 0; |
||
624 | } |
||
625 | |||
1312 | jmachado | 626 | public void setOcorrencias(1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias) { |
627 | this.ocorrencias = ocorrencias; |
||
628 | } |
||
629 | |||
630 | public 1.5.0/docs/api/java/lang/String.html">String getCdDocente() { |
||
631 | return cdDocente; |
||
632 | } |
||
633 | |||
634 | public void setCdDocente(1.5.0/docs/api/java/lang/String.html">String cdDocente) { |
||
635 | this.cdDocente = cdDocente; |
||
636 | } |
||
637 | |||
638 | public 1.5.0/docs/api/java/lang/String.html">String getCdTurma() { |
||
639 | return cdTurma; |
||
640 | } |
||
641 | |||
642 | public void setCdTurma(1.5.0/docs/api/java/lang/String.html">String cdTurma) { |
||
643 | this.cdTurma = cdTurma; |
||
644 | } |
||
645 | |||
646 | public 1.5.0/docs/api/java/lang/String.html">String getCdTipologia() { |
||
647 | return cdTipologia; |
||
648 | } |
||
649 | |||
650 | public void setCdTipologia(1.5.0/docs/api/java/lang/String.html">String cdTipologia) { |
||
651 | this.cdTipologia = cdTipologia; |
||
652 | } |
||
653 | |||
1313 | jmachado | 654 | public 1.5.0/docs/api/java/lang/String.html">String getDsTipologia() { |
655 | return dsTipologia; |
||
656 | } |
||
657 | |||
658 | public void setDsTipologia(1.5.0/docs/api/java/lang/String.html">String dsTipologia) { |
||
659 | this.dsTipologia = dsTipologia; |
||
660 | } |
||
661 | |||
662 | public boolean isExtra() { |
||
663 | return extra; |
||
664 | } |
||
665 | |||
666 | public boolean isSumario() { |
||
667 | return ocorrencias != null && ocorrencias > 0; |
||
668 | } |
||
669 | |||
670 | public boolean isHorRef() { |
||
671 | return horRef; |
||
672 | } |
||
673 | |||
674 | |||
675 | |||
1312 | jmachado | 676 | @1.5.0/docs/api/java/lang/Override.html">Override |
677 | public boolean equals(5+0%2Fdocs%2Fapi+Object">Object o) |
||
678 | { |
||
679 | return o instanceof Tipologia && |
||
680 | ((((Tipologia)o).getCdTurma() == null && getCdTurma() == null) |
||
681 | || |
||
682 | (((Tipologia)o).getCdTurma().equals(getCdTurma()))) |
||
683 | && |
||
684 | |||
685 | ( |
||
686 | (((Tipologia)o).getCdDocente() == null && getCdDocente() == null) |
||
687 | || |
||
688 | (((Tipologia)o).getCdDocente().equals(getCdDocente()))) |
||
689 | && |
||
690 | |||
691 | ( |
||
692 | (((Tipologia)o).getCdTipologia() == null && getCdTipologia() == null) |
||
693 | || |
||
694 | (((Tipologia)o).getCdTipologia().equals(getCdTipologia()))); |
||
695 | } |
||
1313 | jmachado | 696 | |
697 | public boolean equalsIncDsFields(5+0%2Fdocs%2Fapi+Object">Object o) |
||
698 | { |
||
699 | return o instanceof Tipologia && |
||
700 | equals(o) |
||
701 | && |
||
702 | ( |
||
703 | (((Tipologia)o).getDsTipologia() == null && getDsTipologia() == null) |
||
704 | || |
||
705 | (((Tipologia)o).getDsTipologia().equals(getDsTipologia()))) |
||
706 | && |
||
707 | |||
708 | ( |
||
709 | (((Tipologia)o).getOcorrencias() == null && getOcorrencias() == null) |
||
710 | || |
||
711 | (((Tipologia)o).getOcorrencias().equals(getOcorrencias()))) |
||
712 | ; |
||
713 | } |
||
1312 | jmachado | 714 | } |
715 | |||
1326 | jmachado | 716 | public static class MergedTipologias |
717 | { |
||
718 | ArrayList<Tipologia> tipologiasWithMarkedAndUsed = new ArrayList<Tipologia>(); |
||
719 | |||
720 | public ArrayList<Tipologia> getTipologiasWithMarkedAndUsed() { |
||
721 | return tipologiasWithMarkedAndUsed; |
||
722 | } |
||
723 | |||
724 | public void setTipologiasWithMarkedAndUsed(ArrayList<Tipologia> tipologiasWithMarkedAndUsed) { |
||
725 | this.tipologiasWithMarkedAndUsed = tipologiasWithMarkedAndUsed; |
||
726 | } |
||
727 | } |
||
1312 | jmachado | 728 | public static class Tipologias |
729 | { |
||
1313 | jmachado | 730 | ArrayList<Tipologia> tipologiasHorarioReferencia = new ArrayList<Tipologia>(); |
731 | ArrayList<Tipologia> tipologiasSumarios = new ArrayList<Tipologia>(); |
||
732 | ArrayList<Tipologia> tipologiasExtraAdicionadas = new ArrayList<Tipologia>(); |
||
1326 | jmachado | 733 | ArrayList<Tipologia> tipologiasUsadas = new ArrayList<Tipologia>(); |
734 | ArrayList<Tipologia> tipologiasMarcadas = new ArrayList<Tipologia>(); |
||
1312 | jmachado | 735 | |
736 | public ArrayList<Tipologia> getTipologiasHorarioReferencia() { |
||
1333 | jmachado | 737 | |
738 | return tipologiasHorarioReferencia == null ? new ArrayList<Tipologia>() : tipologiasHorarioReferencia; |
||
739 | |||
1312 | jmachado | 740 | } |
741 | |||
742 | public void setTipologiasHorarioReferencia(ArrayList<Tipologia> tipologiasHorarioReferencia) { |
||
743 | this.tipologiasHorarioReferencia = tipologiasHorarioReferencia; |
||
744 | } |
||
745 | |||
746 | public ArrayList<Tipologia> getTipologiasSumarios() { |
||
1333 | jmachado | 747 | return tipologiasSumarios == null ? new ArrayList<Tipologia>() : tipologiasSumarios; |
1312 | jmachado | 748 | } |
749 | |||
750 | public void setTipologiasSumarios(ArrayList<Tipologia> tipologiasSumarios) { |
||
751 | this.tipologiasSumarios = tipologiasSumarios; |
||
752 | } |
||
753 | |||
754 | public ArrayList<Tipologia> getTipologiasExtraAdicionadas() { |
||
1333 | jmachado | 755 | return tipologiasExtraAdicionadas == null ? new ArrayList<Tipologia>() : tipologiasExtraAdicionadas; |
1312 | jmachado | 756 | } |
757 | |||
758 | public void setTipologiasExtraAdicionadas(ArrayList<Tipologia> tipologiasExtraAdicionadas) { |
||
759 | this.tipologiasExtraAdicionadas = tipologiasExtraAdicionadas; |
||
760 | } |
||
761 | |||
1333 | jmachado | 762 | public ArrayList<Tipologia> getTipologiasUsadas() { |
763 | return tipologiasUsadas == null ? new ArrayList<Tipologia>() : tipologiasUsadas; |
||
764 | } |
||
1326 | jmachado | 765 | |
766 | public void setTipologiasUsadas(ArrayList<Tipologia> tipologiasUsadas) { this.tipologiasUsadas = tipologiasUsadas; } |
||
767 | |||
1333 | jmachado | 768 | public ArrayList<Tipologia> getTipologiasMarcadas() { |
769 | return tipologiasMarcadas == null ? new ArrayList<Tipologia>() : tipologiasMarcadas; |
||
770 | } |
||
1326 | jmachado | 771 | |
772 | public void setTipologiasMarcadas(ArrayList<Tipologia> tipologiasMarcadas) { this.tipologiasMarcadas = tipologiasMarcadas; } |
||
773 | |||
1312 | jmachado | 774 | private static Genson getGenson(){ |
775 | Genson genson = new Genson.Builder() |
||
776 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
||
777 | .include("tipologiasExtraAdicionadas", Tipologias.class) |
||
778 | .include("tipologiasSumarios", Tipologias.class) |
||
779 | .include("tipologiasHorarioReferencia", Tipologias.class) |
||
1326 | jmachado | 780 | .include("tipologiasUsadas", Tipologias.class) |
781 | .include("tipologiasMarcadas", Tipologias.class) |
||
1312 | jmachado | 782 | .include("cdTipologia", Tipologia.class) |
783 | .include("cdDocente", Tipologia.class) |
||
784 | .include("cdTurma", Tipologia.class) |
||
1313 | jmachado | 785 | .include("dsTipologia",Tipologia.class) |
1312 | jmachado | 786 | .include("ocorrencias", Tipologia.class) |
787 | .create(); |
||
788 | return genson; |
||
789 | } |
||
790 | |||
1326 | jmachado | 791 | private static Genson getGensonMergedTipologiasComplete(){ |
792 | Genson genson = new Genson.Builder() |
||
793 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
||
794 | |||
795 | .include("tipologiasWithMarkedAndUsed", MergedTipologias.class) |
||
796 | .include("cdTipologia", Tipologia.class) |
||
797 | .include("cdDocente", Tipologia.class) |
||
798 | .include("cdTurma", Tipologia.class) |
||
799 | .include("dsTipologia",Tipologia.class) |
||
800 | .include("ocorrencias", Tipologia.class) |
||
801 | .include("horRef", Tipologia.class) |
||
802 | .include("extra", Tipologia.class) |
||
803 | .include("use", Tipologia.class) |
||
804 | .include("markWarning", Tipologia.class) |
||
805 | .create(); |
||
806 | return genson; |
||
807 | } |
||
808 | |||
1312 | jmachado | 809 | public 1.5.0/docs/api/java/lang/String.html">String serialize() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
810 | { |
||
811 | Genson genson = getGenson(); |
||
812 | try { |
||
813 | return genson.serialize(this); |
||
814 | } catch (TransformationException e) { |
||
815 | throw e; |
||
816 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
817 | throw e; |
||
818 | } |
||
819 | } |
||
820 | public static Tipologias deserialize(1.5.0/docs/api/java/lang/String.html">String serial) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
821 | { |
||
822 | if(serial == null) |
||
1333 | jmachado | 823 | return new Tipologias(); |
1312 | jmachado | 824 | try { |
825 | return getGenson().deserialize(serial, Tipologias.class); |
||
826 | } catch (TransformationException e) { |
||
827 | throw e; |
||
828 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
829 | throw e; |
||
830 | } |
||
831 | } |
||
832 | |||
833 | public static void main(1.5.0/docs/api/java/lang/String.html">String [] args) |
||
834 | { |
||
835 | new TestCourseUnit().testTipologias(); |
||
836 | } |
||
1313 | jmachado | 837 | |
1326 | jmachado | 838 | public static 1.5.0/docs/api/java/lang/String.html">String serializeMergedList(ArrayList<Tipologia> tipologias) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
1313 | jmachado | 839 | { |
1326 | jmachado | 840 | MergedTipologias mergedTipologias = new MergedTipologias(); |
1333 | jmachado | 841 | if(tipologias != null) |
842 | { |
||
843 | mergedTipologias.setTipologiasWithMarkedAndUsed(tipologias); |
||
844 | } |
||
1326 | jmachado | 845 | Genson genson = getGensonMergedTipologiasComplete(); |
846 | try { |
||
847 | return genson.serialize(mergedTipologias); |
||
848 | } catch (TransformationException e) { |
||
849 | throw e; |
||
850 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
851 | throw e; |
||
852 | } |
||
853 | } |
||
854 | public static ArrayList<Tipologia> deserializeMergedTipologias(1.5.0/docs/api/java/lang/String.html">String serial) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
855 | { |
||
856 | if(serial == null) |
||
1333 | jmachado | 857 | return new ArrayList<Tipologia>(); |
1326 | jmachado | 858 | try { |
859 | MergedTipologias mergedTipologias = getGensonMergedTipologiasComplete().deserialize(serial, MergedTipologias.class); |
||
860 | if(mergedTipologias.getTipologiasWithMarkedAndUsed() == null) |
||
861 | return new ArrayList<Tipologia>(); |
||
862 | return mergedTipologias.getTipologiasWithMarkedAndUsed(); |
||
863 | } catch (TransformationException e) { |
||
864 | throw e; |
||
865 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
866 | throw e; |
||
867 | } |
||
868 | } |
||
1332 | jmachado | 869 | public 1.5.0/docs/api/java/lang/String.html">String obtainMergeTipologiasSerialized() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
870 | { |
||
871 | return serializeMergedList(obtainMergeTipologias()); |
||
872 | } |
||
1337 | jmachado | 873 | |
1326 | jmachado | 874 | public ArrayList<Tipologia> obtainMergeTipologias() |
875 | { |
||
876 | ArrayList<Tipologia> merge = new ArrayList<Tipologia>(); |
||
1315 | jmachado | 877 | if(getTipologiasSumarios() != null) |
878 | merge.addAll(getTipologiasSumarios()); |
||
1313 | jmachado | 879 | |
1315 | jmachado | 880 | if(getTipologiasHorarioReferencia() != null) |
881 | for(Tipologia tipo: getTipologiasHorarioReferencia()) |
||
1313 | jmachado | 882 | { |
1315 | jmachado | 883 | if(!merge.contains(tipo)) |
884 | { |
||
885 | merge.add(tipo); |
||
886 | } |
||
1313 | jmachado | 887 | } |
1315 | jmachado | 888 | if(getTipologiasExtraAdicionadas() != null) |
889 | for(Tipologia tipo: getTipologiasExtraAdicionadas()) |
||
1313 | jmachado | 890 | { |
1315 | jmachado | 891 | if(!merge.contains(tipo)) |
892 | { |
||
893 | merge.add(tipo); |
||
894 | } |
||
1313 | jmachado | 895 | } |
896 | for(Tipologia tipo: merge) |
||
897 | { |
||
1326 | jmachado | 898 | tipo.setMarkWarning(false); |
899 | tipo.setUse(false); |
||
1315 | jmachado | 900 | if(getTipologiasHorarioReferencia() != null && getTipologiasHorarioReferencia().contains(tipo)) |
1313 | jmachado | 901 | { |
902 | tipo.horRef = true; |
||
903 | } |
||
904 | |||
1315 | jmachado | 905 | if(getTipologiasExtraAdicionadas() != null && getTipologiasExtraAdicionadas().contains(tipo)) |
1313 | jmachado | 906 | { |
907 | tipo.extra = true; |
||
908 | } |
||
909 | } |
||
1326 | jmachado | 910 | |
911 | if(getTipologiasMarcadas() != null) |
||
912 | for(Tipologia t: getTipologiasMarcadas()) |
||
913 | { |
||
914 | for(Tipologia tMerge: merge) |
||
915 | { |
||
916 | if(tMerge.equals(t)) |
||
917 | { |
||
918 | tMerge.setMarkWarning(true); |
||
919 | break; |
||
920 | } |
||
921 | } |
||
922 | } |
||
923 | if(getTipologiasUsadas() != null) |
||
924 | for(Tipologia t: getTipologiasUsadas()) |
||
925 | { |
||
926 | for(Tipologia tMerge: merge) |
||
927 | { |
||
928 | if(tMerge.equals(t)) |
||
929 | { |
||
930 | tMerge.setUse(true); |
||
931 | break; |
||
932 | } |
||
933 | } |
||
934 | } |
||
1313 | jmachado | 935 | return merge; |
936 | } |
||
937 | |||
938 | |||
1337 | jmachado | 939 | public ArrayList<Tipologia> obtainTipologiasSimples(CourseUnit courseUnit) |
940 | { |
||
941 | ArrayList<Tipologia> merge = new ArrayList<Tipologia>(); |
||
942 | |||
943 | Map<String,Map<String,Tipologia>> docenteTurmas = new HashMap<String,Map<String,Tipologia>>(); |
||
944 | |||
945 | fullfillTipologiasSimples(getTipologiasSumarios(), docenteTurmas); |
||
946 | fullfillTipologiasSimples(getTipologiasExtraAdicionadas(), docenteTurmas); |
||
947 | fullfillTipologiasSimples(getTipologiasHorarioReferencia(), docenteTurmas); |
||
948 | fullfillTipologiasSimples(getTipologiasMarcadas(), docenteTurmas); |
||
949 | fullfillTipologiasSimples(getTipologiasUsadas(), docenteTurmas); |
||
950 | |||
951 | |||
952 | if(docenteTurmas.size() == 0) |
||
953 | { |
||
954 | //NAO Há sumários vamos associar todos os docentes a todas as turmas |
||
955 | if(courseUnit.getTurmas() != null && courseUnit.getTeachers() != null) |
||
956 | { |
||
957 | for(CourseUnitTurma turma: courseUnit.getTurmas()) |
||
958 | { |
||
959 | for(Teacher t : courseUnit.getTeachers()) |
||
960 | { |
||
961 | Tipologia simples = new Tipologia(); |
||
962 | simples.setMarkWarning(true); |
||
963 | simples.setCdDocente(""+t.getSigesCode()); |
||
964 | simples.setCdTurma(turma.getTurma()); |
||
965 | simples.setCdTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_VIRTUAL_CODE); |
||
966 | simples.setDsTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_DS); |
||
967 | merge.add(simples); |
||
968 | } |
||
969 | } |
||
970 | } |
||
971 | } |
||
972 | else |
||
973 | { |
||
974 | for(1.5.0/docs/api/java/util/Map.html">Map.Entry<String,Map<String,Tipologia>> docentes: docenteTurmas.entrySet()) |
||
975 | { |
||
976 | for(Tipologia tipologia: docentes.getValue().values()) |
||
977 | { |
||
978 | merge.add(tipologia); |
||
979 | } |
||
980 | } |
||
981 | } |
||
982 | return merge; |
||
983 | } |
||
984 | |||
985 | private void fullfillTipologiasSimples(ArrayList<Tipologia> tipologias, Map<String, Map<String, Tipologia>> docenteTurmas) { |
||
986 | if(tipologias != null) |
||
987 | for(Tipologia tipo: tipologias) |
||
988 | { |
||
989 | Map<String,Tipologia> turmasDocente = docenteTurmas.get(tipo.getCdDocente()); |
||
990 | if(turmasDocente == null) |
||
991 | turmasDocente = new HashMap<String,Tipologia>(); |
||
992 | docenteTurmas.put(tipo.getCdDocente(),turmasDocente); |
||
993 | Tipologia simples = turmasDocente.get(tipo.getCdTurma()); |
||
994 | if(simples==null) |
||
995 | { |
||
996 | simples = new Tipologia(); |
||
997 | simples.setCdDocente(tipo.getCdDocente()); |
||
998 | simples.setCdTurma(tipo.getCdTurma()); |
||
999 | simples.setCdTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_VIRTUAL_CODE); |
||
1000 | simples.setDsTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_DS); |
||
1338 | jmachado | 1001 | if(tipo.hasOcorrencias()) |
1337 | jmachado | 1002 | { |
1003 | simples.setOcorrencias(tipo.getOcorrencias()); |
||
1004 | } |
||
1005 | turmasDocente.put(tipo.getCdTurma(),simples); |
||
1006 | } |
||
1338 | jmachado | 1007 | if(tipo.hasOcorrencias()) |
1337 | jmachado | 1008 | { |
1338 | jmachado | 1009 | if(simples.getOcorrencias() == null) |
1010 | simples.setOcorrencias(0); |
||
1337 | jmachado | 1011 | simples.setOcorrencias(simples.getOcorrencias()+tipo.getOcorrencias()); |
1012 | } |
||
1013 | |||
1014 | } |
||
1015 | } |
||
1016 | |||
1017 | |||
1312 | jmachado | 1018 | } |
1019 | |||
1020 | |||
1021 | |||
1022 | |||
1023 | |||
112 | jmachado | 1024 | } |