@Override public void setCandidacyPeriod(DelegateElectionCandidacyPeriod candidacyPeriod) { if (candidacyPeriod != null) { validatePeriodGivenExecutionYear(getExecutionYear(), candidacyPeriod); if (hasLastVotingPeriod()) { if (candidacyPeriod.endsBefore(getLastVotingPeriod())) { throw new DomainException( "error.elections.edit.colidesWithVotingPeriod", new String[] { getDegree().getSigla(), getCurricularYear().getYear().toString(), candidacyPeriod.getPeriod(), getLastVotingPeriod().getPeriod() }); } } } super.setCandidacyPeriod(candidacyPeriod); }
/* * Checks if the new election candidacy period colides with another election * candidacy period, previously added to this degree and curricular year */ private static void checkNewElectionCandidacyPeriod( Degree degree, ExecutionYear executionYear, CurricularYear curricularYear, DelegateElectionCandidacyPeriod candidacyPeriod) throws DomainException { for (DelegateElection election : degree.getYearDelegateElectionsGivenExecutionYearAndCurricularYear( executionYear, curricularYear)) { if (!election.getCandidacyPeriod().endsBefore(candidacyPeriod)) { throw new DomainException( "error.elections.newElection.invalidPeriod", new String[] { degree.getSigla(), curricularYear.getYear().toString(), candidacyPeriod.getPeriod(), election.getCandidacyPeriod().getPeriod() }); } } }