package net.sourceforge.fenixedu.domain.inquiries; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import net.sourceforge.fenixedu.dataTransferObject.InfoStudent; import net.sourceforge.fenixedu.dataTransferObject.inquiries.InfoInquiriesCourse3; import net.sourceforge.fenixedu.dataTransferObject.inquiries.InfoInquiriesDemographicalAndAcademical3; import net.sourceforge.fenixedu.domain.ExecutionCourse; import net.sourceforge.fenixedu.domain.ExecutionDegree; import net.sourceforge.fenixedu.domain.ExecutionPeriod; import net.sourceforge.fenixedu.domain.RootDomainObject; import net.sourceforge.fenixedu.domain.SchoolClass; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.student.Registration; import net.sourceforge.zas.metainfo.AccessControlled; /** * * @author José Pedro Pereira - DSI - ISCTE - Linkare TI * */ public class InquiriesDemographicalAndAcademical3 extends InquiriesDemographicalAndAcademical3_Base { static final public Comparator PROBLEMATIC_DATA_REPORT_DATE_COMPARATOR = new Comparator() { public int compare(InquiriesDemographicalAndAcademical3 o1, InquiriesDemographicalAndAcademical3 o2) { if (o1.getProblematicDataReportDate() == null) { return -1; } if (o2.getProblematicDataReportDate() == null) { return 1; } return o1.getProblematicDataReportDate().compareTo(o2.getProblematicDataReportDate()); } }; public InquiriesDemographicalAndAcademical3(Registration registration, ExecutionPeriod executionPeriod) { super(); setRootDomainObject(RootDomainObject.getInstance()); checkDuplicateInquiries(registration, executionPeriod); checkForinquiriesRegistry(registration, executionPeriod); setRegistration(registration); setExecutionPeriod(executionPeriod); setSaved(false); setWasSavedAutomatically(false); } public static void checkForinquiriesRegistry(Registration registration, ExecutionPeriod executionPeriod) { InquiriesRegistry3 inquiryRegistry = registration.getAssociatedInquiriesRegistries3ByExecutionPeriod(executionPeriod); if (inquiryRegistry != null && inquiryRegistry.getFinishedAnswering() == Boolean.TRUE) throw new DomainException("allready.responded.inquiries.for.execution.period"); } public static void checkDuplicateInquiries(Registration registration, ExecutionPeriod executionPeriod) { if (registration.getAssociatedInquiriesDemographicalAndAcademical3ByExecutionPeriod(executionPeriod) != null) throw new DomainException("cannot.respond.twice.to.inquiries.by.execution.period"); } /** * * @param executionDegree * @param executionDegreeStudent * @param executionPeriod * @param schoolClass * @param infoInquiriesDemographicalAndAcademical3 * * Preconditions: - executionDegree != null - * executionDegreeStudent != null - executionPeriod != null * Postcondition: - A new inquiriesDemographicalAndAcademical is * created, referencing correctly the other domainObjects and its * basic properties are initialized Invariants: - None * @param infoStudent */ public InquiriesDemographicalAndAcademical3(Registration registration, ExecutionDegree executionDegree, ExecutionPeriod executionPeriod, SchoolClass schoolClass, InfoInquiriesDemographicalAndAcademical3 infoInquiriesDemographicalAndAcademical3, InfoStudent infoStudent) { this(registration, executionPeriod); if ((executionDegree == null) || (executionPeriod == null)) { throw new DomainException("Neither the executionDegree nor executionPeriod should not be null!"); } this.setExecutionDegree(executionDegree); this.setExecutionPeriod(executionPeriod); this.setStudentSchoolClass(schoolClass); this.setBasicProperties(infoInquiriesDemographicalAndAcademical3); for (InfoInquiriesCourse3 infoInquiryCourse3 : infoInquiriesDemographicalAndAcademical3.getInfoInquiriesCourses3()) { ExecutionDegree executionDegreeCourse = (ExecutionDegree) RootDomainObject.readDomainObjectByOID( ExecutionDegree.class, infoInquiryCourse3.getExecutionDegree().getIdInternal()); ExecutionCourse executionCourse = (ExecutionCourse) RootDomainObject.readDomainObjectByOID(ExecutionCourse.class, infoInquiryCourse3.getExecutionCourse().getIdInternal()); new InquiriesCourse3(this, executionCourse, executionDegreeCourse, executionDegree, executionPeriod, infoInquiryCourse3, registration.getEntryGradeClassification(), registration .getApprovationRatioClassification(), registration.getArithmeticMeanClassification()); } } private void setBasicProperties(InfoInquiriesDemographicalAndAcademical3 infoInquiriesDemographicalAndAcademical3) { this.setStudentCurricularYear(infoInquiriesDemographicalAndAcademical3.getStudentCurricularYear()); this.setAge(infoInquiriesDemographicalAndAcademical3.getAge()); this.setDistrict(infoInquiriesDemographicalAndAcademical3.getDistrict()); this.setGender(infoInquiriesDemographicalAndAcademical3.getGender()); if (infoInquiriesDemographicalAndAcademical3.getStudentSchoolClass() != null) { this.setStudentSchoolClass(infoInquiriesDemographicalAndAcademical3.getStudentSchoolClass().getSchoolClass()); } this.setDayPeriodType(infoInquiriesDemographicalAndAcademical3.getDayPeriodType()); this.setIsWorkingStudent(infoInquiriesDemographicalAndAcademical3.getIsWorkingStudent()); this.setReprovedAnyCourse(infoInquiriesDemographicalAndAcademical3.getReprovedAnyCourse()); this.setNumReprovedCourses(infoInquiriesDemographicalAndAcademical3.getNumReprovedCourses()); this.setReprovedAnyYear(infoInquiriesDemographicalAndAcademical3.getReprovedAnyYear()); this.setNumReprovedYears(infoInquiriesDemographicalAndAcademical3.getNumReprovedYears()); this.setIngressDegreeFirstChoice(infoInquiriesDemographicalAndAcademical3.getIngressDegreeFirstChoice()); this.setIngressUniversityFirstChoice(infoInquiriesDemographicalAndAcademical3.getIngressUniversityFirstChoice()); this.setIsDislocated(infoInquiriesDemographicalAndAcademical3.getIsDislocated()); this.setHasSocialServicesScholarship(infoInquiriesDemographicalAndAcademical3.getHasSocialServicesScholarship()); this.setClassRooms(infoInquiriesDemographicalAndAcademical3.getClassRooms()); this.setInformaticLabs(infoInquiriesDemographicalAndAcademical3.getInformaticLabs()); this.setStudyRooms(infoInquiriesDemographicalAndAcademical3.getStudyRooms()); this.setLabs(infoInquiriesDemographicalAndAcademical3.getLabs()); this.setLaisure(infoInquiriesDemographicalAndAcademical3.getLaisure()); this.setBathrooms(infoInquiriesDemographicalAndAcademical3.getBathrooms()); this.setBibliography(infoInquiriesDemographicalAndAcademical3.getBibliography()); this.setForeignLanguage(infoInquiriesDemographicalAndAcademical3.getForeignLanguage()); this.setSoftwareAndHardware(infoInquiriesDemographicalAndAcademical3.getSoftwareAndHardware()); this.setFotocopyMachines(infoInquiriesDemographicalAndAcademical3.getFotocopyMachines()); this.setMultimediaMaterial(infoInquiriesDemographicalAndAcademical3.getMultimediaMaterial()); this.setClassRoomsInsufficient(infoInquiriesDemographicalAndAcademical3.getClassRoomsInsufficient()); this.setInformaticLabsInsufficient(infoInquiriesDemographicalAndAcademical3.getInformaticLabsInsufficient()); this.setStudyRoomsInsufficient(infoInquiriesDemographicalAndAcademical3.getStudyRoomsInsufficient()); this.setLabsInsufficient(infoInquiriesDemographicalAndAcademical3.getLabsInsufficient()); this.setLaisureInsufficient(infoInquiriesDemographicalAndAcademical3.getLaisureInsufficient()); this.setBathroomsInsufficient(infoInquiriesDemographicalAndAcademical3.getBathroomsInsufficient()); this.setBibliographyInsufficient(infoInquiriesDemographicalAndAcademical3.getBibliographyInsufficient()); this.setForeignLanguageInsufficient(infoInquiriesDemographicalAndAcademical3.getForeignLanguageInsufficient()); this.setSoftwareAndHardwareInsufficient(infoInquiriesDemographicalAndAcademical3.getSoftwareAndHardwareInsufficient()); this.setFotocopyMachinesInsufficient(infoInquiriesDemographicalAndAcademical3.getFotocopyMachinesInsufficient()); this.setMultimediaMaterialInsufficient(infoInquiriesDemographicalAndAcademical3.getMultimediaMaterialInsufficient()); this.setBiblio(infoInquiriesDemographicalAndAcademical3.getBiblio()); this.setInformaticsSupport(infoInquiriesDemographicalAndAcademical3.getInformaticsSupport()); this.setAdministrativeOffice(infoInquiriesDemographicalAndAcademical3.getAdministrativeOffice()); this.setTesourary(infoInquiriesDemographicalAndAcademical3.getTesourary()); this.setLanguagesCenter(infoInquiriesDemographicalAndAcademical3.getLanguagesCenter()); this.setMobilityOffice(infoInquiriesDemographicalAndAcademical3.getMobilityOffice()); this.setDegreeAdminOffice(infoInquiriesDemographicalAndAcademical3.getDegreeAdminOffice()); this.setResearchCenters(infoInquiriesDemographicalAndAcademical3.getResearchCenters()); this.setBookShop(infoInquiriesDemographicalAndAcademical3.getBookShop()); this.setFotocopyServices(infoInquiriesDemographicalAndAcademical3.getFotocopyServices()); this.setStudentAssociation(infoInquiriesDemographicalAndAcademical3.getStudentAssociation()); this.setAuxiliarAndSecurityPersonnel(infoInquiriesDemographicalAndAcademical3.getAuxiliarAndSecurityPersonnel()); this.setSchedule(infoInquiriesDemographicalAndAcademical3.getSchedule()); this.setYearCouncil(infoInquiriesDemographicalAndAcademical3.getYearCouncil()); this.setDegreePedagogicalComitee(infoInquiriesDemographicalAndAcademical3.getDegreePedagogicalComitee()); this.setPedagogicalCouncil(infoInquiriesDemographicalAndAcademical3.getPedagogicalCouncil()); this.setDegreeGlobalSatisfaction(infoInquiriesDemographicalAndAcademical3.getDegreeGlobalSatisfaction()); this.setUniversityGlobalSatisfaction(infoInquiriesDemographicalAndAcademical3.getUniversityGlobalSatisfaction()); this.setDegreeTheoreticalKnowledge(infoInquiriesDemographicalAndAcademical3.getDegreeTheoreticalKnowledge()); this.setDegreePracticalKnowledge(infoInquiriesDemographicalAndAcademical3.getDegreePracticalKnowledge()); this.setDegreeWorkMarketIntegration(infoInquiriesDemographicalAndAcademical3.getDegreeWorkMarketIntegration()); this.setUniversityComparedToOthers(infoInquiriesDemographicalAndAcademical3.getUniversityComparedToOthers()); this.setDegreePositivePoint1(infoInquiriesDemographicalAndAcademical3.getDegreePositivePoint1()); this.setDegreeImprovmentPoint1(infoInquiriesDemographicalAndAcademical3.getDegreeImprovmentPoint1()); } public void copyFromInfo(InfoInquiriesDemographicalAndAcademical3 infoInquiry) { setBasicProperties(infoInquiry); for (InfoInquiriesCourse3 infoInquiryCourse3 : infoInquiry.getInfoInquiriesCourses3()) { ExecutionCourse executionCourse = RootDomainObject.getInstance().readExecutionCourseByOID( infoInquiryCourse3.getExecutionCourse().getIdInternal()); InquiriesCourse3 inquiriesCourse3 = getAssociatedInquiriesCourseByExecutionCourse(executionCourse); if (inquiriesCourse3 != null) inquiriesCourse3.copyFromInfo(infoInquiryCourse3); } } public InquiriesCourse3 getAssociatedInquiriesCourseByExecutionCourse(ExecutionCourse executionCourse) { for (InquiriesCourse3 inquiryCourse : getAssociatedInquiriesCourses3()) if (inquiryCourse.getExecutionCourse() == executionCourse) return inquiryCourse; return null; } public boolean containsInquiryCourse(ExecutionCourse executionCourse) { for (InquiriesCourse3 course : getAssociatedInquiriesCourses3()) { if (course.getExecutionCourse() == executionCourse) return true; } return false; } @AccessControlled("STUDENT || GEP") public void removeProblematicDataReport() { super.setProblematicDataReportResolved(true); } public void delete() { for (; !getAssociatedInquiriesCourses3().isEmpty(); getAssociatedInquiriesCourses3().iterator().next().delete()) ; for (; !getAssociatedInquiriesPreviousGrades3().isEmpty(); getAssociatedInquiriesPreviousGrades3().iterator().next() .delete()) ; removeStudentSchoolClass(); removeRegistration(); removeExecutionDegree(); removeExecutionPeriod(); removeRootDomainObject(); deleteDomainObject(); } public Collection getCoursesWithMissingProfessorships() { Collection result = new ArrayList(); for (InquiriesCourse3 inquiriesCourse3 : getAssociatedInquiriesCourses3()) { if (inquiriesCourse3.getExecutionCourse().getProfessorshipsCount() == 0) { result.add(inquiriesCourse3.getExecutionCourse()); } } return result; } }