Пример #1
0
  @Override
  @Transactional
  public void loadRequiredData() {
    if (calendarExceptionTypeDAO.getAll().size() == 0) {
      for (PredefinedCalendarExceptionTypes type : PredefinedCalendarExceptionTypes.values()) {
        CalendarExceptionType calendarExceptionType = type.getCalendarExceptionType();

        calendarExceptionType.setCode(
            entitySequenceDAO.getNextEntityCodeWithoutTransaction(
                EntityNameEnum.CALENDAR_EXCEPTION_TYPE));

        calendarExceptionType.setCodeAutogenerated(true);
        calendarExceptionTypeDAO.save(calendarExceptionType);
      }
    }

    boolean condition =
        calendarExceptionTypeDAO.existsByName(
            PredefinedCalendarExceptionTypes.NOT_WORKING_DAY.getCalendarExceptionType());

    if (!condition) {

      CalendarExceptionType calendarExceptionType =
          PredefinedCalendarExceptionTypes.NOT_WORKING_DAY.getCalendarExceptionType();

      calendarExceptionType.setCode(
          entitySequenceDAO.getNextEntityCodeWithoutTransaction(
              EntityNameEnum.CALENDAR_EXCEPTION_TYPE));

      calendarExceptionType.setCodeAutogenerated(true);
      calendarExceptionTypeDAO.save(calendarExceptionType);
    }

    condition =
        calendarExceptionTypeDAO.existsByName(
            PredefinedCalendarExceptionTypes.WORKING_DAY.getCalendarExceptionType());

    if (!condition) {

      CalendarExceptionType calendarExceptionType =
          PredefinedCalendarExceptionTypes.WORKING_DAY.getCalendarExceptionType();

      calendarExceptionType.setCode(
          entitySequenceDAO.getNextEntityCodeWithoutTransaction(
              EntityNameEnum.CALENDAR_EXCEPTION_TYPE));

      calendarExceptionType.setCodeAutogenerated(true);
      calendarExceptionTypeDAO.save(calendarExceptionType);
    }
  }