Ejemplo n.º 1
0
  @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);
  }
Ejemplo n.º 2
0
  /*
   * 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()
            });
      }
    }
  }