Rev 1341 | Rev 1365 | 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); |
||
1350 | jmachado | 363 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_CAN_VALIDATE.name(),usession); |
364 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_TEACHER_PART.name(),usession); |
||
365 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_COORDINATOR_PART.name(),usession); |
||
1326 | jmachado | 366 | } |
367 | |||
368 | if(usession.getUser() != null && usession.getUser() instanceof Teacher) |
||
369 | { |
||
1350 | jmachado | 370 | Teacher t = ((Teacher)(usession.getUser())); |
1326 | jmachado | 371 | boolean teacher = ((Teacher)(usession.getUser())).isTeacherOfCourseUnit(c.getId(),true); |
372 | boolean responsable = c.getResponsableTeacher()!=null && usession.getUser().getId() == c.getResponsableTeacher().getId(); |
||
1350 | jmachado | 373 | boolean isCoordinator = (c.getCourse().getCoordinator() != null && t.getId() == c.getCourse().getCoordinator().getId()) || (c.getCourse().getValidationRole() != null && t.hasRole(c.getCourse().getValidationRole())); |
1326 | jmachado | 374 | if(teacher) |
1350 | jmachado | 375 | { |
1326 | jmachado | 376 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_TEACHER.name(), usession); |
1350 | jmachado | 377 | } |
1326 | jmachado | 378 | if(responsable) |
1350 | jmachado | 379 | { |
1326 | jmachado | 380 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_RESP_TEACHER.name(), usession); |
1350 | jmachado | 381 | } |
1326 | jmachado | 382 | if(teacher || responsable) |
383 | { |
||
384 | //s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_TEACHER.name(), usession); |
||
385 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITION.name(),usession); |
||
386 | if(active && isEdit) |
||
387 | { |
||
388 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITSAVE.name(),usession); |
||
389 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_TEACHER_PART.name(),usession); |
||
390 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_COMPLETE.name(),usession); |
||
391 | } |
||
392 | } |
||
393 | |||
1350 | jmachado | 394 | if(isCoordinator) |
1326 | jmachado | 395 | { |
1350 | jmachado | 396 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_CAN_VALIDATE.name(),usession); |
397 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_INFO_USER_COMMISSION.name(), usession); |
||
398 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITION.name(), usession); |
||
399 | if(active && isEdit) |
||
400 | { |
||
401 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITSAVE.name(),usession); |
||
402 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_TEACHER_PART.name(),usession); |
||
403 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_COMISSION_PART.name(),usession); |
||
404 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_COMPLETE.name(),usession); |
||
405 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_CLOSE.name(),usession); |
||
406 | } |
||
407 | else if(active && isComplete) |
||
408 | { |
||
409 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_EDITSAVE.name(),usession); |
||
410 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_TEACHER_PART.name(),usession); |
||
411 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_PERSIST_COMISSION_PART.name(),usession); |
||
412 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_CLOSE.name(),usession); |
||
413 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_EDIT.name(),usession); |
||
414 | } |
||
415 | else if(active && isClosed) |
||
416 | { |
||
417 | s.addClearance(CourseUnitClearancesOperation.EVALUATION_TRANSITATE_TO_EDIT.name(),usession); |
||
418 | } |
||
1326 | jmachado | 419 | } |
1350 | jmachado | 420 | |
421 | |||
422 | if(!c.isValidProgram()) |
||
1326 | jmachado | 423 | { |
1350 | jmachado | 424 | if(teacher) |
425 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_TEACHER_PART.name(), usession); |
||
426 | if(isCoordinator) |
||
427 | { |
||
428 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_TEACHER_PART.name(), usession); |
||
429 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_COORDINATOR_PART.name(), usession); |
||
430 | } |
||
1326 | jmachado | 431 | } |
1350 | jmachado | 432 | else |
1326 | jmachado | 433 | { |
1350 | jmachado | 434 | s.addClearance(CourseUnitClearancesOperation.PROGRAM_INFO_VALID_NOT_ACTIVE.name(), usession); |
1326 | jmachado | 435 | } |
1350 | jmachado | 436 | |
1326 | jmachado | 437 | } |
1350 | jmachado | 438 | |
1326 | jmachado | 439 | c.setClearanceRuledSupport(s); |
440 | } |
||
441 | |||
1312 | jmachado | 442 | public static enum CourseUnitClearancesOperation |
443 | { |
||
444 | EVALUATION_ALL, //SPECIAL OPERATION FOR DENY AND PERMIT REPLACE FULL CONTROL |
||
445 | |||
446 | //COURSE UNIT EVALUATION |
||
447 | EVALUATION_PERSIST_TEACHER_PART, //SERVICE PERSIST THIS PART |
||
448 | EVALUATION_PERSIST_COMISSION_PART, //SERVICE PERSIST THIS PART |
||
449 | |||
450 | EVALUATION_EDITION, //CAN SEE EDITION SCREEN |
||
451 | EVALUATION_EDITSAVE, //CAN PRESS SAVE |
||
452 | EVALUATION_TRANSITATE_TO_COMPLETE, //CAN_TRANSITATE |
||
453 | EVALUATION_TRANSITATE_TO_CLOSE, //CAN CLOSE |
||
454 | EVALUATION_TRANSITATE_TO_EDIT, //CAN REVERT |
||
455 | |||
456 | EVALUATION_INFO_ACTIVE, //INFO CLEARANCE WHEN ACTIVE |
||
457 | EVALUATION_INFO_ACTIVE_SPECIAL_ADMIN, //INFO CLEARANCE REASON OF BEING ACTIVE |
||
458 | EVALUATION_INFO_ACTIVE_REGULAR_PERIOD, //INFO CLEARANCE REASON OF BEING ACTIVE |
||
459 | |||
460 | EVALUATION_INFO_STATE_EDIT, //INFO CLEARANCE |
||
461 | EVALUATION_INFO_STATE_COMPLETE, //INFO CLEARANCE |
||
462 | EVALUATION_INFO_STATE_CLOSED, //INFO CLEARANCE |
||
463 | |||
464 | EVALUATION_INFO_USER_TEACHER, //INFO CLEARANCE |
||
465 | EVALUATION_INFO_USER_RESP_TEACHER, //INFO CLEARANCE |
||
466 | EVALUATION_INFO_USER_COMMISSION, //INFO CLEARANCE |
||
467 | |||
1350 | jmachado | 468 | |
469 | PROGRAM_COORDINATOR_PART, |
||
470 | PROGRAM_TEACHER_PART, |
||
471 | PROGRAM_CAN_VALIDATE, |
||
472 | PROGRAM_INFO_VALID_NOT_ACTIVE |
||
473 | |||
1312 | jmachado | 474 | ; |
475 | |||
476 | public static CourseUnitClearancesOperation parse(1.5.0/docs/api/java/lang/String.html">String clearance) |
||
477 | { |
||
478 | if(clearance == null) |
||
479 | return null; |
||
480 | for(CourseUnitClearancesOperation op: CourseUnitClearancesOperation.values()) |
||
481 | { |
||
482 | if(op.name().equals(clearance)) |
||
483 | return op; |
||
484 | } |
||
485 | return null; |
||
486 | } |
||
487 | } |
||
488 | |||
489 | |||
490 | public Tipologias getTipologiasClass() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
491 | { |
||
492 | return Tipologias.deserialize(getTipologias()); |
||
493 | } |
||
494 | |||
495 | public void setTipologiasClass(Tipologias tipologias) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
496 | { |
||
497 | if(tipologias != null) |
||
498 | setTipologias(tipologias.serialize()); |
||
499 | } |
||
500 | |||
1313 | jmachado | 501 | public TipologiaPersistent loadPersistent(Tipologia myTipo) |
502 | { |
||
503 | TipologiaPersistent tipologiaPersistent = new TipologiaPersistent(); |
||
504 | tipologiaPersistent.setHorRef(myTipo.isHorRef()); |
||
505 | tipologiaPersistent.setExtra(myTipo.isExtra()); |
||
506 | tipologiaPersistent.setTeacher(DaoFactory.getTeacherDaoImpl().loadBySigesCode(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(myTipo.getCdDocente()))); |
||
507 | tipologiaPersistent.setCdTipologia(myTipo.getCdTipologia()); |
||
508 | tipologiaPersistent.setOcorrencias(myTipo.getOcorrencias()); |
||
1326 | jmachado | 509 | tipologiaPersistent.setMarkWarning(myTipo.isMarkWarning()); |
510 | tipologiaPersistent.setUse(myTipo.isUse()); |
||
1313 | jmachado | 511 | |
512 | tipologiaPersistent.setCourseUnitTurma(findTurma(myTipo.getCdTurma())); |
||
513 | if(tipologiaPersistent.getCourseUnitTurma() == null || tipologiaPersistent.getTeacher() == null) |
||
514 | { |
||
1338 | jmachado | 515 | logger.error("Turma ou professor nao encontrados enquanto fazia uma tipologia persistente: turma:" + myTipo.getCdTurma() + " teacher code: " + myTipo.getCdDocente()); |
1313 | jmachado | 516 | return null; |
517 | } |
||
518 | return tipologiaPersistent; |
||
519 | } |
||
520 | |||
521 | public CourseUnitTurma findTurma(1.5.0/docs/api/java/lang/String.html">String turma) |
||
522 | { |
||
523 | if(getTurmas() == null) |
||
524 | return null; |
||
525 | for(CourseUnitTurma t: getTurmas()) |
||
526 | { |
||
527 | if(t.getTurma().equals(turma)) |
||
528 | return t; |
||
529 | } |
||
530 | return null; |
||
531 | } |
||
532 | |||
533 | |||
534 | public static class TipologiaPersistent |
||
535 | { |
||
536 | private Teacher teacher; |
||
537 | private CourseUnitTurma courseUnitTurma; |
||
538 | private 1.5.0/docs/api/java/lang/String.html">String cdTipologia; |
||
539 | private 1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias = 0; |
||
540 | protected boolean extra; |
||
541 | protected boolean horRef; |
||
1326 | jmachado | 542 | protected boolean use; //campo auxiliar para marcar se vai ser ou não usada nas afetacoes especificas |
543 | //por omissão apenas as que têm sumários |
||
544 | protected boolean markWarning; //camp |
||
1313 | jmachado | 545 | |
1326 | jmachado | 546 | public boolean isUse() { |
547 | return use; |
||
548 | } |
||
549 | |||
550 | public void setUse(boolean use) { |
||
551 | this.use = use; |
||
552 | } |
||
553 | |||
554 | public boolean isMarkWarning() { |
||
555 | return markWarning; |
||
556 | } |
||
557 | |||
558 | public void setMarkWarning(boolean markWarning) { |
||
559 | this.markWarning = markWarning; |
||
560 | } |
||
561 | |||
1313 | jmachado | 562 | public boolean isExtra() { |
563 | return extra; |
||
564 | } |
||
565 | |||
566 | public boolean isHorRef() { |
||
567 | return horRef; |
||
568 | } |
||
569 | |||
570 | public boolean isSumario() { |
||
571 | return ocorrencias != null && ocorrencias > 0; |
||
572 | } |
||
573 | |||
574 | public void setExtra(boolean extra) { |
||
575 | this.extra = extra; |
||
576 | } |
||
577 | |||
578 | public void setHorRef(boolean horRef) { |
||
579 | this.horRef = horRef; |
||
580 | } |
||
581 | |||
582 | public Teacher getTeacher() { |
||
583 | return teacher; |
||
584 | } |
||
585 | |||
586 | public void setTeacher(Teacher teacher) { |
||
587 | this.teacher = teacher; |
||
588 | } |
||
589 | |||
590 | public CourseUnitTurma getCourseUnitTurma() { |
||
591 | return courseUnitTurma; |
||
592 | } |
||
593 | |||
594 | public void setCourseUnitTurma(CourseUnitTurma courseUnitTurma) { |
||
595 | this.courseUnitTurma = courseUnitTurma; |
||
596 | } |
||
597 | |||
598 | public 1.5.0/docs/api/java/lang/String.html">String getCdTipologia() { |
||
599 | return cdTipologia; |
||
600 | } |
||
601 | |||
602 | public void setCdTipologia(1.5.0/docs/api/java/lang/String.html">String cdTipologia) { |
||
603 | this.cdTipologia = cdTipologia; |
||
604 | } |
||
605 | |||
606 | public 1.5.0/docs/api/java/lang/Integer.html">Integer getOcorrencias() { |
||
1338 | jmachado | 607 | return ocorrencias == null ? 0:ocorrencias; |
1313 | jmachado | 608 | } |
609 | |||
610 | public void setOcorrencias(1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias) { |
||
611 | this.ocorrencias = ocorrencias; |
||
612 | } |
||
613 | } |
||
1312 | jmachado | 614 | /** |
615 | * Os codigos de tipologia devem ser limitados a T TP OT etc |
||
616 | */ |
||
617 | public static class Tipologia |
||
618 | { |
||
1313 | jmachado | 619 | protected 1.5.0/docs/api/java/lang/String.html">String cdDocente; |
620 | protected 1.5.0/docs/api/java/lang/String.html">String cdTurma; |
||
621 | protected 1.5.0/docs/api/java/lang/String.html">String cdTipologia; |
||
622 | protected 1.5.0/docs/api/java/lang/String.html">String dsTipologia; |
||
1338 | jmachado | 623 | protected 1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias = 0; // apenas faz sentido nos sumarios. no horario ref nao. |
1312 | jmachado | 624 | |
1325 | jmachado | 625 | protected boolean use; //campo auxiliar para marcar se vai ser ou não usada nas afetacoes especificas |
626 | //por omissão apenas as que têm sumários |
||
627 | protected boolean markWarning; //campo auxiliar para marcar se vai ser ou não usada nas afetacoes especificas |
||
628 | |||
1313 | jmachado | 629 | protected boolean extra; |
630 | protected boolean horRef; |
||
631 | |||
1325 | jmachado | 632 | public boolean isUse() { |
633 | return use; |
||
634 | } |
||
635 | |||
636 | public void setUse(boolean use) { |
||
637 | this.use = use; |
||
638 | } |
||
639 | |||
640 | public boolean isMarkWarning() { |
||
641 | return markWarning; |
||
642 | } |
||
643 | |||
644 | public void setMarkWarning(boolean markWarning) { |
||
645 | this.markWarning = markWarning; |
||
646 | } |
||
647 | |||
1312 | jmachado | 648 | public 1.5.0/docs/api/java/lang/Integer.html">Integer getOcorrencias() { |
1338 | jmachado | 649 | return ocorrencias == null ? 0:ocorrencias; |
1312 | jmachado | 650 | } |
651 | |||
1338 | jmachado | 652 | public boolean hasOcorrencias() { |
653 | return ocorrencias != null && ocorrencias > 0; |
||
654 | } |
||
655 | |||
1312 | jmachado | 656 | public void setOcorrencias(1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias) { |
657 | this.ocorrencias = ocorrencias; |
||
658 | } |
||
659 | |||
660 | public 1.5.0/docs/api/java/lang/String.html">String getCdDocente() { |
||
661 | return cdDocente; |
||
662 | } |
||
663 | |||
664 | public void setCdDocente(1.5.0/docs/api/java/lang/String.html">String cdDocente) { |
||
665 | this.cdDocente = cdDocente; |
||
666 | } |
||
667 | |||
668 | public 1.5.0/docs/api/java/lang/String.html">String getCdTurma() { |
||
669 | return cdTurma; |
||
670 | } |
||
671 | |||
672 | public void setCdTurma(1.5.0/docs/api/java/lang/String.html">String cdTurma) { |
||
673 | this.cdTurma = cdTurma; |
||
674 | } |
||
675 | |||
676 | public 1.5.0/docs/api/java/lang/String.html">String getCdTipologia() { |
||
677 | return cdTipologia; |
||
678 | } |
||
679 | |||
680 | public void setCdTipologia(1.5.0/docs/api/java/lang/String.html">String cdTipologia) { |
||
681 | this.cdTipologia = cdTipologia; |
||
682 | } |
||
683 | |||
1313 | jmachado | 684 | public 1.5.0/docs/api/java/lang/String.html">String getDsTipologia() { |
685 | return dsTipologia; |
||
686 | } |
||
687 | |||
688 | public void setDsTipologia(1.5.0/docs/api/java/lang/String.html">String dsTipologia) { |
||
689 | this.dsTipologia = dsTipologia; |
||
690 | } |
||
691 | |||
692 | public boolean isExtra() { |
||
693 | return extra; |
||
694 | } |
||
695 | |||
696 | public boolean isSumario() { |
||
697 | return ocorrencias != null && ocorrencias > 0; |
||
698 | } |
||
699 | |||
700 | public boolean isHorRef() { |
||
701 | return horRef; |
||
702 | } |
||
703 | |||
704 | |||
705 | |||
1312 | jmachado | 706 | @1.5.0/docs/api/java/lang/Override.html">Override |
707 | public boolean equals(5+0%2Fdocs%2Fapi+Object">Object o) |
||
708 | { |
||
709 | return o instanceof Tipologia && |
||
710 | ((((Tipologia)o).getCdTurma() == null && getCdTurma() == null) |
||
711 | || |
||
712 | (((Tipologia)o).getCdTurma().equals(getCdTurma()))) |
||
713 | && |
||
714 | |||
715 | ( |
||
716 | (((Tipologia)o).getCdDocente() == null && getCdDocente() == null) |
||
717 | || |
||
718 | (((Tipologia)o).getCdDocente().equals(getCdDocente()))) |
||
719 | && |
||
720 | |||
721 | ( |
||
722 | (((Tipologia)o).getCdTipologia() == null && getCdTipologia() == null) |
||
723 | || |
||
724 | (((Tipologia)o).getCdTipologia().equals(getCdTipologia()))); |
||
725 | } |
||
1313 | jmachado | 726 | |
727 | public boolean equalsIncDsFields(5+0%2Fdocs%2Fapi+Object">Object o) |
||
728 | { |
||
729 | return o instanceof Tipologia && |
||
730 | equals(o) |
||
731 | && |
||
732 | ( |
||
733 | (((Tipologia)o).getDsTipologia() == null && getDsTipologia() == null) |
||
734 | || |
||
735 | (((Tipologia)o).getDsTipologia().equals(getDsTipologia()))) |
||
736 | && |
||
737 | |||
738 | ( |
||
739 | (((Tipologia)o).getOcorrencias() == null && getOcorrencias() == null) |
||
740 | || |
||
741 | (((Tipologia)o).getOcorrencias().equals(getOcorrencias()))) |
||
742 | ; |
||
743 | } |
||
1312 | jmachado | 744 | } |
745 | |||
1326 | jmachado | 746 | public static class MergedTipologias |
747 | { |
||
748 | ArrayList<Tipologia> tipologiasWithMarkedAndUsed = new ArrayList<Tipologia>(); |
||
749 | |||
750 | public ArrayList<Tipologia> getTipologiasWithMarkedAndUsed() { |
||
751 | return tipologiasWithMarkedAndUsed; |
||
752 | } |
||
753 | |||
754 | public void setTipologiasWithMarkedAndUsed(ArrayList<Tipologia> tipologiasWithMarkedAndUsed) { |
||
755 | this.tipologiasWithMarkedAndUsed = tipologiasWithMarkedAndUsed; |
||
756 | } |
||
757 | } |
||
1312 | jmachado | 758 | public static class Tipologias |
759 | { |
||
1313 | jmachado | 760 | ArrayList<Tipologia> tipologiasHorarioReferencia = new ArrayList<Tipologia>(); |
761 | ArrayList<Tipologia> tipologiasSumarios = new ArrayList<Tipologia>(); |
||
762 | ArrayList<Tipologia> tipologiasExtraAdicionadas = new ArrayList<Tipologia>(); |
||
1326 | jmachado | 763 | ArrayList<Tipologia> tipologiasUsadas = new ArrayList<Tipologia>(); |
764 | ArrayList<Tipologia> tipologiasMarcadas = new ArrayList<Tipologia>(); |
||
1312 | jmachado | 765 | |
766 | public ArrayList<Tipologia> getTipologiasHorarioReferencia() { |
||
1333 | jmachado | 767 | |
768 | return tipologiasHorarioReferencia == null ? new ArrayList<Tipologia>() : tipologiasHorarioReferencia; |
||
769 | |||
1312 | jmachado | 770 | } |
771 | |||
772 | public void setTipologiasHorarioReferencia(ArrayList<Tipologia> tipologiasHorarioReferencia) { |
||
773 | this.tipologiasHorarioReferencia = tipologiasHorarioReferencia; |
||
774 | } |
||
775 | |||
776 | public ArrayList<Tipologia> getTipologiasSumarios() { |
||
1333 | jmachado | 777 | return tipologiasSumarios == null ? new ArrayList<Tipologia>() : tipologiasSumarios; |
1312 | jmachado | 778 | } |
779 | |||
780 | public void setTipologiasSumarios(ArrayList<Tipologia> tipologiasSumarios) { |
||
781 | this.tipologiasSumarios = tipologiasSumarios; |
||
782 | } |
||
783 | |||
784 | public ArrayList<Tipologia> getTipologiasExtraAdicionadas() { |
||
1333 | jmachado | 785 | return tipologiasExtraAdicionadas == null ? new ArrayList<Tipologia>() : tipologiasExtraAdicionadas; |
1312 | jmachado | 786 | } |
787 | |||
788 | public void setTipologiasExtraAdicionadas(ArrayList<Tipologia> tipologiasExtraAdicionadas) { |
||
789 | this.tipologiasExtraAdicionadas = tipologiasExtraAdicionadas; |
||
790 | } |
||
791 | |||
1333 | jmachado | 792 | public ArrayList<Tipologia> getTipologiasUsadas() { |
793 | return tipologiasUsadas == null ? new ArrayList<Tipologia>() : tipologiasUsadas; |
||
794 | } |
||
1326 | jmachado | 795 | |
796 | public void setTipologiasUsadas(ArrayList<Tipologia> tipologiasUsadas) { this.tipologiasUsadas = tipologiasUsadas; } |
||
797 | |||
1333 | jmachado | 798 | public ArrayList<Tipologia> getTipologiasMarcadas() { |
799 | return tipologiasMarcadas == null ? new ArrayList<Tipologia>() : tipologiasMarcadas; |
||
800 | } |
||
1326 | jmachado | 801 | |
802 | public void setTipologiasMarcadas(ArrayList<Tipologia> tipologiasMarcadas) { this.tipologiasMarcadas = tipologiasMarcadas; } |
||
803 | |||
1312 | jmachado | 804 | private static Genson getGenson(){ |
805 | Genson genson = new Genson.Builder() |
||
806 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
||
807 | .include("tipologiasExtraAdicionadas", Tipologias.class) |
||
808 | .include("tipologiasSumarios", Tipologias.class) |
||
809 | .include("tipologiasHorarioReferencia", Tipologias.class) |
||
1326 | jmachado | 810 | .include("tipologiasUsadas", Tipologias.class) |
811 | .include("tipologiasMarcadas", Tipologias.class) |
||
1312 | jmachado | 812 | .include("cdTipologia", Tipologia.class) |
813 | .include("cdDocente", Tipologia.class) |
||
814 | .include("cdTurma", Tipologia.class) |
||
1313 | jmachado | 815 | .include("dsTipologia",Tipologia.class) |
1312 | jmachado | 816 | .include("ocorrencias", Tipologia.class) |
817 | .create(); |
||
818 | return genson; |
||
819 | } |
||
820 | |||
1326 | jmachado | 821 | private static Genson getGensonMergedTipologiasComplete(){ |
822 | Genson genson = new Genson.Builder() |
||
823 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
||
824 | |||
825 | .include("tipologiasWithMarkedAndUsed", MergedTipologias.class) |
||
826 | .include("cdTipologia", Tipologia.class) |
||
827 | .include("cdDocente", Tipologia.class) |
||
828 | .include("cdTurma", Tipologia.class) |
||
829 | .include("dsTipologia",Tipologia.class) |
||
830 | .include("ocorrencias", Tipologia.class) |
||
831 | .include("horRef", Tipologia.class) |
||
832 | .include("extra", Tipologia.class) |
||
833 | .include("use", Tipologia.class) |
||
834 | .include("markWarning", Tipologia.class) |
||
835 | .create(); |
||
836 | return genson; |
||
837 | } |
||
838 | |||
1312 | jmachado | 839 | public 1.5.0/docs/api/java/lang/String.html">String serialize() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
840 | { |
||
841 | Genson genson = getGenson(); |
||
842 | try { |
||
843 | return genson.serialize(this); |
||
844 | } catch (TransformationException e) { |
||
845 | throw e; |
||
846 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
847 | throw e; |
||
848 | } |
||
849 | } |
||
850 | 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 |
||
851 | { |
||
852 | if(serial == null) |
||
1333 | jmachado | 853 | return new Tipologias(); |
1312 | jmachado | 854 | try { |
855 | return getGenson().deserialize(serial, Tipologias.class); |
||
856 | } catch (TransformationException e) { |
||
857 | throw e; |
||
858 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
859 | throw e; |
||
860 | } |
||
861 | } |
||
862 | |||
863 | public static void main(1.5.0/docs/api/java/lang/String.html">String [] args) |
||
864 | { |
||
865 | new TestCourseUnit().testTipologias(); |
||
866 | } |
||
1313 | jmachado | 867 | |
1326 | jmachado | 868 | 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 | 869 | { |
1326 | jmachado | 870 | MergedTipologias mergedTipologias = new MergedTipologias(); |
1333 | jmachado | 871 | if(tipologias != null) |
872 | { |
||
873 | mergedTipologias.setTipologiasWithMarkedAndUsed(tipologias); |
||
874 | } |
||
1326 | jmachado | 875 | Genson genson = getGensonMergedTipologiasComplete(); |
876 | try { |
||
877 | return genson.serialize(mergedTipologias); |
||
878 | } catch (TransformationException e) { |
||
879 | throw e; |
||
880 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
881 | throw e; |
||
882 | } |
||
883 | } |
||
884 | 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 |
||
885 | { |
||
886 | if(serial == null) |
||
1333 | jmachado | 887 | return new ArrayList<Tipologia>(); |
1326 | jmachado | 888 | try { |
889 | MergedTipologias mergedTipologias = getGensonMergedTipologiasComplete().deserialize(serial, MergedTipologias.class); |
||
890 | if(mergedTipologias.getTipologiasWithMarkedAndUsed() == null) |
||
891 | return new ArrayList<Tipologia>(); |
||
892 | return mergedTipologias.getTipologiasWithMarkedAndUsed(); |
||
893 | } catch (TransformationException e) { |
||
894 | throw e; |
||
895 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
896 | throw e; |
||
897 | } |
||
898 | } |
||
1332 | jmachado | 899 | public 1.5.0/docs/api/java/lang/String.html">String obtainMergeTipologiasSerialized() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
900 | { |
||
901 | return serializeMergedList(obtainMergeTipologias()); |
||
902 | } |
||
1337 | jmachado | 903 | |
1326 | jmachado | 904 | public ArrayList<Tipologia> obtainMergeTipologias() |
905 | { |
||
906 | ArrayList<Tipologia> merge = new ArrayList<Tipologia>(); |
||
1315 | jmachado | 907 | if(getTipologiasSumarios() != null) |
908 | merge.addAll(getTipologiasSumarios()); |
||
1313 | jmachado | 909 | |
1315 | jmachado | 910 | if(getTipologiasHorarioReferencia() != null) |
911 | for(Tipologia tipo: getTipologiasHorarioReferencia()) |
||
1313 | jmachado | 912 | { |
1315 | jmachado | 913 | if(!merge.contains(tipo)) |
914 | { |
||
915 | merge.add(tipo); |
||
916 | } |
||
1313 | jmachado | 917 | } |
1315 | jmachado | 918 | if(getTipologiasExtraAdicionadas() != null) |
919 | for(Tipologia tipo: getTipologiasExtraAdicionadas()) |
||
1313 | jmachado | 920 | { |
1315 | jmachado | 921 | if(!merge.contains(tipo)) |
922 | { |
||
923 | merge.add(tipo); |
||
924 | } |
||
1313 | jmachado | 925 | } |
926 | for(Tipologia tipo: merge) |
||
927 | { |
||
1326 | jmachado | 928 | tipo.setMarkWarning(false); |
929 | tipo.setUse(false); |
||
1315 | jmachado | 930 | if(getTipologiasHorarioReferencia() != null && getTipologiasHorarioReferencia().contains(tipo)) |
1313 | jmachado | 931 | { |
932 | tipo.horRef = true; |
||
933 | } |
||
934 | |||
1315 | jmachado | 935 | if(getTipologiasExtraAdicionadas() != null && getTipologiasExtraAdicionadas().contains(tipo)) |
1313 | jmachado | 936 | { |
937 | tipo.extra = true; |
||
938 | } |
||
939 | } |
||
1326 | jmachado | 940 | |
941 | if(getTipologiasMarcadas() != null) |
||
942 | for(Tipologia t: getTipologiasMarcadas()) |
||
943 | { |
||
944 | for(Tipologia tMerge: merge) |
||
945 | { |
||
946 | if(tMerge.equals(t)) |
||
947 | { |
||
948 | tMerge.setMarkWarning(true); |
||
949 | break; |
||
950 | } |
||
951 | } |
||
952 | } |
||
953 | if(getTipologiasUsadas() != null) |
||
954 | for(Tipologia t: getTipologiasUsadas()) |
||
955 | { |
||
956 | for(Tipologia tMerge: merge) |
||
957 | { |
||
958 | if(tMerge.equals(t)) |
||
959 | { |
||
960 | tMerge.setUse(true); |
||
961 | break; |
||
962 | } |
||
963 | } |
||
964 | } |
||
1313 | jmachado | 965 | return merge; |
966 | } |
||
967 | |||
968 | |||
1337 | jmachado | 969 | public ArrayList<Tipologia> obtainTipologiasSimples(CourseUnit courseUnit) |
970 | { |
||
971 | ArrayList<Tipologia> merge = new ArrayList<Tipologia>(); |
||
972 | |||
973 | Map<String,Map<String,Tipologia>> docenteTurmas = new HashMap<String,Map<String,Tipologia>>(); |
||
974 | |||
975 | fullfillTipologiasSimples(getTipologiasSumarios(), docenteTurmas); |
||
976 | fullfillTipologiasSimples(getTipologiasExtraAdicionadas(), docenteTurmas); |
||
977 | fullfillTipologiasSimples(getTipologiasHorarioReferencia(), docenteTurmas); |
||
978 | fullfillTipologiasSimples(getTipologiasMarcadas(), docenteTurmas); |
||
979 | fullfillTipologiasSimples(getTipologiasUsadas(), docenteTurmas); |
||
980 | |||
981 | |||
982 | if(docenteTurmas.size() == 0) |
||
983 | { |
||
984 | //NAO Há sumários vamos associar todos os docentes a todas as turmas |
||
985 | if(courseUnit.getTurmas() != null && courseUnit.getTeachers() != null) |
||
986 | { |
||
987 | for(CourseUnitTurma turma: courseUnit.getTurmas()) |
||
988 | { |
||
989 | for(Teacher t : courseUnit.getTeachers()) |
||
990 | { |
||
991 | Tipologia simples = new Tipologia(); |
||
992 | simples.setMarkWarning(true); |
||
993 | simples.setCdDocente(""+t.getSigesCode()); |
||
994 | simples.setCdTurma(turma.getTurma()); |
||
995 | simples.setCdTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_VIRTUAL_CODE); |
||
996 | simples.setDsTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_DS); |
||
997 | merge.add(simples); |
||
998 | } |
||
999 | } |
||
1000 | } |
||
1001 | } |
||
1002 | else |
||
1003 | { |
||
1004 | for(1.5.0/docs/api/java/util/Map.html">Map.Entry<String,Map<String,Tipologia>> docentes: docenteTurmas.entrySet()) |
||
1005 | { |
||
1006 | for(Tipologia tipologia: docentes.getValue().values()) |
||
1007 | { |
||
1008 | merge.add(tipologia); |
||
1009 | } |
||
1010 | } |
||
1011 | } |
||
1012 | return merge; |
||
1013 | } |
||
1014 | |||
1015 | private void fullfillTipologiasSimples(ArrayList<Tipologia> tipologias, Map<String, Map<String, Tipologia>> docenteTurmas) { |
||
1016 | if(tipologias != null) |
||
1017 | for(Tipologia tipo: tipologias) |
||
1018 | { |
||
1019 | Map<String,Tipologia> turmasDocente = docenteTurmas.get(tipo.getCdDocente()); |
||
1020 | if(turmasDocente == null) |
||
1021 | turmasDocente = new HashMap<String,Tipologia>(); |
||
1022 | docenteTurmas.put(tipo.getCdDocente(),turmasDocente); |
||
1023 | Tipologia simples = turmasDocente.get(tipo.getCdTurma()); |
||
1024 | if(simples==null) |
||
1025 | { |
||
1026 | simples = new Tipologia(); |
||
1027 | simples.setCdDocente(tipo.getCdDocente()); |
||
1028 | simples.setCdTurma(tipo.getCdTurma()); |
||
1029 | simples.setCdTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_VIRTUAL_CODE); |
||
1030 | simples.setDsTipologia(Globals.BACO_TIPOLOGIA_SIMPLES_DS); |
||
1338 | jmachado | 1031 | if(tipo.hasOcorrencias()) |
1337 | jmachado | 1032 | { |
1033 | simples.setOcorrencias(tipo.getOcorrencias()); |
||
1034 | } |
||
1035 | turmasDocente.put(tipo.getCdTurma(),simples); |
||
1036 | } |
||
1338 | jmachado | 1037 | if(tipo.hasOcorrencias()) |
1337 | jmachado | 1038 | { |
1338 | jmachado | 1039 | if(simples.getOcorrencias() == null) |
1040 | simples.setOcorrencias(0); |
||
1337 | jmachado | 1041 | simples.setOcorrencias(simples.getOcorrencias()+tipo.getOcorrencias()); |
1042 | } |
||
1043 | |||
1044 | } |
||
1045 | } |
||
1046 | |||
1047 | |||
1312 | jmachado | 1048 | } |
1049 | |||
1050 | |||
1051 | |||
1052 | |||
1053 | |||
112 | jmachado | 1054 | } |