Rev 202 | Rev 214 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
114 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
3 | import pt.estgp.estgweb.Globals; |
||
202 | jmachado | 4 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
5 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
6 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.ServiceManagerException; |
||
7 | import pt.utl.ist.berserk.logic.filterManager.exceptions.*; |
||
114 | jmachado | 8 | |
202 | jmachado | 9 | import java.util.Set; |
10 | import java.util.HashSet; |
||
11 | |||
12 | import org.apache.log4j.Logger; |
||
13 | |||
114 | jmachado | 14 | /** |
15 | * @author Jorge Machado |
||
16 | * @date 28/Fev/2008 |
||
17 | * @time 12:51:32 |
||
18 | * @see pt.estgp.estgweb |
||
19 | */ |
||
20 | public class TeacherImpl extends Teacher |
||
21 | { |
||
22 | |||
23 | public static final 1.5.0/docs/api/java/lang/String.html">String TEACHER_ROLE = Globals.TEACHER_ROLE; |
||
24 | |||
202 | jmachado | 25 | public 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(TeacherImpl.class); |
114 | jmachado | 26 | |
202 | jmachado | 27 | private Set<CourseUnit> teachedUnitsView = null; |
28 | |||
114 | jmachado | 29 | public 1.5.0/docs/api/java/lang/String.html">String getManagedRole() { |
30 | return TEACHER_ROLE; |
||
31 | } |
||
146 | jmachado | 32 | |
202 | jmachado | 33 | public Set<CourseUnit> getTeachedUnitsView() |
34 | { |
||
35 | if(teachedUnitsView == null) |
||
36 | { |
||
37 | try |
||
38 | { |
||
39 | IServiceManager sm = ServiceManager.getInstance(); |
||
40 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"}; |
||
41 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{getId()}; |
||
42 | teachedUnitsView = (Set<CourseUnit>) sm.execute(null, "LoadTeachedUnits", args, names); |
||
43 | if(teachedUnitsView == null) |
||
44 | teachedUnitsView = new HashSet<CourseUnit>(); |
||
45 | } |
||
46 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
47 | { |
||
48 | logger.error(e,e); |
||
49 | } |
||
50 | } |
||
51 | return teachedUnitsView; |
||
52 | } |
||
53 | |||
204 | jmachado | 54 | public boolean hasCourseUnit(long id) |
55 | { |
||
56 | return hasCourseUnit(id,false); |
||
57 | } |
||
58 | |||
146 | jmachado | 59 | public boolean hasCourseUnit(CourseUnit courseUnit) |
60 | { |
||
204 | jmachado | 61 | return hasCourseUnit(courseUnit.getId(),false); |
202 | jmachado | 62 | } |
63 | |||
204 | jmachado | 64 | public boolean hasCourseUnit(long id, boolean transaction) |
202 | jmachado | 65 | { |
66 | Set<CourseUnit> cUnits; |
||
67 | if(transaction) |
||
68 | cUnits = getTeachedUnits(); |
||
69 | else |
||
70 | cUnits = getTeachedUnitsView(); |
||
71 | if(cUnits == null) |
||
146 | jmachado | 72 | return false; |
202 | jmachado | 73 | for(CourseUnit c: cUnits) |
146 | jmachado | 74 | { |
204 | jmachado | 75 | if(c.getId() == id) |
146 | jmachado | 76 | return true; |
77 | } |
||
78 | return false; |
||
79 | } |
||
114 | jmachado | 80 | } |