Пример #1
0
  @Override
  public void deleteVotingPeriod(
      DelegateElectionVotingPeriod votingPeriod, boolean removeElection) {

    if (!votingPeriod.isPastPeriod() && !votingPeriod.isCurrentPeriod()) {
      super.deleteVotingPeriod(votingPeriod);
      if (removeElection) {
        this.deleteCandidacyPeriod();
      }
    } else {
      throw new DomainException(
          "error.yearDelegateElections.delete.pastPeriod",
          new String[] {
            getDegree().getSigla(),
            getCurricularYear().getYear().toString(),
            getVotingPeriod(votingPeriod.getStartDate(), votingPeriod.getEndDate()).getPeriod()
          });
    }
  }
Пример #2
0
  @Override
  public void editCandidacyPeriod(final YearMonthDay startDate, final YearMonthDay endDate) {
    final DelegateElectionCandidacyPeriod candidacyPeriod = getCandidacyPeriod();
    final DelegateElectionVotingPeriod votingPeriod = getVotingPeriod(startDate, endDate);

    if (candidacyPeriod.isPastPeriod()
        && votingPeriod != null
        && votingPeriod.getStartDate().isBefore(new YearMonthDay())) {
      throw new DomainException(
          "error.yearDelegateElections.edit.pastPeriod",
          new String[] {
            getDegree().getSigla(),
            getCurricularYear().getYear().toString(),
            getCandidacyPeriod().getPeriod()
          });
    } else {
      try {
        candidacyPeriod.delete();
        setCandidacyPeriod(new DelegateElectionCandidacyPeriod(startDate, endDate));
      } catch (DomainException ex) {
        throw new DomainException(ex.getMessage(), ex.getArgs());
      }
    }
  }