public class ReadDetailedTeacherProfessorshipsByExecutionYear extends ReadDetailedTeacherProfessorshipsAbstractService {
protected List run(String teacherID, String executionYearID) throws FenixServiceException {
final Teacher teacher = FenixFramework.getDomainObject(teacherID);
if (teacher == null) {
throw new DomainException("error.noTeacher");
}
final ExecutionYear executionYear;
if (Strings.isNullOrEmpty(executionYearID)) {
executionYear = ExecutionYear.readCurrentExecutionYear();
} else {
executionYear = FenixFramework.getDomainObject(executionYearID);
}
final List<Professorship> responsibleFors = new ArrayList();
for (final Professorship professorship : teacher.responsibleFors()) {
if (professorship.getExecutionCourse().getExecutionPeriod().getExecutionYear() == executionYear) {
responsibleFors.add(professorship);
}
}
return getDetailedProfessorships(teacher.getProfessorships(executionYear), responsibleFors);
}