/* * InfoExecutionCourse.java * * Created on 28 de Novembro de 2002, 3:41 */ package net.sourceforge.fenixedu.dataTransferObject; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sourceforge.fenixedu.dataTransferObject.gesdis.InfoCourseReport; import net.sourceforge.fenixedu.dataTransferObject.gesdis.InfoSiteEvaluationStatistics; import net.sourceforge.fenixedu.dataTransferObject.teacher.InfoNonAffiliatedTeacher; import net.sourceforge.fenixedu.domain.CourseLoad; import net.sourceforge.fenixedu.domain.CurricularCourse; import net.sourceforge.fenixedu.domain.CurricularCourseScope; import net.sourceforge.fenixedu.domain.DomainReference; import net.sourceforge.fenixedu.domain.Evaluation; import net.sourceforge.fenixedu.domain.Exam; import net.sourceforge.fenixedu.domain.ExecutionCourse; import net.sourceforge.fenixedu.domain.ExecutionYear; import net.sourceforge.fenixedu.domain.Grouping; import net.sourceforge.fenixedu.domain.NonAffiliatedTeacher; import net.sourceforge.fenixedu.domain.Shift; import net.sourceforge.fenixedu.domain.ShiftType; import net.sourceforge.fenixedu.domain.time.calendarStructure.AcademicInterval; import net.sourceforge.fenixedu.util.EntryPhase; /** * @author tfc130 */ public class InfoExecutionCourse extends InfoObject { private final DomainReference executionCourseDomainReference; public InfoExecutionCourse(final ExecutionCourse executionCourse) { executionCourseDomainReference = new DomainReference(executionCourse); } public static InfoExecutionCourse newInfoFromDomain(final ExecutionCourse executionCourse) { return executionCourse == null ? null : new InfoExecutionCourse(executionCourse); } public ExecutionCourse getExecutionCourse() { return executionCourseDomainReference == null ? null : executionCourseDomainReference.getObject(); } @Override public boolean equals(Object obj) { return obj instanceof InfoExecutionCourse && getExecutionCourse() == ((InfoExecutionCourse) obj).getExecutionCourse(); } @Override public int hashCode() { return getExecutionCourse().hashCode(); } @Override public Integer getIdInternal() { return getExecutionCourse().getIdInternal(); } @Override public void setIdInternal(Integer integer) { throw new Error("Method should not be called!"); } // =================== FIELDS RETRIEVED BY DOMAIN LOGIC // ======================= public Double getWeeklyTheoreticalHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.TEORICA).doubleValue(); } public Double getWeeklyPraticalHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.PRATICA).doubleValue(); } public Double getWeeklyTheoPratHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.TEORICO_PRATICA).doubleValue(); } public Double getWeeklyLabHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.LABORATORIAL).doubleValue(); } public Double getWeeklyFieldWorkHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.FIELD_WORK).doubleValue(); } public Double getWeeklyProblemsHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.PROBLEMS).doubleValue(); } public Double getWeeklySeminaryHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.SEMINARY).doubleValue(); } public Double getWeeklyTrainingPeriodHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.TRAINING_PERIOD).doubleValue(); } public Double getWeeklyTutorialOrientationHours() { return getExecutionCourse().getWeeklyCourseLoadTotalQuantityByShiftType(ShiftType.TUTORIAL_ORIENTATION).doubleValue(); } public String getNome() { return getExecutionCourse().getNome(); } public String getSigla() { return getExecutionCourse().getSigla(); } public String getComment() { return getExecutionCourse().getComment(); } public Boolean getHasSite() { return getExecutionCourse().hasSite(); } public Integer getNumberOfAttendingStudents() { return getExecutionCourse().getAttendsCount(); } public String getCourseReportFilled() { return (!getExecutionCourse().hasCourseReport() || getExecutionCourse().getCourseReport().getReport() == null) ? "false" : "true"; } public String getEqualLoad() { return getExecutionCourse().getEqualLoad(); } public Boolean getAvailableForInquiries() { return getExecutionCourse().getAvailableForInquiries(); } public Boolean getAvailableGradeSubmission() { return getExecutionCourse().getAvailableGradeSubmission(); } @Deprecated public InfoExecutionPeriod getInfoExecutionPeriod() { return InfoExecutionPeriod.newInfoFromDomain(getExecutionCourse().getExecutionPeriod()); } public AcademicInterval getAcademicInterval() { return getExecutionCourse().getAcademicInterval(); } public InfoCourseReport getInfoCourseReport() { return InfoCourseReport.newInfoFromDomain(getExecutionCourse().getCourseReport()); } public List getAssociatedInfoShifts() { final List result = new ArrayList(); for (final Shift shift : getExecutionCourse().getAssociatedShifts()) { result.add(InfoShift.newInfoFromDomain(shift)); } return result; } public List getNonAffiliatedTeachers() { final List result = new ArrayList(); for (final NonAffiliatedTeacher nonAffiliatedTeacher : getExecutionCourse().getNonAffiliatedTeachers()) { result.add(InfoNonAffiliatedTeacher.newInfoFromDomain(nonAffiliatedTeacher)); } return result; } public List getAssociatedInfoEvaluations() { final List result = new ArrayList(); for (final Evaluation nonAffiliatedTeacher : getExecutionCourse().getAssociatedEvaluations()) { result.add(InfoEvaluation.newInfoFromDomain(nonAffiliatedTeacher)); } return result; } public List getAssociatedInfoCurricularCourses() { if (filteredAssociatedInfoCurricularCourses == null) { List result = new ArrayList(); for (final CurricularCourse curricularCourse : getExecutionCourse().getAssociatedCurricularCourses()) { final InfoCurricularCourse infoCurricularCourse = InfoCurricularCourse.newInfoFromDomain(curricularCourse); infoCurricularCourse.setInfoScopes(getInfoScopes(curricularCourse.getScopesSet())); result.add(infoCurricularCourse); } return result; } else { return getFilteredAssociatedInfoCurricularCourses(); } } private List getInfoScopes(final Collection curricularCourseScopes) { final List result = new ArrayList(); for (final CurricularCourseScope curricularCourseScope : curricularCourseScopes) { result.add(InfoCurricularCourseScope.newInfoFromDomain(curricularCourseScope)); } return result; } public List getAssociatedInfoCurricularCourses(final ExecutionYear executionYear) { List result = new ArrayList(); for (final CurricularCourse curricularCourse : getExecutionCourse().getAssociatedCurricularCourses()) { final InfoCurricularCourse infoCurricularCourse = InfoCurricularCourse.newInfoFromDomain(curricularCourse); infoCurricularCourse.setInfoScopes(getInfoScopes(curricularCourse.findCurricularCourseScopesIntersectingPeriod( executionYear.getBeginDate(), executionYear.getEndDate()))); result.add(infoCurricularCourse); } return result; } public List getAssociatedInfoExams() { if (filteredAssociatedInfoExams == null) { List result = new ArrayList(); for (final Exam exam : getExecutionCourse().getAssociatedExams()) { result.add(InfoExam.newInfoFromDomain(exam)); } return result; } else { return getFilteredAssociatedInfoExams(); } } public List getInfoGroupings() { if (filteredInfoGroupings == null) { List result = new ArrayList(); for (final Grouping grouping : getExecutionCourse().getGroupings()) { result.add(InfoGrouping.newInfoFromDomain(grouping)); } return result; } else { return getFilteredInfoGroupings(); } } public List getCourseLoads() { return getExecutionCourse().getCourseLoads(); } // =================== FIELDS NOT RETRIEVED BY DOMAIN LOGIC // ======================= // The following variable serves the purpose of indicating the // the curricular year in which the execution course is given // for a certain execution degree through which // the execution course was obtained. It should serve only for // view purposes!!! // It was created to be used and set by the ExamsMap Utilities. // It has no meaning in the buisness logic. private Integer curricularYear; public Integer getCurricularYear() { return curricularYear; } public void setCurricularYear(Integer integer) { curricularYear = integer; } // useful for coordinator portal protected InfoSiteEvaluationStatistics infoSiteEvaluationStatistics; public InfoSiteEvaluationStatistics getInfoSiteEvaluationStatistics() { return infoSiteEvaluationStatistics; } public void setInfoSiteEvaluationStatistics(InfoSiteEvaluationStatistics infoSiteEvaluationStatistics) { this.infoSiteEvaluationStatistics = infoSiteEvaluationStatistics; } private Double occupancy; public Double getOccupancy() { return occupancy; } public void setOccupancy(Double occupancy) { this.occupancy = occupancy; } private List filteredAssociatedInfoCurricularCourses; private List getFilteredAssociatedInfoCurricularCourses() { return filteredAssociatedInfoCurricularCourses; } public void setFilteredAssociatedInfoCurricularCourses( final List filteredAssociatedInfoCurricularCourses) { this.filteredAssociatedInfoCurricularCourses = filteredAssociatedInfoCurricularCourses; } private List filteredAssociatedInfoExams; private List getFilteredAssociatedInfoExams() { return filteredAssociatedInfoExams; } public void setFilteredAssociatedInfoExams(final List filteredAssociatedInfoExams) { this.filteredAssociatedInfoExams = filteredAssociatedInfoExams; } @Override public String toString() { return getExecutionCourse().toString(); } private List filteredInfoGroupings; private List getFilteredInfoGroupings() { return filteredInfoGroupings; } public void setFilteredInfoGroupings(List filteredInfoGroupings) { this.filteredInfoGroupings = filteredInfoGroupings; } public EntryPhase getEntryPhase() { return getExecutionCourse().getEntryPhase(); } }