@Transactional public void generateCalendarCodes() { if (getBaseCalendar().isCodeAutogenerated()) { baseCalendar .generateCalendarExceptionCodes(getNumberOfDigitsCode()); } }
/** * Makes a {@link BaseCalendar} from a {@link CalendarDTO}. * * @param calendarDTO * CalendarDTO to extract data from. * @return BaseCalendar with the calendar that we want. * @throws InstanceNotFoundException, ValidationException */ private BaseCalendar toBaseCalendar(CalendarDTO calendarDTO, BaseCalendar parent) throws InstanceNotFoundException { String code = getCode(EntityNameEnum.CALENDAR); String name = validateName(calendarDTO.name); Set<CalendarException> calendarExceptions = getCalendarExceptions(calendarDTO.calendarExceptions); List<CalendarData> calendarData = getCalendarData(calendarDTO.calendarWeeks, parent); BaseCalendar baseCalendar = BaseCalendar.createUnvalidated(code, name, parent, calendarExceptions, calendarData); baseCalendar.setCodeAutogenerated(true); baseCalendar.setName(name); if (parent != null) { baseCalendar.setParent(parent); } baseCalendar.generateCalendarExceptionCodes(entitySequenceDAO.getNumberOfDigitsCode(EntityNameEnum.CALENDAR)); return baseCalendar; }