Example #1
0
  /*
   * If there is a voting period ocurring, it's not possible to add a new
   * election
   */
  private static void checkPreviousDelegateElectionExistence(
      Degree degree, CurricularYear curricularYear, ExecutionYear executionYear)
      throws DomainException {

    final DelegateElection previousElection =
        degree.getYearDelegateElectionWithLastCandidacyPeriod(executionYear, curricularYear);
    if (previousElection != null
        && previousElection.hasLastVotingPeriod()
        && previousElection.getLastVotingPeriod().isCurrentPeriod()) {
      throw new DomainException(
          "error.elections.newElection.currentVotingPeriodExists",
          new String[] {
            degree.getSigla(),
            curricularYear.getYear().toString(),
            previousElection.getLastVotingPeriod().getPeriod()
          });
    }

    if (previousElection != null
        && previousElection.getVotingPeriod() != null
        && previousElection.hasLastVotingPeriod()
        && !previousElection.getLastVotingPeriod().isPastPeriod()) {
      // future voting period (must be deleted)
      previousElection.getLastVotingPeriod().delete();
    }
  }
Example #2
0
 private static boolean hasDelegateElection(
     YearDelegateElection election, StudentCurricularPlan scp) {
   for (DelegateElection delegateElection :
       scp.getRegistration().getStudent().getDelegateElections()) {
     if (delegateElection instanceof YearDelegateElection) {
       if (delegateElection.getDegree().equals(election.getDegree())
           && delegateElection.getExecutionYear().equals(election.getExecutionYear())
           && (delegateElection.hasLastVotingPeriod()
               && !delegateElection.getLastVotingPeriod().isPastPeriod())) {
         return true;
       }
     }
   }
   return false;
 }
Example #3
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()
            });
      }
    }
  }