Subversion Repositories bacoAlunos

Rev

Rev 1313 | Rev 1325 | 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;
1312 jmachado 16
import java.util.ArrayList;
204 jmachado 17
import java.util.List;
1312 jmachado 18
import java.util.Set;
146 jmachado 19
 
112 jmachado 20
/**
21
 * Created by IntelliJ IDEA.
22
 * User: Jorge Machado
23
 * Date: 7/Mai/2008
24
 * Time: 20:21:15
25
 * To change this template use File | Settings | File Templates.
26
 */
1312 jmachado 27
public class CourseUnitImpl extends CourseUnit implements ICanManage, ClearanceRuled
146 jmachado 28
{
489 jmachado 29
 
1312 jmachado 30
    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);
31
 
489 jmachado 32
    CourseUnitContentsGrants courseUnitContentsGrants = null;
33
 
146 jmachado 34
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable()
35
    {
36
        return getId();
37
    }
204 jmachado 38
 
489 jmachado 39
 
40
    public CourseUnitContentsGrants getCourseUnitContentsGrants() {
41
        if(courseUnitContentsGrants == null)
42
            courseUnitContentsGrants = CourseUnitContentsGrants.parse(super.getContentsGrants());
43
        return courseUnitContentsGrants;
44
    }
45
 
46
    public void setCourseUnitContentsGrants(CourseUnitContentsGrants courseUnitContentsGrants) {
47
        super.setContentsGrants(courseUnitContentsGrants.name());
48
        this.courseUnitContentsGrants = courseUnitContentsGrants;
49
    }
50
 
204 jmachado 51
    public boolean isValid()
52
    {
53
        return true;  //To change body of implemented methods use File | Settings | File Templates.
54
    }
55
 
56
    public boolean isOwnedBy(GenericUser u)
57
    {
208 jmachado 58
        return isOwnedBy(u, false);
204 jmachado 59
    }
60
 
208 jmachado 61
    public boolean isOwnedBy(GenericUser u, boolean transaction)
62
    {
63
        return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId(),transaction);
64
    }
65
 
204 jmachado 66
    /**
67
     * Not implemented can be variuous teachers
68
     * @return null
69
     * use isOwnedBy in this class
70
     */
71
    public GenericUser getOwner()
72
    {
73
        return null;
74
    }
75
    /**
76
     * Not implemented
77
     * @return
78
     */
79
    public List<String> getOwnerRoles()
80
    {
81
        return null;
82
    }
83
 
84
    /**
85
     * Not implemented
86
     * @return
87
     */
88
    public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole()
89
    {
90
        return null;
91
    }
92
 
93
    public boolean isInternal()
94
    {
251 jmachado 95
        return true;
204 jmachado 96
    }
208 jmachado 97
 
98
    public CourseUnitBlogImpl getUnitBlog()
99
    {
100
        if(getBlogs()!=null && getBlogs().size() > 0)
101
            return (CourseUnitBlogImpl) getBlogs().iterator().next();
102
        return null;
103
    }
251 jmachado 104
 
1315 jmachado 105
 
1312 jmachado 106
    public boolean equalsSiges(5+0%2Fdocs%2Fapi+Object">Object anotherInstance,boolean turmasSeparadas)
251 jmachado 107
    {
108
        if(anotherInstance instanceof CourseUnitImpl)
109
        {
110
            CourseUnitImpl anCourseUnit = (CourseUnitImpl) anotherInstance;
1312 jmachado 111
            if(turmasSeparadas)
112
            {
113
                boolean turmaVazia = getCdTurma() == null || getCdTurma().trim().length() == 0;
114
                boolean anotherTurmaVazia = anCourseUnit.getCdTurma() == null || anCourseUnit.getCdTurma().trim().length() == 0;
115
                boolean turmasIguais = (turmaVazia && anotherTurmaVazia) || (!turmaVazia && !anotherTurmaVazia && getCdTurma().equals(anCourseUnit.getCdTurma()));
116
                return equalsIgnoringTurma(anotherInstance)
117
                &&
118
                turmasIguais;
119
            }
120
            else
121
                return equalsIgnoringTurma(anotherInstance);
251 jmachado 122
        }
123
        return false;
124
 
125
    }
489 jmachado 126
 
1204 jmachado 127
    public boolean equalsIgnoringTurma(5+0%2Fdocs%2Fapi+Object">Object anotherInstance)
128
    {
129
        if(anotherInstance instanceof CourseUnitImpl)
130
        {
131
            CourseUnitImpl anCourseUnit = (CourseUnitImpl) anotherInstance;
132
 
133
            return anCourseUnit.getCode() != null && getCode() != null && getCode().equals(anCourseUnit.getCode()) &&
134
                    anCourseUnit.getCourseCode() != null && getCourseCode() != null && getCourseCode().equals(anCourseUnit.getCourseCode()) &&
135
                    anCourseUnit.getSemestre() != null && getSemestre() != null && getSemestre().equals(anCourseUnit.getSemestre()) &&
136
                    anCourseUnit.getImportYear() != null && getImportYear() != null && getImportYear().equals(anCourseUnit.getImportYear());
137
        }
138
        return false;
139
 
140
    }
141
 
973 jmachado 142
    /**
143
     * Means that is teacher os responsable teacher or from course commission
144
     * Only works in open transaction
145
     *
146
     * Needs Course and Responsable Teacher loaded
147
     */
148
    public boolean isFromCourseUnitCommission(UserSession userSession)
149
    {
150
        return userSession.getUser()!= null &&
151
                (((UserImpl) userSession.getUser()).isTeacherOfCourseUnit(getId(), true)
152
                        || (getResponsableTeacher() != null && getResponsableTeacher().getId() == userSession.getUser().getId())
153
                        || userSession.getUser().hasRole(getCourse().getValidationRole())
154
                );
155
    }
489 jmachado 156
 
1312 jmachado 157
    public boolean isFromCourseCommission(UserSession userSession)
158
    {
159
        return userSession.getUser()!= null &&
160
                userSession.getUser().hasRole(getCourse().getValidationRole());
161
    }
973 jmachado 162
 
1312 jmachado 163
 
995 jmachado 164
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathIntranet()
165
    {
166
        return Globals.FTP_IONLINE_START_PATH + "/" + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_Sumarios;
167
    }
973 jmachado 168
 
1148 jmachado 169
    public 1.5.0/docs/api/java/lang/String.html">String getInqueritosPedagogicosPathIntranet()
170
    {
171
        return Globals.FTP_IONLINE_START_PATH + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_InqueritoPedagogico;
172
    }
173
 
174
 
995 jmachado 175
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathFileIntranet()
176
    {
177
        return getSummariosPathIntranet() + "/" + getSummariosFileNameIntranet();
178
    }
179
 
180
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosFileNameIntranet(){
181
        return getCode() + "_" + getNormalizedName() + "_sumarios.pdf";
182
    }
183
 
184
 
996 jmachado 185
    public 1.5.0/docs/api/java/lang/String.html">String getSigesUniqueIdentifiers()
186
    {
187
        return "SIGES:" + getCode() + ", COURSE: " + getCourseCode() +
1139 jmachado 188
                ", " + getSemestre() + " of " + getImportYear() + " - " + getName() + " Turma - " + getCdTurma();
996 jmachado 189
    }
190
 
1312 jmachado 191
 
192
    public boolean hasStudent(long studentId, boolean transaction)
193
    {
194
        Set<StudentImpl> students;
195
        if(transaction)
196
            students = getStudents();
197
        else
198
        {
199
            IServiceManager sm;
200
            try {
201
                sm = ServiceManager.getInstance();
202
                1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"};
203
                5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()};
204
                students = (Set<StudentImpl>) sm.execute(null, "LoadCourseUnitStudents", args, names);
205
            } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) {
206
                logger.error(e,e);
207
                return false;
208
            }
209
        }
210
        if(students == null)
211
            return false;
212
        for(Student s: students)
213
        {
214
            if(s.getId() == studentId)
215
                return true;
216
        }
217
        return false;
218
    }
219
 
220
    public boolean hasTeacher(long teacherId, boolean transaction)
221
    {
222
        Set<TeacherImpl> teachers;
223
        if(transaction)
224
            teachers = getTeachers();
225
        else
226
        {
227
            IServiceManager sm;
228
            try {
229
                sm = ServiceManager.getInstance();
230
                1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"};
231
                5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()};
232
                teachers = (Set<TeacherImpl>) sm.execute(null, "LoadCourseUnitTeachers", args, names);
233
            } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) {
234
                logger.error(e,e);
235
                return false;
236
            }
237
        }
238
        if(teachers == null)
239
            return false;
240
        for(Teacher t: teachers)
241
        {
242
            if(t.getId() == teacherId)
243
                return true;
244
        }
245
        return false;
246
    }
247
 
248
    public boolean isResponsibleTeacher(long teacherId, boolean transaction)
249
    {
250
        Teacher t;
251
        if(transaction)
252
            t = getResponsableTeacher();
253
        else
254
        {
255
            IServiceManager sm;
256
            try {
257
                sm = ServiceManager.getInstance();
258
                1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"};
259
                5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()};
260
                t = (Teacher) sm.execute(null, "LoadCourseUnitResponsibleTeacher", args, names);
261
            } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) {
262
                logger.error(e,e);
263
                return false;
264
            }
265
        }
266
        if(t == null)
267
            return false;
268
        if(t.getId() == teacherId)
269
            return true;
270
        return false;
271
    }
272
 
273
    SimpleClearanceRuledSupport clearanceRuledSupport = null;
274
 
275
    public SimpleClearanceRuledSupport getClearanceRuledSupport() {
276
        return clearanceRuledSupport;
277
    }
278
 
279
    public void setClearanceRuledSupport(SimpleClearanceRuledSupport clearanceRuledSupport) {
280
        this.clearanceRuledSupport = clearanceRuledSupport;
281
    }
282
 
283
    @1.5.0/docs/api/java/lang/Override.html">Override
284
    public boolean isClearanceInitialized(UserSessionImpl u) {
285
        return clearanceRuledSupport == null ? false :
286
         clearanceRuledSupport.isClearanceInitialized(u);
287
    }
288
 
289
    @1.5.0/docs/api/java/lang/Override.html">Override
290
    public boolean isClear(UserSessionImpl u, 1.5.0/docs/api/java/lang/String.html">String OP) {
291
 
292
        if(clearanceRuledSupport == null) return false;
293
        if(OP.startsWith("EVALUATION") && !OP.startsWith("EVALUATION_INFO")
294
                && clearanceRuledSupport.isClear(u,CourseUnitClearancesOperation.EVALUATION_ALL.name()))
295
            return true;
296
        return clearanceRuledSupport.isClear(u, OP);
297
    }
298
 
299
    public static enum CourseUnitClearancesOperation
300
    {
301
        EVALUATION_ALL, //SPECIAL OPERATION FOR DENY AND PERMIT REPLACE FULL CONTROL
302
 
303
        //COURSE UNIT EVALUATION
304
        EVALUATION_PERSIST_TEACHER_PART, //SERVICE PERSIST THIS PART
305
        EVALUATION_PERSIST_COMISSION_PART, //SERVICE PERSIST THIS PART
306
 
307
        EVALUATION_EDITION, //CAN SEE EDITION SCREEN
308
        EVALUATION_EDITSAVE, //CAN PRESS SAVE
309
        EVALUATION_TRANSITATE_TO_COMPLETE, //CAN_TRANSITATE
310
        EVALUATION_TRANSITATE_TO_CLOSE, //CAN CLOSE
311
        EVALUATION_TRANSITATE_TO_EDIT, //CAN REVERT
312
 
313
        EVALUATION_INFO_ACTIVE, //INFO CLEARANCE WHEN ACTIVE
314
        EVALUATION_INFO_ACTIVE_SPECIAL_ADMIN, //INFO CLEARANCE REASON OF BEING ACTIVE
315
        EVALUATION_INFO_ACTIVE_REGULAR_PERIOD, //INFO CLEARANCE REASON OF BEING ACTIVE
316
 
317
        EVALUATION_INFO_STATE_EDIT, //INFO CLEARANCE
318
        EVALUATION_INFO_STATE_COMPLETE, //INFO CLEARANCE
319
        EVALUATION_INFO_STATE_CLOSED, //INFO CLEARANCE
320
 
321
        EVALUATION_INFO_USER_TEACHER, //INFO CLEARANCE
322
        EVALUATION_INFO_USER_RESP_TEACHER, //INFO CLEARANCE
323
        EVALUATION_INFO_USER_COMMISSION, //INFO CLEARANCE
324
 
325
        ;
326
 
327
        public static CourseUnitClearancesOperation parse(1.5.0/docs/api/java/lang/String.html">String clearance)
328
        {
329
            if(clearance == null)
330
                return null;
331
            for(CourseUnitClearancesOperation op: CourseUnitClearancesOperation.values())
332
            {
333
                if(op.name().equals(clearance))
334
                    return op;
335
            }
336
            return null;
337
        }
338
    }
339
 
340
 
341
    public Tipologias getTipologiasClass() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
342
    {
343
        return Tipologias.deserialize(getTipologias());
344
    }
345
 
346
    public void setTipologiasClass(Tipologias tipologias) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
347
    {
348
        if(tipologias != null)
349
            setTipologias(tipologias.serialize());
350
    }
351
 
1313 jmachado 352
    public TipologiaPersistent loadPersistent(Tipologia myTipo)
353
    {
354
        TipologiaPersistent tipologiaPersistent = new TipologiaPersistent();
355
        tipologiaPersistent.setHorRef(myTipo.isHorRef());
356
        tipologiaPersistent.setExtra(myTipo.isExtra());
357
        tipologiaPersistent.setTeacher(DaoFactory.getTeacherDaoImpl().loadBySigesCode(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(myTipo.getCdDocente())));
358
        tipologiaPersistent.setCdTipologia(myTipo.getCdTipologia());
359
        tipologiaPersistent.setOcorrencias(myTipo.getOcorrencias());
360
 
361
        tipologiaPersistent.setCourseUnitTurma(findTurma(myTipo.getCdTurma()));
362
        if(tipologiaPersistent.getCourseUnitTurma() == null || tipologiaPersistent.getTeacher() == null)
363
        {
364
            logger.error("Turma ou professor nao encontrados enquanto fazia uma tipologia persistente");
365
            return null;
366
        }
367
        return tipologiaPersistent;
368
    }
369
 
370
    public CourseUnitTurma findTurma(1.5.0/docs/api/java/lang/String.html">String turma)
371
    {
372
        if(getTurmas() == null)
373
            return null;
374
        for(CourseUnitTurma t: getTurmas())
375
        {
376
            if(t.getTurma().equals(turma))
377
                return t;
378
        }
379
        return null;
380
    }
381
 
382
 
383
    public static class TipologiaPersistent
384
    {
385
        private Teacher teacher;
386
        private CourseUnitTurma courseUnitTurma;
387
        private 1.5.0/docs/api/java/lang/String.html">String cdTipologia;
388
        private 1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias = 0;
389
        protected boolean extra;
390
        protected boolean horRef;
391
 
392
        public boolean isExtra() {
393
            return extra;
394
        }
395
 
396
        public boolean isHorRef() {
397
            return horRef;
398
        }
399
 
400
        public boolean isSumario() {
401
            return ocorrencias != null && ocorrencias > 0;
402
        }
403
 
404
        public void setExtra(boolean extra) {
405
            this.extra = extra;
406
        }
407
 
408
        public void setHorRef(boolean horRef) {
409
            this.horRef = horRef;
410
        }
411
 
412
        public Teacher getTeacher() {
413
            return teacher;
414
        }
415
 
416
        public void setTeacher(Teacher teacher) {
417
            this.teacher = teacher;
418
        }
419
 
420
        public CourseUnitTurma getCourseUnitTurma() {
421
            return courseUnitTurma;
422
        }
423
 
424
        public void setCourseUnitTurma(CourseUnitTurma courseUnitTurma) {
425
            this.courseUnitTurma = courseUnitTurma;
426
        }
427
 
428
        public 1.5.0/docs/api/java/lang/String.html">String getCdTipologia() {
429
            return cdTipologia;
430
        }
431
 
432
        public void setCdTipologia(1.5.0/docs/api/java/lang/String.html">String cdTipologia) {
433
            this.cdTipologia = cdTipologia;
434
        }
435
 
436
        public 1.5.0/docs/api/java/lang/Integer.html">Integer getOcorrencias() {
437
            return ocorrencias;
438
        }
439
 
440
        public void setOcorrencias(1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias) {
441
            this.ocorrencias = ocorrencias;
442
        }
443
    }
1312 jmachado 444
    /**
445
     * Os codigos de tipologia devem ser limitados a T TP OT etc
446
     */
447
    public static class Tipologia
448
    {
1313 jmachado 449
        protected 1.5.0/docs/api/java/lang/String.html">String cdDocente;
450
        protected 1.5.0/docs/api/java/lang/String.html">String cdTurma;
451
        protected 1.5.0/docs/api/java/lang/String.html">String cdTipologia;
452
        protected 1.5.0/docs/api/java/lang/String.html">String dsTipologia;
453
        protected 1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias; // apenas faz sentido nos sumarios. no horario ref nao.
1312 jmachado 454
 
1313 jmachado 455
        protected boolean extra;
456
        protected boolean horRef;
457
 
1312 jmachado 458
        public 1.5.0/docs/api/java/lang/Integer.html">Integer getOcorrencias() {
459
            return ocorrencias;
460
        }
461
 
462
        public void setOcorrencias(1.5.0/docs/api/java/lang/Integer.html">Integer ocorrencias) {
463
            this.ocorrencias = ocorrencias;
464
        }
465
 
466
        public 1.5.0/docs/api/java/lang/String.html">String getCdDocente() {
467
            return cdDocente;
468
        }
469
 
470
        public void setCdDocente(1.5.0/docs/api/java/lang/String.html">String cdDocente) {
471
            this.cdDocente = cdDocente;
472
        }
473
 
474
        public 1.5.0/docs/api/java/lang/String.html">String getCdTurma() {
475
            return cdTurma;
476
        }
477
 
478
        public void setCdTurma(1.5.0/docs/api/java/lang/String.html">String cdTurma) {
479
            this.cdTurma = cdTurma;
480
        }
481
 
482
        public 1.5.0/docs/api/java/lang/String.html">String getCdTipologia() {
483
            return cdTipologia;
484
        }
485
 
486
        public void setCdTipologia(1.5.0/docs/api/java/lang/String.html">String cdTipologia) {
487
            this.cdTipologia = cdTipologia;
488
        }
489
 
1313 jmachado 490
        public 1.5.0/docs/api/java/lang/String.html">String getDsTipologia() {
491
            return dsTipologia;
492
        }
493
 
494
        public void setDsTipologia(1.5.0/docs/api/java/lang/String.html">String dsTipologia) {
495
            this.dsTipologia = dsTipologia;
496
        }
497
 
498
        public boolean isExtra() {
499
            return extra;
500
        }
501
 
502
        public boolean isSumario() {
503
            return ocorrencias != null && ocorrencias > 0;
504
        }
505
 
506
        public boolean isHorRef() {
507
            return horRef;
508
        }
509
 
510
 
511
 
1312 jmachado 512
        @1.5.0/docs/api/java/lang/Override.html">Override
513
        public boolean equals(5+0%2Fdocs%2Fapi+Object">Object o)
514
        {
515
            return o instanceof Tipologia &&
516
                    ((((Tipologia)o).getCdTurma() == null && getCdTurma() == null)
517
                            ||
518
                     (((Tipologia)o).getCdTurma().equals(getCdTurma())))
519
                    &&
520
 
521
                    (
522
                     (((Tipologia)o).getCdDocente() == null && getCdDocente() == null)
523
                            ||
524
                     (((Tipologia)o).getCdDocente().equals(getCdDocente())))
525
                    &&
526
 
527
                    (
528
                     (((Tipologia)o).getCdTipologia() == null && getCdTipologia() == null)
529
                                    ||
530
                     (((Tipologia)o).getCdTipologia().equals(getCdTipologia())));
531
        }
1313 jmachado 532
 
533
        public boolean equalsIncDsFields(5+0%2Fdocs%2Fapi+Object">Object o)
534
        {
535
            return o instanceof Tipologia &&
536
                    equals(o)
537
                    &&
538
                    (
539
                            (((Tipologia)o).getDsTipologia() == null && getDsTipologia() == null)
540
                                    ||
541
                                    (((Tipologia)o).getDsTipologia().equals(getDsTipologia())))
542
                    &&
543
 
544
                    (
545
                            (((Tipologia)o).getOcorrencias() == null && getOcorrencias() == null)
546
                                    ||
547
                                    (((Tipologia)o).getOcorrencias().equals(getOcorrencias())))
548
                    ;
549
        }
1312 jmachado 550
    }
551
 
552
    public static class Tipologias
553
    {
1313 jmachado 554
        ArrayList<Tipologia> tipologiasHorarioReferencia = new ArrayList<Tipologia>();
555
        ArrayList<Tipologia> tipologiasSumarios = new ArrayList<Tipologia>();
556
        ArrayList<Tipologia> tipologiasExtraAdicionadas = new ArrayList<Tipologia>();
1312 jmachado 557
 
558
        public ArrayList<Tipologia> getTipologiasHorarioReferencia() {
559
            return tipologiasHorarioReferencia;
560
        }
561
 
562
        public void setTipologiasHorarioReferencia(ArrayList<Tipologia> tipologiasHorarioReferencia) {
563
            this.tipologiasHorarioReferencia = tipologiasHorarioReferencia;
564
        }
565
 
566
        public ArrayList<Tipologia> getTipologiasSumarios() {
567
            return tipologiasSumarios;
568
        }
569
 
570
        public void setTipologiasSumarios(ArrayList<Tipologia> tipologiasSumarios) {
571
            this.tipologiasSumarios = tipologiasSumarios;
572
        }
573
 
574
        public ArrayList<Tipologia> getTipologiasExtraAdicionadas() {
575
            return tipologiasExtraAdicionadas;
576
        }
577
 
578
        public void setTipologiasExtraAdicionadas(ArrayList<Tipologia> tipologiasExtraAdicionadas) {
579
            this.tipologiasExtraAdicionadas = tipologiasExtraAdicionadas;
580
        }
581
 
582
        private static Genson getGenson(){
583
            Genson genson = new Genson.Builder()
584
                    .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
585
                    .include("tipologiasExtraAdicionadas", Tipologias.class)
586
                    .include("tipologiasSumarios", Tipologias.class)
587
                    .include("tipologiasHorarioReferencia", Tipologias.class)
588
                    .include("cdTipologia", Tipologia.class)
589
                    .include("cdDocente", Tipologia.class)
590
                    .include("cdTurma", Tipologia.class)
1313 jmachado 591
                    .include("dsTipologia",Tipologia.class)
1312 jmachado 592
                    .include("ocorrencias", Tipologia.class)
593
                    .create();
594
            return genson;
595
        }
596
 
597
        public 1.5.0/docs/api/java/lang/String.html">String serialize() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
598
        {
599
            Genson genson = getGenson();
600
            try {
601
                return genson.serialize(this);
602
            } catch (TransformationException e) {
603
                throw e;
604
            } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) {
605
                throw e;
606
            }
607
        }
608
        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
609
        {
610
            if(serial == null)
611
                return null;
612
            try {
613
                return getGenson().deserialize(serial, Tipologias.class);
614
            } catch (TransformationException e) {
615
                throw e;
616
            } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) {
617
                throw e;
618
            }
619
        }
620
 
621
        public static void main(1.5.0/docs/api/java/lang/String.html">String [] args)
622
        {
623
            new TestCourseUnit().testTipologias();
624
        }
1313 jmachado 625
 
626
        public List<Tipologia> obtainMergeTipologias()
627
        {
628
            List<Tipologia> merge = new ArrayList<Tipologia>();
1315 jmachado 629
            if(getTipologiasSumarios() != null)
630
                merge.addAll(getTipologiasSumarios());
1313 jmachado 631
 
1315 jmachado 632
            if(getTipologiasHorarioReferencia() != null)
633
                for(Tipologia tipo: getTipologiasHorarioReferencia())
1313 jmachado 634
                {
1315 jmachado 635
                    if(!merge.contains(tipo))
636
                    {
637
                        merge.add(tipo);
638
                    }
1313 jmachado 639
                }
1315 jmachado 640
            if(getTipologiasExtraAdicionadas() != null)
641
                for(Tipologia tipo: getTipologiasExtraAdicionadas())
1313 jmachado 642
                {
1315 jmachado 643
                    if(!merge.contains(tipo))
644
                    {
645
                        merge.add(tipo);
646
                    }
1313 jmachado 647
                }
648
            for(Tipologia tipo: merge)
649
            {
1315 jmachado 650
                if(getTipologiasHorarioReferencia() != null && getTipologiasHorarioReferencia().contains(tipo))
1313 jmachado 651
                {
652
                    tipo.horRef = true;
653
                }
654
 
1315 jmachado 655
                if(getTipologiasExtraAdicionadas() != null && getTipologiasExtraAdicionadas().contains(tipo))
1313 jmachado 656
                {
657
                    tipo.extra = true;
658
                }
659
            }
660
            return merge;
661
        }
662
 
663
 
1312 jmachado 664
    }
665
 
666
 
667
 
668
 
669
 
112 jmachado 670
}