Example #1
0
  @Override
  public void addVotingPeriod(DelegateElectionVotingPeriod votingPeriod) {
    if (votingPeriod != null) {
      validatePeriodGivenExecutionYear(getExecutionYear(), votingPeriod);

      if (!hasCandidacyPeriod()) {
        throw new DomainException(
            "error.elections.createVotingPeriod.mustCreateCandidacyPeriod",
            new String[] {getDegree().getSigla(), getCurricularYear().getYear().toString()});
      }

      if (!getCandidacyPeriod().endsBefore(votingPeriod)) {
        throw new DomainException(
            "error.elections.edit.colidesWithCandidacyPeriod",
            new String[] {
              getDegree().getSigla(),
              getCurricularYear().getYear().toString(),
              getCandidacyPeriod().getPeriod(),
              votingPeriod.getPeriod()
            });
      }
      if (!getLastElectionPeriod().endsBefore(votingPeriod)) {
        throw new DomainException(
            "error.elections.edit.colidesWithPreviousVotingPeriod",
            new String[] {
              getDegree().getSigla(),
              getCurricularYear().getYear().toString(),
              getCandidacyPeriod().getPeriod(),
              votingPeriod.getPeriod()
            });
      }
    }
    super.addVotingPeriod(votingPeriod);
  }
Example #2
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()
          });
    }
  }
Example #3
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);
  }
Example #4
0
 @Override
 public void delete() {
   removeCurricularYear();
   super.delete();
 }