Subversion Repositories bacoAlunos

Rev

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