package net.sourceforge.fenixedu.domain.candidacyProcess.over23; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import net.sourceforge.fenixedu.domain.Degree; import net.sourceforge.fenixedu.domain.DomainReference; import net.sourceforge.fenixedu.domain.candidacyProcess.CandidacyProcessDocumentUploadBean; import net.sourceforge.fenixedu.domain.candidacyProcess.FormationBean; import net.sourceforge.fenixedu.domain.candidacyProcess.IndividualCandidacyDocumentFileType; import net.sourceforge.fenixedu.domain.candidacyProcess.IndividualCandidacyProcessBean; import org.joda.time.LocalDate; public class Over23IndividualCandidacyProcessBean extends IndividualCandidacyProcessBean { private DomainReference degreeToAdd; private List> selectedDegrees; private String disabilities; private String education; private String languages; private String languagesRead; private String languagesWrite; private String languagesSpeak; private List habilitationCertificateList; private List reportOrWorkDocumentList; private CandidacyProcessDocumentUploadBean handicapProofDocument; private CandidacyProcessDocumentUploadBean curriculumVitaeDocument; public Over23IndividualCandidacyProcessBean() { setCandidacyDate(new LocalDate()); setSelectedDegrees(Collections.EMPTY_LIST); setFormationConcludedBeanList(new ArrayList()); setFormationNonConcludedBeanList(new ArrayList()); initializeDocumentUploadBeans(); this.honorAgreement = false; } public Over23IndividualCandidacyProcessBean(Over23IndividualCandidacyProcess process) { setIndividualCandidacyProcess(process); setCandidacyDate(process.getCandidacyDate()); setSelectedDegrees(Collections.EMPTY_LIST); addDegrees(process.getSelectedDegreesSortedByOrder()); setDisabilities(process.getDisabilities()); setEducation(process.getEducation()); setLanguages(process.getLanguages()); initializeFormation(process.getCandidacy().getFormations()); setLanguagesRead(process.getLanguagesRead()); setLanguagesWrite(process.getLanguagesWrite()); setLanguagesSpeak(process.getLanguagesSpeak()); setProcessChecked(process.getProcessChecked()); } @Override public Over23CandidacyProcess getCandidacyProcess() { return (Over23CandidacyProcess) super.getCandidacyProcess(); } public Degree getDegreeToAdd() { return (this.degreeToAdd != null) ? this.degreeToAdd.getObject() : null; } public void setDegreeToAdd(Degree degreeToAdd) { this.degreeToAdd = (degreeToAdd != null) ? new DomainReference(degreeToAdd) : null; } public boolean hasDegreeToAdd() { return getDegreeToAdd() != null; } public void removeDegreeToAdd() { degreeToAdd = null; } public List getSelectedDegrees() { final List result = new ArrayList(); for (final DomainReference degree : selectedDegrees) { result.add(degree.getObject()); } return result; } public void setSelectedDegrees(final List degrees) { selectedDegrees = new ArrayList>(); for (final Degree degree : degrees) { selectedDegrees.add(new DomainReference(degree)); } } public void addDegree(final Degree degree) { selectedDegrees.add(new DomainReference(degree)); } public void addDegrees(final Collection degrees) { for (final Degree degree : degrees) { addDegree(degree); } } public void removeDegree(final Degree degree) { final Iterator> iter = selectedDegrees.iterator(); while (iter.hasNext()) { if (iter.next().getObject() == degree) { iter.remove(); break; } } } public boolean containsDegree(final Degree value) { for (final Degree degree : getSelectedDegrees()) { if (degree == value) { return true; } } return false; } public void removeSelectedDegrees() { selectedDegrees.clear(); } public String getDisabilities() { return disabilities; } public void setDisabilities(String disabilities) { this.disabilities = disabilities; } public String getEducation() { return education; } public void setEducation(String education) { this.education = education; } public String getLanguages() { return languages; } public void setLanguages(String languages) { this.languages = languages; } public List getHabilitationCertificateList() { return habilitationCertificateList; } public void setHabilitationCertificateList(List habilitationCertificateList) { this.habilitationCertificateList = habilitationCertificateList; } public List getReportOrWorkDocumentList() { return reportOrWorkDocumentList; } public void setReportOrWorkDocumentList(List reportOrWorkDocumentList) { this.reportOrWorkDocumentList = reportOrWorkDocumentList; } public CandidacyProcessDocumentUploadBean getHandicapProofDocument() { return handicapProofDocument; } public void setHandicapProofDocument(CandidacyProcessDocumentUploadBean handicapProofDocument) { this.handicapProofDocument = handicapProofDocument; } public CandidacyProcessDocumentUploadBean getCurriculumVitaeDocument() { return curriculumVitaeDocument; } public void setCurriculumVitaeDocument(CandidacyProcessDocumentUploadBean curriculumVitaeDocument) { this.curriculumVitaeDocument = curriculumVitaeDocument; } public String getLanguagesRead() { return this.languagesRead; } public void setLanguagesRead(String value) { this.languagesRead = value; } public String getLanguagesWrite() { return this.languagesWrite; } public void setLanguagesWrite(String value) { this.languagesWrite = value; } public String getLanguagesSpeak() { return this.languagesSpeak; } public void setLanguagesSpeak(String value) { this.languagesSpeak = value; } public void addHabilitationCertificateDocument() { this.habilitationCertificateList.add(new CandidacyProcessDocumentUploadBean( IndividualCandidacyDocumentFileType.HABILITATION_CERTIFICATE_DOCUMENT)); } public void removeHabilitationCertificateDocument(final int index) { this.habilitationCertificateList.remove(index); } public void addReportOrWorkDocument() { this.reportOrWorkDocumentList.add(new CandidacyProcessDocumentUploadBean( IndividualCandidacyDocumentFileType.REPORT_OR_WORK_DOCUMENT)); } public void removeReportOrWorkDocument(final int index) { this.reportOrWorkDocumentList.remove(index); } @Override protected void initializeDocumentUploadBeans() { setDocumentIdentificationDocument(new CandidacyProcessDocumentUploadBean( IndividualCandidacyDocumentFileType.DOCUMENT_IDENTIFICATION)); setPaymentDocument(new CandidacyProcessDocumentUploadBean(IndividualCandidacyDocumentFileType.PAYMENT_DOCUMENT)); setVatCatCopyDocument(new CandidacyProcessDocumentUploadBean(IndividualCandidacyDocumentFileType.VAT_CARD_DOCUMENT)); this.habilitationCertificateList = new ArrayList(); addHabilitationCertificateDocument(); this.reportOrWorkDocumentList = new ArrayList(); addReportOrWorkDocument(); this.handicapProofDocument = new CandidacyProcessDocumentUploadBean( IndividualCandidacyDocumentFileType.HANDICAP_PROOF_DOCUMENT); this.curriculumVitaeDocument = new CandidacyProcessDocumentUploadBean(IndividualCandidacyDocumentFileType.CV_DOCUMENT); setPhotoDocument(new CandidacyProcessDocumentUploadBean(IndividualCandidacyDocumentFileType.PHOTO)); } }