Rev 214 |
Rev 223 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package pt.estgp.estgweb.domain;
import pt.estgp.estgweb.Globals;
import pt.utl.ist.berserk.logic.serviceManager.IServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.ServiceManager;
import java.util.List;
import java.util.ArrayList;
import org.apache.log4j.Logger;
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 12:51:32
* @see pt.estgp.estgweb
*/
public class TeacherImpl
extends Teacher
{
public static final 1.5.0/docs/api/java/lang/String.html">String TEACHER_ROLE = Globals.
TEACHER_ROLE;
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);
private List
<CourseUnit
> teachedUnitsView =
null;
private List
<Course
> teachedCoursesView =
null;
public TeacherImpl
()
{
setScholarDegree
(Globals.
PROFILE_SCHOLAR_DEGREE_SUPERIOR);
}
public 1.5.0/docs/api/java/lang/String.html">String getManagedRole
() {
return TEACHER_ROLE
;
}
public List
<Course
> getTeachedCoursesView
()
{
getTeachedUnitsView
();
return teachedCoursesView
;
}
public List
<CourseUnit
> getTeachedUnitsView
()
{
if(teachedUnitsView ==
null)
{
teachedCoursesView =
new ArrayList
<Course
>();
try
{
IServiceManager sm = ServiceManager.
getInstance();
1.5.0/docs/api/java/lang/String.html">String[] names =
new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"};
5+0%2Fdocs%2Fapi+Object">Object[] args =
new 5+0%2Fdocs%2Fapi+Object">Object[]{getId
()};
teachedUnitsView =
(List
<CourseUnit
>) sm.
execute(null,
"LoadTeachedUnits", args, names
);
if(teachedUnitsView ==
null)
teachedUnitsView =
new ArrayList
<CourseUnit
>();
for(CourseUnit c: teachedUnitsView
)
{
if(!teachedCoursesView.
contains(c.
getCourse()))
{
teachedCoursesView.
add(c.
getCourse());
}
}
}
catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e
)
{
logger.
error(e,e
);
}
}
return teachedUnitsView
;
}
public boolean hasCourseUnit
(long id
)
{
return hasCourseUnit
(id,
false);
}
public boolean hasCourseUnit
(CourseUnit courseUnit
)
{
return hasCourseUnit
(courseUnit.
getId(),
false);
}
public boolean hasCourseUnit
(long id,
boolean transaction
)
{
List
<CourseUnit
> cUnits
;
if(transaction
)
cUnits =
new ArrayList
<CourseUnit
>(getTeachedUnits
());
else
cUnits = getTeachedUnitsView
();
if(cUnits ==
null)
return false;
for(CourseUnit c: cUnits
)
{
if(c.
getId() == id
)
return true;
}
return false;
}
}