PhdProgramProcessState mostRecentState = process.getMostRecentState();
switch (type) {
case CANDIDACY:
if (process.getCandidacyProcess().getCandidacyDate() == null) {
throw new PhdDomainOperationException("error.phd.PhdProgramProcessState.candidacyDate.required");
}
stateDate = process.getCandidacyProcess().getCandidacyDate().toDateTimeAtStartOfDay();
break;
case WORK_DEVELOPMENT:
if (process.getMostRecentStateByType(PhdIndividualProgramProcessState.WORK_DEVELOPMENT) != null) {
stateDate = mostRecentState.getStateDate().plusMinutes(1);
break;
}
if (process.getWhenStartedStudies() == null) {
throw new PhdDomainOperationException("error.phd.PhdProgramProcessState.whenStartedStudies.required");
}
stateDate = process.getWhenStartedStudies().toDateTimeAtStartOfDay();
break;
case THESIS_DISCUSSION:
if (process.getMostRecentStateByType(PhdIndividualProgramProcessState.THESIS_DISCUSSION) != null) {
stateDate = mostRecentState.getStateDate().plusMinutes(1);
break;
}
if (process.getThesisProcess().getWhenThesisDiscussionRequired() == null) {
throw new PhdDomainOperationException("error.phd.PhdProgramProcessState.whenThesisDiscussionRequired.required");
}
stateDate = process.getThesisProcess().getWhenThesisDiscussionRequired().toDateTimeAtStartOfDay();
break;
case TRANSFERRED:
stateDate = mostRecentState.getStateDate().plusMinutes(1);
break;
case CONCLUDED:
if (process.getLastConclusionProcess() == null) {
throw new PhdDomainOperationException("error.phd.PhdProgramProcessState.conclusionProcess.required");
}
stateDate = process.getLastConclusionProcess().getConclusionDate().toDateTimeAtStartOfDay();
break;
case CANCELLED: