package net.sourceforge.fenixedu.domain.serviceRequests.documentRequests; import net.sourceforge.fenixedu.dataTransferObject.serviceRequests.AcademicServiceRequestBean; import net.sourceforge.fenixedu.domain.StudentCurricularPlan; import net.sourceforge.fenixedu.domain.accounting.EventType; import net.sourceforge.fenixedu.domain.degree.DegreeType; import net.sourceforge.fenixedu.domain.degreeStructure.CycleType; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.student.Registration; /** * * @author rjmvo * */ public class ISCTEFinalizationCertificateRequest extends ISCTEFinalizationCertificateRequest_Base { public ISCTEFinalizationCertificateRequest() { super(); } public ISCTEFinalizationCertificateRequest(Registration registration, CycleType requestedCycle) { this(); init(registration, requestedCycle); } private void init(Registration registration, CycleType requestedCycle) { init(registration, null, Boolean.FALSE, Boolean.TRUE); checkForDiplomaRequest(registration, requestedCycle); setRequestedCycle(requestedCycle); } private void checkForDiplomaRequest(Registration registration, CycleType requestedCycle) { if (!registration.hasPayedDiplomaRequest(requestedCycle)) { // throw new // DomainException("DegreeFinalizationCertificateRequest.registration.withoutDiplomaRequest"); } } @Override protected void internalChangeState(AcademicServiceRequestBean academicServiceRequestBean) { if (academicServiceRequestBean.isToProcess()) { if (!getRegistration().isRegistrationConclusionProcessed(getRequestedCycle())) { throw new DomainException("DegreeFinalizationCertificateRequest.registration.not.submited.to.conclusion.process"); } } super.internalChangeState(academicServiceRequestBean); } @Override public Integer getNumberOfUnits() { return null; } @Override public EventType getEventType() { return EventType.DEGREE_FINALIZATION_CERTIFICATE_REQUEST; } @Override public String getDocumentTemplateKey() { return getClass().getName(); } @Override public DocumentRequestType getDocumentRequestType() { return DocumentRequestType.DEGREE_FINALIZATION_CERTIFICATE; } @Override public String getDescription() { DegreeType degreeType = getDegreeType(); return getDescription(AcademicServiceRequestType.DOCUMENT, getDocumentRequestType().getQualifiedName() + "." + degreeType.name() + ((degreeType.isComposite() && getRequestedCycle() != null) ? "." + getRequestedCycle() : "")); } @Override public StudentCurricularPlan getStudentCurricularPlan() { return getRegistration().getLastStudentCurricularPlan(); } }