Subversion Repositories bacoAlunos

Rev

Rev 1704 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
113 fvelez 1
package pt.estgp.estgweb.domain.views;
2
 
1054 jmachado 3
import jomm.utils.BytesUtils;
4
import jomm.utils.DesUtils;
146 jmachado 5
import org.apache.log4j.Logger;
206 jmachado 6
import pt.estgp.estgweb.domain.*;
1054 jmachado 7
import pt.estgp.estgweb.domain.dao.DaoFactory;
215 jmachado 8
import pt.estgp.estgweb.domain.enums.RecordEnum;
113 fvelez 9
import pt.estgp.estgweb.utils.RoleManager;
10
 
146 jmachado 11
import java.io.Serializable;
215 jmachado 12
import java.util.*;
113 fvelez 13
 
14
/**
15
 * @author Jorge Machado
16
 * @date 2/Mar/2008
17
 * @time 19:34:49
18
 * @see pt.estgp.estgweb.domain.views
19
 */
146 jmachado 20
public class UserView extends DomainObjectView implements IOwned
113 fvelez 21
{
146 jmachado 22
 
219 jmachado 23
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(UserView.class);
146 jmachado 24
 
25
 
1704 jmachado 26
    private 1.5.0/docs/api/java/lang/String.html">String apikey;
27
    private 1.5.0/docs/api/java/lang/String.html">String chaveDeUtilizadorParaAppsMoveis;
28
 
29
    private 1.5.0/docs/api/java/lang/String.html">String className;
113 fvelez 30
    private long id;
206 jmachado 31
    private int code;
113 fvelez 32
    private 1.5.0/docs/api/java/lang/String.html">String name;
132 fvelez 33
    private List<String> userRoles;
381 jmachado 34
    private 1.5.0/docs/api/java/lang/String.html">String mainArea;
113 fvelez 35
    private 1.5.0/docs/api/java/lang/String.html">String address;
36
    private 1.5.0/docs/api/java/lang/String.html">String zip;
37
    private 1.5.0/docs/api/java/lang/String.html">String country;
381 jmachado 38
    private 1.5.0/docs/api/java/lang/String.html">String office;
39
    private 1.5.0/docs/api/java/lang/String.html">String ext;
113 fvelez 40
    private 1.5.0/docs/api/java/lang/String.html">String email;
132 fvelez 41
    private 1.5.0/docs/api/java/lang/String.html">String outEmail;
113 fvelez 42
    private 1.5.0/docs/api/java/lang/String.html">String phonenumber;
132 fvelez 43
    private 1.5.0/docs/api/java/lang/String.html">String bi;
44
    private 5+0%2Fdocs%2Fapi+Date">Date birthDate;
45
    private 1.5.0/docs/api/java/lang/String.html">String username;
146 jmachado 46
    private User user;
156 jmachado 47
    private 1.5.0/docs/api/java/lang/String.html">String pop3server;
215 jmachado 48
    private 1.5.0/docs/api/java/lang/String.html">String pop3username;
49
    private 1.5.0/docs/api/java/lang/String.html">String pop3password;
156 jmachado 50
    private 1.5.0/docs/api/java/lang/String.html">String pop3passwordAgain;
215 jmachado 51
    private 1.5.0/docs/api/java/lang/String.html">String skype;
52
    private 1.5.0/docs/api/java/lang/String.html">String gmail;
53
    private 1.5.0/docs/api/java/lang/String.html">String msn;
175 jmachado 54
    private 1.5.0/docs/api/java/lang/String.html">String password;
55
    private 1.5.0/docs/api/java/lang/String.html">String passwordAgain;
56
    private boolean passwordLocal = false;
113 fvelez 57
 
215 jmachado 58
    private 1.5.0/docs/api/java/lang/String.html">String scholarDegree;
59
    private 1.5.0/docs/api/java/lang/String.html">String academicDegree;
60
 
428 jmachado 61
    //This field should be set true when a user View is representing a deleted user
62
    private boolean deleted = false;
63
 
1553 jmachado 64
    private 1.5.0/docs/api/java/lang/String.html">String nacionalidade;
65
    private 1.5.0/docs/api/java/lang/String.html">String pais;
806 jmachado 66
 
1553 jmachado 67
 
806 jmachado 68
    private boolean autoBlockMode;
69
    private boolean autoBlock;
70
    private boolean manualBlock;
71
 
1701 jmachado 72
    private List<String> courseComissionsAndCoordinationsRoles;
215 jmachado 73
    private List<RecordView> creatorRecords;
74
    private List<RecordView> contributorRecords;
75
 
76
    private List<CourseView> courses;
77
    private List<CourseUnitView> courseUnits;
219 jmachado 78
    private List<CourseUnitGradeView> grades;
215 jmachado 79
 
821 jmachado 80
    private List<CourseUnitView> responsableCourseUnits;
81
 
1054 jmachado 82
    private boolean propinasEmDia = false;
83
 
1315 jmachado 84
    private CourseUnitTurmaView studentCourseUnitTurmaView = null;
85
 
86
    public void setStudentCourseUnitTurmaView(CourseUnitTurmaView studentCourseUnitTurmaView) {
87
        this.studentCourseUnitTurmaView = studentCourseUnitTurmaView;
88
    }
89
 
90
    public 1.5.0/docs/api/java/lang/String.html">String getStudentTurma()
91
    {
92
        if(studentCourseUnitTurmaView == null)
93
            return "";
94
        else
95
            return studentCourseUnitTurmaView.getTurma();
96
    }
97
 
113 fvelez 98
    public UserView()
99
    {}
100
 
101
    public UserView(User user)
102
    {
103
        super(user);
428 jmachado 104
        if(user == null)
105
        {
106
            this.deleted = true;
107
            return;
108
        }
1704 jmachado 109
        this.className = user.getClass().getName();
1553 jmachado 110
        this.nacionalidade = user.getNacionalidade();
111
        this.country = user.getCountry();
146 jmachado 112
        this.user = user;
113 fvelez 113
        this.id = user.getId();
114
        this.name=user.getName();
115
        this.address=user.getAddress();
116
        this.zip = user.getZip();
117
        this.country=user.getCountry();
118
        this.email=user.getEmail();
119
        this.phonenumber=user.getPhonenumber();
132 fvelez 120
        this.userRoles = RoleManager.getRolesFromSerial(user.getRoles());
121
        this.outEmail=user.getOutEmail();
122
        this.bi=user.getBi();
123
        this.birthDate=user.getBirthDate();
124
        this.username=user.getUsername();
175 jmachado 125
        if(user.getPassword() != null && user.getPassword().length() > 0)
126
            passwordLocal = true;
156 jmachado 127
        this.pop3server = user.getPop3server();
128
        this.pop3username = user.getPop3username();
129
        this.skype=user.getSkype();
130
        this.gmail=user.getGmail();
131
        this.msn=user.getMsn();
215 jmachado 132
        this.scholarDegree = user.getScholarDegree();
381 jmachado 133
        this.office = user.getOffice();
134
        this.ext = user.getExt();
135
 
806 jmachado 136
        this.autoBlockMode = user.isAutoBlockMode();
137
        this.autoBlock = user.isAutoBlock();
138
        this.manualBlock = user.isManualBlock();
139
 
1704 jmachado 140
        //CHAVE DE UTILIZADOR FINAL PARA METER NO TELEMOVEL
141
        this.chaveDeUtilizadorParaAppsMoveis = user.getChaveAppsMoveis();
142
        //CHAVE DE API'S PARA APLICACOES AUTO
143
        if(user instanceof AppUser)
144
        {
145
            this.apikey = ((AppUser)user).getChaveApi();
146
        }
147
 
206 jmachado 148
        if(user instanceof Teacher)
149
        {
381 jmachado 150
            mainArea = ((Teacher)user).getMainArea();
206 jmachado 151
            code = ((Teacher)user).getSigesCode();
1701 jmachado 152
            this.academicDegree = ((Teacher)user).getAcademicDegree();
153
            try{
154
                TeacherImpl tImpl;
155
                if(!(user instanceof TeacherImpl))
156
                {
157
                    tImpl = (TeacherImpl) DaoFactory.getTeacherDaoImpl().get(user.getId());
158
                }
159
                else
160
                {
161
                    tImpl = (TeacherImpl) user;
162
                }
163
                this.courseComissionsAndCoordinationsRoles = tImpl.obtainCourseComissionsAndCoordinationsRoles();
164
            }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
165
            {
166
                logger.warn("Probably no transaction trying to load course comissions and coordinations roles");
167
            }
206 jmachado 168
        }
169
        else if(user instanceof Student)
170
        {
381 jmachado 171
            mainArea = ((Student)user).getMainArea();
206 jmachado 172
            code = ((Student)user).getSigesCode();
1054 jmachado 173
            propinasEmDia = ((Student)user).isPropinasEmDia();
206 jmachado 174
        }
113 fvelez 175
    }
176
 
1704 jmachado 177
    public 1.5.0/docs/api/java/lang/String.html">String getClassName() {
178
        return className;
179
    }
180
 
181
    public void setClassName(1.5.0/docs/api/java/lang/String.html">String className) {
182
        this.className = className;
183
    }
184
 
1701 jmachado 185
    public List<String> getCourseComissionsAndCoordinationsRoles()
186
    {
187
        return courseComissionsAndCoordinationsRoles;
188
    }
189
    public boolean hasCoordinationsOrBelongToCourseCommissions()
190
    {
191
        if(courseComissionsAndCoordinationsRoles != null)
192
            return getCourseComissionsAndCoordinationsRoles().size() > 0;
193
        return false;
194
    }
195
 
1704 jmachado 196
    public 1.5.0/docs/api/java/lang/String.html">String getChaveDeUtilizadorParaAppsMoveis() {
197
        return chaveDeUtilizadorParaAppsMoveis;
198
    }
199
 
200
    public void setChaveDeUtilizadorParaAppsMoveis(1.5.0/docs/api/java/lang/String.html">String chaveDeUtilizadorParaAppsMoveis) {
201
        this.chaveDeUtilizadorParaAppsMoveis = chaveDeUtilizadorParaAppsMoveis;
202
    }
203
 
204
    public 1.5.0/docs/api/java/lang/String.html">String getApikey() {
205
        return apikey;
206
    }
207
 
208
    public void setApikey(1.5.0/docs/api/java/lang/String.html">String apikey) {
209
        this.apikey = apikey;
210
    }
211
 
1701 jmachado 212
    public void setCourseComissionsAndCoordinationsRoles(List<String> courseComissionsAndCoordinationsRoles) {
213
        this.courseComissionsAndCoordinationsRoles = courseComissionsAndCoordinationsRoles;
214
    }
215
 
821 jmachado 216
    public List<CourseUnitView> getResponsableCourseUnits() {
217
        return responsableCourseUnits;
218
    }
219
 
220
    public void setResponsableCourseUnits(List<CourseUnitView> responsableCourseUnits) {
221
        this.responsableCourseUnits = responsableCourseUnits;
222
    }
223
 
806 jmachado 224
    public boolean isAutoBlockMode() {
225
        return autoBlockMode;
226
    }
215 jmachado 227
 
806 jmachado 228
    public void setAutoBlockMode(boolean autoBlockMode) {
229
        this.autoBlockMode = autoBlockMode;
230
    }
231
 
232
    public boolean isAutoBlock() {
233
        return autoBlock;
234
    }
235
 
236
    public void setAutoBlock(boolean autoBlock) {
237
        this.autoBlock = autoBlock;
238
    }
239
 
240
    public boolean isManualBlock() {
241
        return manualBlock;
242
    }
243
 
244
    public void setManualBlock(boolean manualBlock) {
245
        this.manualBlock = manualBlock;
246
    }
247
 
132 fvelez 248
    public void persistViewInObjectAdmin(User user)
113 fvelez 249
    {
1553 jmachado 250
 
113 fvelez 251
        user.setName(name);
252
        user.setAddress(address);
253
        user.setZip(zip);
254
        user.setCountry(country);
255
        user.setEmail(email);
256
        user.setPhonenumber(phonenumber);
132 fvelez 257
        user.setRoles(RoleManager.getSerialRoles(userRoles));
258
        user.setOutEmail(outEmail);
259
        user.setBi(bi);
260
        user.setBirthDate(birthDate);
261
        user.setUsername(username);
156 jmachado 262
        user.setPop3server(pop3server);
263
        user.setPop3username(pop3username);
264
        if(pop3password != null && pop3password.length()> 0)
265
            user.setPop3password(DesUtils.getInstance().encrypt(pop3password));
266
        user.setSkype(skype);
267
        user.setGmail(gmail);
268
        user.setMsn(msn);
215 jmachado 269
        user.setScholarDegree(scholarDegree);
381 jmachado 270
        user.setOffice(office);
271
        user.setExt(ext);
806 jmachado 272
        user.setAutoBlockMode(autoBlockMode);
273
        user.setAutoBlock(autoBlock);
274
        user.setManualBlock(manualBlock);
381 jmachado 275
 
1704 jmachado 276
        if(user instanceof AppUser)
277
        {
278
            //NAO SE FAZ SET DA CHAVE DE UTiLIZADORES FINAIS, ESTA A SER CARREGADA NO INIT PARA MOSTRAR
279
            //AO USER
280
            //ESTA E' OUTRA CHAVE , e' a chave de api para aplicacoes
281
            ((AppUser)user).setChaveApi(apikey);
282
        }
175 jmachado 283
        if(password != null && password.length() > 0)
284
        {
285
            user.setPassword(BytesUtils.getDigestMD5Hex(password));
286
        }
206 jmachado 287
        if(user instanceof Teacher)
288
        {
381 jmachado 289
            ((Teacher)user).setMainArea(mainArea);
206 jmachado 290
            ((Teacher)user).setSigesCode(code);
215 jmachado 291
            ((Teacher)user).setAcademicDegree(academicDegree);
206 jmachado 292
        }
293
        else if(user instanceof Student)
294
        {
381 jmachado 295
            ((Student)user).setMainArea(mainArea);
206 jmachado 296
            ((Student)user).setSigesCode(code);
297
        }
113 fvelez 298
    }
299
 
381 jmachado 300
    public 1.5.0/docs/api/java/lang/String.html">String getMainArea()
301
    {
302
        return mainArea;
303
    }
304
 
305
    public void setMainArea(1.5.0/docs/api/java/lang/String.html">String mainArea)
306
    {
307
        this.mainArea = mainArea;
308
    }
309
 
215 jmachado 310
    public 1.5.0/docs/api/java/lang/String.html">String getScholarDegree()
311
    {
312
        return scholarDegree;
313
    }
314
 
315
    public void setScholarDegree(1.5.0/docs/api/java/lang/String.html">String scholarDegree)
316
    {
317
        this.scholarDegree = scholarDegree;
318
    }
319
 
320
    public 1.5.0/docs/api/java/lang/String.html">String getAcademicDegree()
321
    {
322
        return academicDegree;
323
    }
324
 
219 jmachado 325
    public List<CourseUnitGradeView> getGrades()
326
    {
327
        return grades;
328
    }
329
 
330
    public void setGrades(List<CourseUnitGradeView> grades)
331
    {
332
        this.grades = grades;
333
    }
334
 
215 jmachado 335
    public void setAcademicDegree(1.5.0/docs/api/java/lang/String.html">String academicDegree)
336
    {
337
        this.academicDegree = academicDegree;
338
    }
339
 
340
    public List<RecordView> getCreatorRecords()
341
    {
342
        return creatorRecords;
343
    }
344
 
345
    HashMap<RecordEnum,List<RecordView>> recordCreatorMap = new HashMap<RecordEnum,List<RecordView>>();
346
 
347
    public List<RecordView> getCreatorRecords(RecordEnum type)
348
    {
349
        if(creatorRecords != null && creatorRecords.size() > 0)
350
        {
351
            List<RecordView> views = recordCreatorMap.get(type);
352
            if(views == null)
353
            {
354
                views = new ArrayList<RecordView>();
355
                for(RecordView recordView: creatorRecords)
356
                {
357
                    if(recordView.getTypeEnum() == type)
358
                        views.add(recordView);
359
                }
360
                recordCreatorMap.put(type,views);
361
            }
362
            return views;
363
        }
364
        return null;
365
    }
366
 
367
    HashMap<RecordEnum,List<RecordView>> recordContributorMap = new HashMap<RecordEnum,List<RecordView>>();
368
 
369
    public List<RecordView> getContributorRecords(RecordEnum type)
370
    {
371
        if(contributorRecords != null && contributorRecords.size() > 0)
372
        {
373
            List<RecordView> views = recordContributorMap.get(type);
374
            if(views == null)
375
            {
376
                views = new ArrayList<RecordView>();
377
                for(RecordView recordView: contributorRecords)
378
                {
379
                    if(recordView.getTypeEnum() == type)
380
                        views.add(recordView);
381
                }
382
                recordContributorMap.put(type,views);
383
            }
384
            return views;
385
        }
386
        return null;
387
    }
388
 
389
    public void setCreatorRecords(List<RecordView> creatorRecords)
390
    {
391
        this.creatorRecords = creatorRecords;
392
    }
393
 
394
    public List<RecordView> getContributorRecords()
395
    {
396
        return contributorRecords;
397
    }
398
 
399
    public void setContributorRecords(List<RecordView> contributorRecords)
400
    {
401
        this.contributorRecords = contributorRecords;
402
    }
403
 
132 fvelez 404
    public void persistViewInObjectUser(User user)
405
    {
198 jmachado 406
        user.setName(name);
485 jmachado 407
        user.setAddress(address);
408
        user.setZip(zip);
409
        user.setCountry(country);
368 jmachado 410
        user.setEmail(email);
485 jmachado 411
        user.setPhonenumber(phonenumber);
132 fvelez 412
        user.setOutEmail(outEmail);
485 jmachado 413
 
156 jmachado 414
        user.setPop3server(pop3server);
415
        user.setPop3username(pop3username);
416
        if(pop3password != null && pop3password.length()> 0)
417
            user.setPop3password(DesUtils.getInstance().encrypt(pop3password));
418
        user.setSkype(skype);
419
        user.setGmail(gmail);
420
        user.setMsn(msn);
485 jmachado 421
        user.setOffice(office);
422
        user.setExt(ext);
423
 
424
 
425
 
426
        user.setScholarDegree(scholarDegree);
175 jmachado 427
        if(user.getPassword() != null && user.getPassword().length() > 0 && password != null && password.length() > 0)
428
        {
429
            user.setPassword(BytesUtils.getDigestMD5Hex(password));
430
        }
220 jmachado 431
        if(user instanceof Teacher)
432
        {
433
            ((Teacher)user).setAcademicDegree(academicDegree);
434
        }
132 fvelez 435
    }
436
 
113 fvelez 437
    public 1.5.0/docs/api/java/lang/Class.html">Class getReferenceClass()
438
    {
203 jmachado 439
        return UserImpl.class;
113 fvelez 440
    }
441
 
442
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable()
443
    {
444
        return id;
445
    }
446
 
175 jmachado 447
 
206 jmachado 448
    public int getCode()
449
    {
450
        return code;
451
    }
452
 
453
    public void setCode(int code)
454
    {
455
        this.code = code;
456
    }
457
 
175 jmachado 458
    public boolean isPasswordLocal()
459
    {
460
        return passwordLocal;
461
    }
462
 
463
    public void setPasswordLocal(boolean passwordLocal)
464
    {
465
        this.passwordLocal = passwordLocal;
466
    }
467
 
468
 
469
    public 1.5.0/docs/api/java/lang/String.html">String getPasswordAgain()
470
    {
471
        return passwordAgain;
472
    }
473
 
474
    public void setPasswordAgain(1.5.0/docs/api/java/lang/String.html">String passwordAgain)
475
    {
476
        this.passwordAgain = passwordAgain;
477
    }
478
 
479
    public 1.5.0/docs/api/java/lang/String.html">String getPassword()
480
    {
481
        return password;
482
    }
483
 
484
    public void setPassword(1.5.0/docs/api/java/lang/String.html">String password)
485
    {
486
        this.password = password;
487
    }
488
 
113 fvelez 489
    public long getId() {
490
        return id;
491
    }
492
 
493
    public void setId(long id) {
494
        this.id = id;
495
    }
496
 
497
    public 1.5.0/docs/api/java/lang/String.html">String getName() {
428 jmachado 498
        if(deleted)
499
        {
500
            return "(Apagado do Sistema) "  + name;
501
        }
502
        else
503
            return name;
113 fvelez 504
    }
505
 
506
    public void setName(1.5.0/docs/api/java/lang/String.html">String name) {
507
        this.name = name;
508
    }
509
 
132 fvelez 510
    public List<String> getUserRoles() {
113 fvelez 511
        return userRoles;
512
    }
513
 
132 fvelez 514
    public void setUserRoles(List<String> userRoles) {
113 fvelez 515
        this.userRoles = userRoles;
516
    }
517
 
518
    public 1.5.0/docs/api/java/lang/String.html">String getAddress() {
519
        return address;
520
    }
521
 
522
    public void setAddress(1.5.0/docs/api/java/lang/String.html">String address) {
523
        this.address = address;
524
    }
525
 
526
    public 1.5.0/docs/api/java/lang/String.html">String getZip() {
527
        return zip;
528
    }
529
 
530
    public void setZip(1.5.0/docs/api/java/lang/String.html">String zip) {
531
        this.zip = zip;
532
    }
533
 
534
    public 1.5.0/docs/api/java/lang/String.html">String getCountry() {
535
        return country;
536
    }
537
 
538
    public void setCountry(1.5.0/docs/api/java/lang/String.html">String country) {
539
        this.country = country;
540
    }
541
 
542
    public 1.5.0/docs/api/java/lang/String.html">String getEmail() {
543
        return email;
544
    }
545
 
298 jmachado 546
    public 1.5.0/docs/api/java/lang/String.html">String getSafeEmail()
547
    {
565 jmachado 548
 
1316 jmachado 549
        1.5.0/docs/api/java/lang/String.html">String email = getEmail();
550
        /*if(pop3username != null && pop3username.trim().length() > 0)
565 jmachado 551
            email = pop3username + "@" + Globals.EMAIL_LOCAL_SUFFIX;
552
        else
1316 jmachado 553
            email = username + "@" + Globals.EMAIL_LOCAL_SUFFIX*/;
565 jmachado 554
 
1316 jmachado 555
        if(email != null && email.indexOf("@") > 0)
298 jmachado 556
        {
311 jmachado 557
            1.5.0/docs/api/java/lang/String.html">String safe = email.replace("@", " [ AT ] ").replace("."," [ DOT ] ");
298 jmachado 558
            1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder result = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder();
559
            result.append("<script type=\"text/javascript\" language=\"JavaScript\">\n");
560
            for(int i = 0;i< safe.length();i++)
561
            {
562
                char c = safe.charAt(i);
563
                if(c != '\'')
564
                    result.append("document.write('").append(c).append("');\n");
565
            }
566
            result.append("</script>");
567
            return result.toString();
568
        }
569
        return email;
570
    }
571
 
113 fvelez 572
    public void setEmail(1.5.0/docs/api/java/lang/String.html">String email) {
573
        this.email = email;
574
    }
575
 
576
    public 1.5.0/docs/api/java/lang/String.html">String getPhonenumber() {
577
        return phonenumber;
578
    }
579
 
580
    public void setPhonenumber(1.5.0/docs/api/java/lang/String.html">String phonenumber) {
581
        this.phonenumber = phonenumber;
582
    }
132 fvelez 583
 
584
    public 1.5.0/docs/api/java/lang/String.html">String getOutEmail() {
585
        return outEmail;
586
    }
587
 
588
    public void setOutEmail(1.5.0/docs/api/java/lang/String.html">String outEmail) {
589
        this.outEmail = outEmail;
590
    }
591
 
592
    public 1.5.0/docs/api/java/lang/String.html">String getBi() {
593
        return bi;
594
    }
595
 
596
    public void setBi(1.5.0/docs/api/java/lang/String.html">String bi) {
597
        this.bi = bi;
598
    }
599
 
600
    public 5+0%2Fdocs%2Fapi+Date">Date getBirthDate() {
601
        return birthDate;
602
    }
603
 
604
    public void setBirthDate(5+0%2Fdocs%2Fapi+Date">Date birthDate) {
605
        this.birthDate = birthDate;
146 jmachado 606
    }
132 fvelez 607
 
608
    public 1.5.0/docs/api/java/lang/String.html">String getUsername() {
609
        return username;
610
    }
611
 
612
    public void setUsername(1.5.0/docs/api/java/lang/String.html">String username) {
613
        this.username = username;
614
    }
146 jmachado 615
 
156 jmachado 616
    public User getUser()
617
    {
618
        return user;
619
    }
620
 
621
    public void setUser(User user)
622
    {
623
        this.user = user;
624
    }
625
 
626
    public 1.5.0/docs/api/java/lang/String.html">String getPop3server()
627
    {
628
        return pop3server;
629
    }
630
 
631
    public void setPop3server(1.5.0/docs/api/java/lang/String.html">String pop3server)
632
    {
633
        this.pop3server = pop3server;
634
    }
635
 
636
    public 1.5.0/docs/api/java/lang/String.html">String getPop3username()
637
    {
638
        return pop3username;
639
    }
640
 
641
    public void setPop3username(1.5.0/docs/api/java/lang/String.html">String pop3username)
642
    {
643
        this.pop3username = pop3username;
644
    }
645
 
646
    public 1.5.0/docs/api/java/lang/String.html">String getPop3passwordAgain()
647
    {
648
        return pop3passwordAgain;
649
    }
650
 
651
    public void setPop3passwordAgain(1.5.0/docs/api/java/lang/String.html">String pop3passwordAgain)
652
    {
653
        this.pop3passwordAgain = pop3passwordAgain;
654
    }
655
 
656
    public 1.5.0/docs/api/java/lang/String.html">String getPop3password()
657
    {
658
        return pop3password;
659
    }
660
 
661
    public void setPop3password(1.5.0/docs/api/java/lang/String.html">String pop3password)
662
    {
663
        this.pop3password = pop3password;
664
    }
665
 
666
    public 1.5.0/docs/api/java/lang/String.html">String getSkype()
667
    {
668
        return skype;
669
    }
670
 
671
    public void setSkype(1.5.0/docs/api/java/lang/String.html">String skype)
672
    {
673
        this.skype = skype;
674
    }
675
 
676
    public 1.5.0/docs/api/java/lang/String.html">String getGmail()
677
    {
678
        return gmail;
679
    }
680
 
681
    public void setGmail(1.5.0/docs/api/java/lang/String.html">String gmail)
682
    {
683
        this.gmail = gmail;
684
    }
685
 
686
    public 1.5.0/docs/api/java/lang/String.html">String getMsn()
687
    {
688
        return msn;
689
    }
690
 
691
    public void setMsn(1.5.0/docs/api/java/lang/String.html">String msn)
692
    {
693
        this.msn = msn;
694
    }
695
 
1782 jmachado 696
    public boolean checkIsOwnedBy(GenericUser u)
146 jmachado 697
    {
1782 jmachado 698
        return checkIsOwnedBy(u, false);
208 jmachado 699
    }
700
 
1782 jmachado 701
    public boolean checkIsOwnedBy(GenericUser u, boolean transaction)
208 jmachado 702
    {
146 jmachado 703
        return u.getId() == id;
704
    }
705
 
706
    public GenericUser getOwner()
707
    {
708
        return user;
709
    }
710
 
711
    public List<String> getOwnerRoles()
712
    {
713
        return getUserRoles();
714
    }
715
 
716
    /**
717
     * Not implemented here
718
     * @return null
719
     */
720
    public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole()
721
    {
722
        logger.warn("Invoke not implemented method in class:" + getClass().getName());
723
        return null;
724
    }
215 jmachado 725
 
726
 
727
    public static List<UserView> getViews(List<User> users)
728
    {
729
        if(users == null)
730
            return null;
731
        List<UserView> views = new ArrayList<UserView>();
732
        for(User u: users)
733
        {
734
            views.add(new UserView(u));
735
        }
736
        return views;
737
    }
1510 jmachado 738
 
739
    public static List<UserView> getViewsFromIds(List<Long> usersIds)
740
    {
741
        if(usersIds == null)
742
            return null;
743
        List<UserView> views = new ArrayList<UserView>();
744
        for(1.5.0/docs/api/java/lang/Long.html">Long uId: usersIds)
745
        {
746
            views.add(new UserView(DaoFactory.getUserDaoImpl().load(uId)));
747
        }
748
        return views;
749
    }
749 jmachado 750
     public static List<UserView> getTeacherViews(List<Teacher> users)
751
    {
752
        if(users == null)
753
            return null;
754
        List<UserView> views = new ArrayList<UserView>();
755
        for(User u: users)
756
        {
757
            views.add(new UserView(u));
758
        }
759
        return views;
760
    }
215 jmachado 761
 
749 jmachado 762
 
763
 
215 jmachado 764
    public static Set<User> loadUsers(List<UserView> views)
765
    {
766
        if(views != null)
767
        {
768
            Set<User> users = new HashSet<User>();
769
            for(UserView view: views)
770
            {
771
                User u = DaoFactory.getUserDaoImpl().load(view.getId());
772
                users.add(u);
773
            }
774
            return users;
775
        }
776
        return null;
777
    }
778
 
779
    public List<CourseView> getCourses()
780
    {
781
        return courses;
782
    }
783
 
784
    public List<CourseUnitView> getCourseUnits()
785
    {
786
        return courseUnits;
787
    }
788
 
789
    public void setCourses(List<CourseView> courses)
790
    {
791
        this.courses = courses;
792
    }
793
 
794
    public void setCourseUnits(List<CourseUnitView> courseUnits)
795
    {
796
        this.courseUnits = courseUnits;
797
    }
798
 
381 jmachado 799
    public 1.5.0/docs/api/java/lang/String.html">String getOffice()
800
    {
801
        return office;
802
    }
803
 
804
    public void setOffice(1.5.0/docs/api/java/lang/String.html">String office)
805
    {
806
        this.office = office;
807
    }
808
 
809
    public 1.5.0/docs/api/java/lang/String.html">String getExt()
810
    {
811
        return ext;
812
    }
813
 
814
    public void setExt(1.5.0/docs/api/java/lang/String.html">String ext)
815
    {
816
        this.ext = ext;
817
    }
818
 
428 jmachado 819
    public boolean isDeleted()
820
    {
821
        return deleted;
822
    }
823
 
824
    public void setDeleted(boolean deleted)
825
    {
826
        this.deleted = deleted;
827
    }
828
 
1054 jmachado 829
    public boolean isPropinasEmDia() {
830
        return propinasEmDia;
831
    }
832
 
833
    public void setPropinasEmDia(boolean propinasEmDia) {
834
        this.propinasEmDia = propinasEmDia;
835
    }
836
 
837
    //    public List<Course> getCourses()
215 jmachado 838
//    {
839
//        if(courses == null)
840
//        {
841
//            if(user instanceof Teacher)
842
//            {
843
//                courses = ((TeacherImpl)user).getTeachedCoursesView();
844
//            }
845
//            else if(user instanceof Student)
846
//            {
847
//                courses = ((StudentImpl)user).getSubscribedCoursesView();
848
//            }
849
//        }
850
//        return courses;
851
//    }
852
//
853
//    public List<CourseUnit> getCourseUnits()
854
//    {
855
//        if(courseUnits == null)
856
//        {
857
//            if(user instanceof Teacher)
858
//            {
859
//                courseUnits = ((TeacherImpl)user).getTeachedUnitsView();
860
//
861
//            }
862
//            else if(user instanceof Student)
863
//            {
864
//                courseUnits = ((StudentImpl)user).getSubscribedUnitsView();
865
//            }
866
//        }
867
//        return courseUnits;
868
//    }
1553 jmachado 869
 
870
 
871
    public 1.5.0/docs/api/java/lang/String.html">String getNacionalidade() {
872
        return nacionalidade;
873
    }
874
 
875
    public void setNacionalidade(1.5.0/docs/api/java/lang/String.html">String nacionalidade) {
876
        this.nacionalidade = nacionalidade;
877
    }
878
 
879
    public 1.5.0/docs/api/java/lang/String.html">String getPais() {
880
        return pais;
881
    }
882
 
883
    public void setPais(1.5.0/docs/api/java/lang/String.html">String pais) {
884
        this.pais = pais;
885
    }
113 fvelez 886
}