コード例 #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();
    }
  }
コード例 #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;
 }