Пример #1
0
    @Override
    @Transactional(readOnly = true)
    public void initCreate() {
        editing = false;

        boolean codeGenerated = (configurationDAO.getConfiguration() != null) ? configurationDAO
                .getConfiguration().getGenerateCodeForBaseCalendars()
                : false;

        this.baseCalendar = BaseCalendar.createBasicCalendar("");

        if (codeGenerated) {
            setDefaultCode();
        }
        baseCalendar.setCodeAutogenerated(codeGenerated);
    }
Пример #2
0
    /**
     * 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;
    }