package net.sourceforge.fenixedu.dataTransferObject.serviceRequests; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import net.sourceforge.fenixedu.domain.DomainReference; import net.sourceforge.fenixedu.domain.Enrolment; import net.sourceforge.fenixedu.domain.Exam; import net.sourceforge.fenixedu.domain.ExecutionSemester; import net.sourceforge.fenixedu.domain.degreeStructure.CycleType; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.organizationalStructure.Unit; import net.sourceforge.fenixedu.domain.organizationalStructure.UnitName; import net.sourceforge.fenixedu.domain.serviceRequests.documentRequests.DocumentPurposeType; import net.sourceforge.fenixedu.domain.serviceRequests.documentRequests.DocumentRequestType; import net.sourceforge.fenixedu.domain.student.MobilityProgram; import net.sourceforge.fenixedu.domain.student.Registration; import net.sourceforge.fenixedu.domain.studentCurriculum.CurriculumGroup; import net.sourceforge.fenixedu.util.Money; import org.joda.time.LocalDate; import org.joda.time.YearMonthDay; import com.linkare.commons.metainfo.Linkare; public class DocumentRequestCreateBean extends RegistrationAcademicServiceRequestCreateBean { private DocumentRequestType chosenDocumentRequestType; private DocumentPurposeType chosenDocumentPurposeType; private String otherPurpose; private DomainReference branchCurriculumGroup; private String branch; private Boolean average = Boolean.FALSE; private Boolean detailed = Boolean.FALSE; private Boolean technicalEngineer = Boolean.FALSE; private Boolean internshipAbolished = Boolean.FALSE; private Boolean internshipApproved = Boolean.FALSE; private Boolean studyPlan = Boolean.FALSE; private YearMonthDay exceptionalConclusionDate; private Boolean toBeCreated; private String schema; private Collection warningsToReport; private Integer year; private CycleType requestedCycle; private MobilityProgram mobilityProgram; private boolean ignoreExternalEntries = false; private boolean toUseAll = false; private List> enrolments; private DomainReference executionSemester; private List> exams; private Integer numberOfCourseLoads; private DomainReference institution; private Integer numberOfPrograms; private Money pastPaymentAmount; private LocalDate pastRequestDate; private LocalDate pastPaymentDate; private LocalDate pastEmissionDate; private LocalDate pastDispatchDate; public DocumentRequestCreateBean(Registration registration) { super(registration); this.enrolments = new ArrayList>(); this.exams = new ArrayList>(); pastRequestDate = new LocalDate(); } public DocumentRequestType getChosenDocumentRequestType() { return chosenDocumentRequestType; } public void setChosenDocumentRequestType(DocumentRequestType chosenDocumentRequestType) { this.chosenDocumentRequestType = chosenDocumentRequestType; } public DocumentPurposeType getChosenDocumentPurposeType() { return chosenDocumentPurposeType; } public void setChosenDocumentPurposeType(DocumentPurposeType chosenDocumentPurposeType) { this.chosenDocumentPurposeType = chosenDocumentPurposeType; } public String getOtherPurpose() { return otherPurpose; } public void setOtherPurpose(String otherPurpose) { this.otherPurpose = otherPurpose; } public Boolean getAverage() { return average; } public void setAverage(Boolean average) { this.average = average; } public Boolean getDetailed() { return detailed; } public void setDetailed(Boolean detailed) { this.detailed = detailed; } public Boolean getTechnicalEngineer() { return technicalEngineer; } public void setTechnicalEngineer(Boolean technicalEngineer) { this.technicalEngineer = technicalEngineer; } public Boolean getInternshipAbolished() { return internshipAbolished; } public void setInternshipAbolished(Boolean internshipAbolished) { this.internshipAbolished = internshipAbolished; } public Boolean getInternshipApproved() { return internshipApproved; } public void setInternshipApproved(Boolean internshipApproved) { this.internshipApproved = internshipApproved; } public Boolean getStudyPlan() { return studyPlan; } public void setStudyPlan(Boolean studyPlan) { this.studyPlan = studyPlan; } public YearMonthDay getExceptionalConclusionDate() { return exceptionalConclusionDate; } public void setExceptionalConclusionDate(YearMonthDay exceptionalConclusionDate) { this.exceptionalConclusionDate = exceptionalConclusionDate; } public Integer getYear() { return this.year; } public void setYear(Integer year) { this.year = year; } public Boolean getToBeCreated() { return toBeCreated; } public void setToBeCreated(Boolean toBeCreated) { this.toBeCreated = toBeCreated; } /** * This method is only needed to report warnings to the user. While we don't * have enough info in our database to decide on what cases the document * request should abort (acording to the Administrative Office rules shown * in the use cases), warnings must be shown to the user. * * @return */ public Collection getWarningsToReport() { if (warningsToReport == null) { warningsToReport = new HashSet(); if (chosenDocumentRequestType == DocumentRequestType.APPROVEMENT_CERTIFICATE) { if (chosenDocumentPurposeType == DocumentPurposeType.PROFESSIONAL) { warningsToReport.add("aprovementType.professionalPurpose.thirdGrade"); } warningsToReport.add("aprovementType.finished.degree"); } if (chosenDocumentRequestType == DocumentRequestType.DEGREE_FINALIZATION_CERTIFICATE) { warningsToReport.add("degreeFinalizationType.withoutDegreeCertificate"); } } return warningsToReport; } public boolean hasWarningsToReport() { if (warningsToReport == null) { getWarningsToReport(); } return !warningsToReport.isEmpty(); } public void setPurpose(DocumentPurposeType chosenDocumentPurposeType, String otherPurpose) { otherPurpose = otherPurpose.trim(); if (chosenDocumentPurposeType != null && chosenDocumentPurposeType.equals(DocumentPurposeType.OTHER) && (otherPurpose == null || otherPurpose.length() == 0)) { throw new DomainException("DocumentRequestCreateBean.error.other.purpose.required"); } this.chosenDocumentPurposeType = chosenDocumentPurposeType; this.otherPurpose = otherPurpose; } public String getSchema() { return schema; } public void setSchema(String schema) { this.schema = schema; } public CycleType getRequestedCycle() { return requestedCycle; } public void setRequestedCycle(final CycleType cycleType) { this.requestedCycle = cycleType; } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") public final boolean getHasAdditionalInformation() { return getChosenDocumentRequestType() == null ? false : getChosenDocumentRequestType().getHasAdditionalInformation(); } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") public final boolean getHasCycleTypeDependency() { return getChosenDocumentRequestType().getHasCycleTypeDependency(getRegistration().getDegreeType()); } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") public final boolean getHasMobilityProgramDependency() { return chosenDocumentRequestType == DocumentRequestType.APPROVEMENT_CERTIFICATE || chosenDocumentRequestType == DocumentRequestType.DEGREE_FINALIZATION_CERTIFICATE; } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") public final MobilityProgram getMobilityProgram() { return mobilityProgram; } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") public final void setMobilityProgram(final MobilityProgram mobilityProgram) { this.mobilityProgram = mobilityProgram; } public boolean isIgnoreExternalEntries() { return ignoreExternalEntries; } public void setIgnoreExternalEntries(final boolean ignoreExternalEntries) { this.ignoreExternalEntries = ignoreExternalEntries; } public boolean isToUseAll() { return toUseAll; } public void setToUseAll(boolean toUseAll) { this.toUseAll = toUseAll; } public List getEnrolments() { final List result = new ArrayList(); for (final DomainReference each : this.enrolments) { result.add(each.getObject()); } return result; } public void setEnrolments(List enrolments) { final List> enrolmentsToSet = new ArrayList>(); for (final Enrolment enrolment : enrolments) { enrolmentsToSet.add(new DomainReference(enrolment)); } this.enrolments = enrolmentsToSet; } public List getExams() { final List result = new ArrayList(); for (final DomainReference each : this.exams) { result.add(each.getObject()); } return result; } public void setExams(List exams) { final List> result = new ArrayList>(); for (final Exam each : exams) { result.add(new DomainReference(each)); } this.exams = result; } public ExecutionSemester getExecutionPeriod() { return (this.executionSemester != null) ? this.executionSemester.getObject() : null; } public void setExecutionPeriod(ExecutionSemester executionSemester) { this.executionSemester = (executionSemester != null) ? new DomainReference(executionSemester) : null; } public Integer getNumberOfCourseLoads() { return numberOfCourseLoads; } public void setNumberOfCourseLoads(Integer numberOfCourseLoads) { this.numberOfCourseLoads = numberOfCourseLoads; } public UnitName getInstitutionName() { return (this.institution != null) ? this.institution.getObject().getUnitName() : null; } public void setInstitutionName(final UnitName institutionName) { this.institution = (institutionName != null) ? new DomainReference(institutionName.getUnit()) : null; } public Unit getInstitution() { return (this.institution != null) ? this.institution.getObject() : null; } public Integer getNumberOfPrograms() { return numberOfPrograms; } public void setNumberOfPrograms(Integer numberOfPrograms) { this.numberOfPrograms = numberOfPrograms; } public void setBranch(String branch) { this.branch = branch; } public String getBranch() { return branch; } public CurriculumGroup getBranchCurriculumGroup() { return branchCurriculumGroup != null ? branchCurriculumGroup.getObject() : null; } public void setBranchCurriculumGroup(CurriculumGroup branchCurriculumGroup) { this.branchCurriculumGroup = (branchCurriculumGroup != null ? new DomainReference(branchCurriculumGroup) : null); } public String getBranchName() { if (getBranchCurriculumGroup() == null) { return branch; } return getBranchCurriculumGroup().getName().getContent(); } public boolean getIsDiploma() { return (chosenDocumentRequestType.isDiploma() || chosenDocumentRequestType.isPastDiploma()); } public void setPastPaymentAmount(Money paymentAmount) { this.pastPaymentAmount = paymentAmount; } public Money getPastPaymentAmount() { return pastPaymentAmount; } public void setPastPaymentDate(LocalDate paymentDate) { this.pastPaymentDate = paymentDate; } public LocalDate getPastPaymentDate() { return pastPaymentDate; } public LocalDate getPastEmissionDate() { return pastEmissionDate; } public void setPastEmissionDate(LocalDate emissionDate) { this.pastEmissionDate = emissionDate; } public LocalDate getPastDispatchDate() { return pastDispatchDate; } public void setPastDispatchDate(LocalDate dispatchDate) { this.pastDispatchDate = dispatchDate; } public LocalDate getPastRequestDate() { return pastRequestDate; } public void setPastRequestDate(LocalDate pastRequestDate) { this.pastRequestDate = pastRequestDate; } }