package net.sourceforge.fenixedu.domain; import java.util.SortedSet; import java.util.TreeSet; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import pt.ist.fenixWebFramework.security.accessControl.Checked; public class DegreeCurricularPlanEquivalencePlan extends DegreeCurricularPlanEquivalencePlan_Base { @Checked("DegreeCurricularPlanEquivalencePlanPredicates.checkPermissionsToCreate") public DegreeCurricularPlanEquivalencePlan(final DegreeCurricularPlan degreeCurricularPlan, final DegreeCurricularPlan sourceDegreeCurricularPlan) { super(); init(degreeCurricularPlan, sourceDegreeCurricularPlan); } protected void init(DegreeCurricularPlan degreeCurricularPlan, DegreeCurricularPlan sourceDegreeCurricularPlan) { checkParameters(degreeCurricularPlan, sourceDegreeCurricularPlan); super.setDegreeCurricularPlan(degreeCurricularPlan); super.setSourceDegreeCurricularPlan(sourceDegreeCurricularPlan); } private void checkParameters(DegreeCurricularPlan degreeCurricularPlan, DegreeCurricularPlan sourceDegreeCurricularPlan) { if (degreeCurricularPlan == null) { throw new DomainException("error.DegreeCurricularPlanEquivalencePlan.degreeCurricularPlan.cannot.be.null"); } if (sourceDegreeCurricularPlan == null) { throw new DomainException("error.DegreeCurricularPlanEquivalencePlan.sourceDegreeCurricularPlan.cannot.be.null"); } if (degreeCurricularPlan == sourceDegreeCurricularPlan) { throw new DomainException("error.DegreeCurricularPlanEquivalencePlan.source.and.target.cannot.be.the.same"); } } public SortedSet getOrderedEntries() { final SortedSet entries = new TreeSet(EquivalencePlanEntry.COMPARATOR); entries.addAll(getEntriesSet()); return entries; } @Override public void delete() { removeDegreeCurricularPlan(); removeSourceDegreeCurricularPlan(); super.delete(); } public Degree getSourceDegree() { return getSourceDegreeCurricularPlan().getDegree(); } }