package net.sourceforge.fenixedu.dataTransferObject.administrativeOffice.raides; import java.io.Serializable; import java.util.ResourceBundle; import net.sourceforge.fenixedu.domain.Degree; import net.sourceforge.fenixedu.domain.ExecutionPeriod; import net.sourceforge.fenixedu.domain.ExecutionYear; import net.sourceforge.fenixedu.domain.GrantOwnerType; import net.sourceforge.fenixedu.domain.LiteraryHabilitationType; import net.sourceforge.fenixedu.domain.Person; import net.sourceforge.fenixedu.domain.ProfessionConditionType; import net.sourceforge.fenixedu.domain.ProfessionSectorType; import net.sourceforge.fenixedu.domain.candidacy.Ingression; import net.sourceforge.fenixedu.domain.candidacy.StudentCandidacy; import net.sourceforge.fenixedu.domain.degree.DegreeType; import net.sourceforge.fenixedu.domain.person.MaritalStatus; import net.sourceforge.fenixedu.domain.student.PrecedentDegreeInformation; import net.sourceforge.fenixedu.domain.student.Registration; import net.sourceforge.fenixedu.domain.student.RegistrationAgreement; import net.sourceforge.fenixedu.domain.student.SecondarySchoolType; import net.sourceforge.fenixedu.domain.student.Student; import net.sourceforge.fenixedu.domain.student.StudentStatuteType; import net.sourceforge.fenixedu.domain.student.registrationStates.RegistrationStateType; import net.sourceforge.fenixedu.util.LanguageUtils; /** * * @author rjmvo * */ public class RAIDESStudentDataBean implements Serializable { // Ingression and frequency private Boolean isFirstTime; private String ingressionGrade; private Integer ingressionOption; private Ingression ingressionType; private Integer numberOfPreviousEnrollments; private Integer numberOfPreviousCandidacies; private Integer numberOfPreviousRegistrations; private String regime; private Boolean isPartialTime; private Boolean frequentOtherDegrees; private RegistrationAgreement registrationAgreement; // Student and family situation private MaritalStatus maritalStatus; private Boolean isDislocated; private String countryOfResidence; private String districtOfResidence; private String districtSubdivisionOfResidence; private LiteraryHabilitationType fatherLiteraryHabilitation; private LiteraryHabilitationType motherLiteraryHabilitation; private ProfessionSectorType studentProfessionSector; private ProfessionSectorType fatherProfessionSector; private ProfessionSectorType motherProfessionSector; private ProfessionConditionType studentProfessionCondition; private Boolean isDiligentStudent; private GrantOwnerType grantOwnerType; // Academic career private LiteraryHabilitationType formerLiteraryHabilitations; private String precedentInstitutionName; private String precedentDegreeDesignation; private String precedentDegreeCountry; private Integer precedentDegreeConclusionYear; private Integer precedentNumberOfFails; private SecondarySchoolType secondarySchoolType; private final ResourceBundle resourceBundle = ResourceBundle.getBundle("resources.EnumerationResources", LanguageUtils .getLocale()); public RAIDESStudentDataBean() { } public RAIDESStudentDataBean(Registration registration, ExecutionYear executionYear) { final Person person = registration.getPerson(); setPersonData(person); setRegistrationData(registration, executionYear); final StudentCandidacy candidacy = registration.getStudentCandidacy(); if (candidacy != null) { setCandidacyData(candidacy); final PrecedentDegreeInformation precedent = candidacy.getPrecedentDegreeInformation(); if (precedent != null) { setPrecedentDegreeInformationData(precedent); } } } private void setPersonData(Person person) { setMaritalStatus(person.getMaritalStatus()); setCountryOfResidence(person.getCountryOfResidence().getName()); setDistrictOfResidence(person.getDistrictOfResidence()); setDistrictSubdivisionOfResidence(person.getDistrictSubdivisionOfResidence()); setFatherLiteraryHabilitation(person.getFatherLiteraryHabilitationType()); setMotherLiteraryHabilitation(person.getMotherLiteraryHabilitationType()); setStudentProfessionSector(person.getProfessionSectorType()); setFatherProfessionSector(person.getFatherProfessionSectorType()); setMotherProfessionSector(person.getMotherProfessionSectorType()); setStudentProfessionCondition(person.getProfessionConditionType()); } private void setRegistrationData(Registration registration, ExecutionYear executionYear) { final Student student = registration.getStudent(); final ExecutionPeriod executionPeriod = executionYear.getFirstExecutionPeriod(); setFirstTime(registration.isFirstTime(executionYear)); setIngressionType(registration.getIngressionEnum()); setPartialTime(student.hasStatuteType(StudentStatuteType.PARTIAL_TIME_STUDENT, executionPeriod)); setDiligentStudent(student.hasStatuteType(StudentStatuteType.WORKING_STUDENT, executionPeriod)); Integer numinsc = registration.getRegistrationDataByExecutionYearCount() - 1; String degreeCode = registration.getDegree().getCode(); if ("9927".equals(degreeCode) || "8029".equals(degreeCode)) { Degree degree = Degree.readByCode("9927".equals(degreeCode) ? "9181" : "9140", true); Registration previous = registration.getStudent().getRegistrationFor(degree); if (previous != null) { numinsc += previous.getRegistrationDataByExecutionYearCount(); numinsc += getPreviousRegistrationDataByExecutionYearCount(previous); } else { numinsc += getPreviousRegistrationDataByExecutionYearCount(registration); } } else { numinsc += getPreviousRegistrationDataByExecutionYearCount(registration); } setNumberOfPreviousEnrollments(numinsc); setRegime(registration.getSchoolClassByExecutionYear(executionYear).getDayPeriodType().getLocalizedName()); setRegistrationAgreement(registration.getRegistrationAgreement()); } private void setCandidacyData(StudentCandidacy candidacy) { setIngressionGrade(String.valueOf(candidacy.getEntryGrade())); setFrequentOtherDegrees(candidacy.getFrequentOtherDegrees()); setDislocated(candidacy.getDislocated()); setGrantOwnerType(candidacy.getGrantOwnerType()); setNumberOfPreviousCandidacies(candidacy.getNumberOfPreviousCandidacies()); setNumberOfPreviousRegistrations(candidacy.getNumberOfPreviousEnrolments()); } private void setPrecedentDegreeInformationData(PrecedentDegreeInformation precedent) { setFormerLiteraryHabilitations(precedent.getFormerLiteraryHabilitations()); setPrecedentInstitutionName(precedent.getInstitutionName()); setPrecedentDegreeDesignation(precedent.getDegreeDesignation()); setPrecedentDegreeCountry(precedent.getCountry().getName()); setPrecedentDegreeConclusionYear(precedent.getConclusionYear()); setPrecedentNumberOfFails(precedent.getNumberOfFails()); setSecondarySchoolType(precedent.getSecondarySchoolType()); } private Integer getPreviousRegistrationDataByExecutionYearCount(Registration registration) { if (registration.getFirstState().getStateType() == RegistrationStateType.TRANSITION) { for (Registration previous : registration.getStudent().getRegistrationsByDegreeType(DegreeType.DEGREE)) { if (previous.getActiveStateType() == RegistrationStateType.TRANSITED) { return previous.getRegistrationDataByExecutionYearCount(); } } } return 0; } public Boolean getFirstTime() { return isFirstTime; } public void setFirstTime(Boolean isFirstTime) { this.isFirstTime = isFirstTime; } public String getIngressionGrade() { return ingressionGrade; } public void setIngressionGrade(String ingressionGrade) { this.ingressionGrade = ingressionGrade; } public Integer getIngressionOption() { return ingressionOption; } public void setIngressionOption(Integer ingressionOption) { this.ingressionOption = ingressionOption; } public String getIngressionType() { return ingressionType == null ? "" : ingressionType.name() + " - " + ingressionType.getFullDescription(); } public void setIngressionType(Ingression ingressionType) { this.ingressionType = ingressionType; } public Integer getNumberOfPreviousEnrollments() { return numberOfPreviousEnrollments; } public void setNumberOfPreviousEnrollments(Integer numberOfPreviousEnrollments) { this.numberOfPreviousEnrollments = numberOfPreviousEnrollments; } public Integer getNumberOfPreviousCandidacies() { return numberOfPreviousCandidacies; } public void setNumberOfPreviousCandidacies(Integer numberOfPreviousCandidacies) { this.numberOfPreviousCandidacies = numberOfPreviousCandidacies; } public Integer getNumberOfPreviousRegistrations() { return numberOfPreviousRegistrations; } public void setNumberOfPreviousRegistrations(Integer numberOfPreviousRegistrations) { this.numberOfPreviousRegistrations = numberOfPreviousRegistrations; } public String getRegime() { return regime; } public void setRegime(String regime) { this.regime = regime; } public Boolean getPartialTime() { return isPartialTime; } public void setPartialTime(Boolean isPartialTime) { this.isPartialTime = isPartialTime; } public Boolean getFrequentOtherDegrees() { return frequentOtherDegrees; } public void setFrequentOtherDegrees(Boolean frequentOtherDegrees) { this.frequentOtherDegrees = frequentOtherDegrees; } public String getRegistrationAgreement() { return getResourceBundleValue("RegistrationAgreement." + registrationAgreement.name()); } public void setRegistrationAgreement(RegistrationAgreement registrationAgreement) { this.registrationAgreement = registrationAgreement; } public String getMaritalStatus() { return getResourceBundleValue(maritalStatus.name()); } public void setMaritalStatus(MaritalStatus maritalStatus) { this.maritalStatus = maritalStatus; } public Boolean getDislocated() { return isDislocated; } public void setDislocated(Boolean isDislocated) { this.isDislocated = isDislocated; } public String getCountryOfResidence() { return countryOfResidence; } public void setCountryOfResidence(String countryOfResidence) { this.countryOfResidence = countryOfResidence; } public String getDistrictOfResidence() { return districtOfResidence; } public void setDistrictOfResidence(String districtOfResidence) { this.districtOfResidence = districtOfResidence; } public String getDistrictSubdivisionOfResidence() { return districtSubdivisionOfResidence; } public void setDistrictSubdivisionOfResidence(String districtSubdivisionOfResidence) { this.districtSubdivisionOfResidence = districtSubdivisionOfResidence; } public String getFatherLiteraryHabilitation() { return fatherLiteraryHabilitation != null ? fatherLiteraryHabilitation.getLocalizedName() : null; } public void setFatherLiteraryHabilitation(LiteraryHabilitationType fatherLiteraryHabilitation) { this.fatherLiteraryHabilitation = fatherLiteraryHabilitation; } public String getMotherLiteraryHabilitation() { return motherLiteraryHabilitation != null ? motherLiteraryHabilitation.getLocalizedName() : null; } public void setMotherLiteraryHabilitation(LiteraryHabilitationType motherLiteraryHabilitation) { this.motherLiteraryHabilitation = motherLiteraryHabilitation; } public String getStudentProfessionSector() { return studentProfessionSector != null ? studentProfessionSector.getLocalizedName() : null; } public void setStudentProfessionSector(ProfessionSectorType studentProfessionSector) { this.studentProfessionSector = studentProfessionSector; } public String getFatherProfessionSector() { return fatherProfessionSector != null ? fatherProfessionSector.getLocalizedName() : null; } public void setFatherProfessionSector(ProfessionSectorType fatherProfessionSector) { this.fatherProfessionSector = fatherProfessionSector; } public String getMotherProfessionSector() { return motherProfessionSector != null ? motherProfessionSector.getLocalizedName() : null; } public void setMotherProfessionSector(ProfessionSectorType motherProfessionSector) { this.motherProfessionSector = motherProfessionSector; } public String getStudentProfessionCondition() { return studentProfessionCondition != null ? studentProfessionCondition.getLocalizedName() : null; } public void setStudentProfessionCondition(ProfessionConditionType studentProfessionCondition) { this.studentProfessionCondition = studentProfessionCondition; } public Boolean getDiligentStudent() { return isDiligentStudent; } public void setDiligentStudent(Boolean isDiligentStudent) { this.isDiligentStudent = isDiligentStudent; } public String getGrantOwnerType() { return grantOwnerType != null ? getResourceBundleValue(grantOwnerType.getQualifiedName()) : null; } public void setGrantOwnerType(GrantOwnerType grantOwnerType) { this.grantOwnerType = grantOwnerType; } public String getFormerLiteraryHabilitations() { return formerLiteraryHabilitations != null ? formerLiteraryHabilitations.getLocalizedName() : null; } public void setFormerLiteraryHabilitations(LiteraryHabilitationType formerLiteraryHabilitations) { this.formerLiteraryHabilitations = formerLiteraryHabilitations; } public String getPrecedentInstitutionName() { return precedentInstitutionName; } public void setPrecedentInstitutionName(String precedentInstitutionName) { this.precedentInstitutionName = precedentInstitutionName; } public String getPrecedentDegreeDesignation() { return precedentDegreeDesignation; } public void setPrecedentDegreeDesignation(String precedentDegreeDesignation) { this.precedentDegreeDesignation = precedentDegreeDesignation; } public String getPrecedentDegreeCountry() { return precedentDegreeCountry; } public void setPrecedentDegreeCountry(String precedentDegreeCountry) { this.precedentDegreeCountry = precedentDegreeCountry; } public Integer getPrecedentDegreeConclusionYear() { return precedentDegreeConclusionYear; } public void setPrecedentDegreeConclusionYear(Integer precedentDegreeConclusionYear) { this.precedentDegreeConclusionYear = precedentDegreeConclusionYear; } public Integer getPrecedentNumberOfFails() { return precedentNumberOfFails; } public void setPrecedentNumberOfFails(Integer precedentNumberOfFails) { this.precedentNumberOfFails = precedentNumberOfFails; } public String getSecondarySchoolType() { return secondarySchoolType != null ? secondarySchoolType.getLocalizedName() : null; } public void setSecondarySchoolType(SecondarySchoolType secondarySchoolType) { this.secondarySchoolType = secondarySchoolType; } private String getResourceBundleValue(String key) { return resourceBundle.getString(key); } }