package net.sourceforge.fenixedu.domain.studentCurriculum; import java.math.BigDecimal; import net.sourceforge.fenixedu.domain.IEnrolment; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import net.sourceforge.fenixedu.domain.student.curriculum.ICurriculumEntry; /** * * @author rjmvo * */ public class ISCTEDismissalWrapper extends ISCTEDismissalWrapper_Base implements ISCTECurriculumEntryWrapper { public ISCTEDismissalWrapper() { super(); } public ISCTEDismissalWrapper(Certification certification, Dismissal dismissal) { if (certification == null) { throw new DomainException("error.EnrolmentWrapper.certification.cannot.be.null"); } if (dismissal == null) { throw new DomainException("error.EnrolmentWrapper.dismissal.cannot.be.null"); } super.setCertification(certification); super.setEnrolment(dismissal); } public ISCTEDismissalWrapper(Credits credits, Dismissal dismissal, Double creditsWeight, Double creditsEcts) { this(); init(credits, dismissal, creditsWeight, creditsEcts); } protected void init(Credits credits, Dismissal dismissal, Double creditsWeight, Double creditsEcts) { init(credits); if (dismissal == null) { throw new DomainException("error.EnrolmentWrapper.dismissal.cannot.be.null"); } super.setEnrolment(dismissal); if (creditsEcts == null) { throw new DomainException("error.EnrolmentWrapper.givenCredits.cannot.be.null"); } setCreditsWeight(creditsWeight); setCreditsEcts(creditsEcts); } public final void setEnrolment() { throw new RuntimeException("error.EnrolmentWrapper.cannot.modify.dismissal"); } public final IEnrolment getIEnrolment() { return null; } public boolean isInternal() { return true; } @Override public ICurriculumEntry getCurriculumEntry() { return getEnrolment(); } public BigDecimal getWeight() { return getCreditsWeight() != null ? new BigDecimal(getCreditsWeight()) : getCurriculumEntry().getWeigthForCurriculum(); } @Override public void delete() { removeCertification(); removeEnrolment(); super.delete(); } public void setWeight(BigDecimal weight) { super.setCreditsWeight(weight.doubleValue()); } }