&& event.isOpen()) {
throw new DomainException("already.has.phd.gratuity.for.that.year");
}
}
PhdIndividualProgramProcess process = getProcess(request);
TreeSet<PhdProgramProcessState> orderdStates =
new TreeSet<PhdProgramProcessState>(new Comparator<PhdProgramProcessState>() {
@Override
public int compare(PhdProgramProcessState o1, PhdProgramProcessState o2) {
return o1.getStateDate().compareTo(o2.getStateDate());
}
});
orderdStates.addAll(process.getStates());
int lastOpenYear = new DateTime().getYear();
int year = renderedObject.getYear();
boolean yearWithinWorkingDevelopmentPeriod = false;
for (PhdProgramProcessState state : process.getStates()) {
if (state.getType().equals(PhdIndividualProgramProcessState.WORK_DEVELOPMENT)) {
if (state.getStateDate().getYear() <= year && year <= lastOpenYear) {
yearWithinWorkingDevelopmentPeriod = true;
break;
}
}
lastOpenYear = state.getStateDate().getYear();
}
if (!yearWithinWorkingDevelopmentPeriod) {
throw new FenixActionException("error.chosen.year.not.within.working.period");
}
PhdGratuityEvent.create(getProcess(request), year, process.getWhenFormalizedRegistration().toDateTimeAtMidnight());
return prepare(mapping, actionForm, request, response);
} catch (DomainException e) {
addErrorMessage(request, e.getMessage(), e.getArgs());