/**
     * Saves a list of {@link BaseCalendar} that has all the calendar data that we want to store in the database.
     *
     * @param baseCalendars
     */
    @Override
    @Transactional
    public void storeBaseCalendars(List<BaseCalendar> baseCalendars) {
        for (BaseCalendar baseCalendar : baseCalendars) {
            baseCalendarDAO.save(baseCalendar);
        }

    }
示例#2
0
 @Override
 @Transactional(readOnly = true)
 public boolean isParent(BaseCalendar calendar) {
     if (calendar == null) {
         return false;
     }
     return !baseCalendarDAO.findByParent(calendar).isEmpty();
 }
示例#3
0
 private void reattachAndLoadCalendar(TaskElement taskElement) {
   BaseCalendar calendar = taskElement.getCalendar();
   if (calendar == null) {
     return;
   }
   baseCalendarDAO.reattach(calendar);
   forceLoadCalendar(calendar);
   calendar.getCapacityOn(PartialDay.wholeDay(taskElement.getIntraDayStartDate().getDate()));
 }
示例#4
0
 @Override
 @Transactional(readOnly = true)
 public List<BaseCalendar> getBaseCalendars() {
     List<BaseCalendar> baseCalendars = baseCalendarDAO.getBaseCalendars();
     for (BaseCalendar each : baseCalendars) {
         forceLoad(each);
     }
     return baseCalendars;
 }
示例#5
0
 @Override
 @Transactional
 public void confirmRemove(BaseCalendar calendar) {
     try {
         baseCalendarDAO.remove(calendar.getId());
     } catch (InstanceNotFoundException e) {
         throw new RuntimeException(e);
     }
 }
示例#6
0
 @Transactional(readOnly = true)
 private BaseCalendar getFromDB(Long id) {
     try {
         BaseCalendar result = baseCalendarDAO.find(id);
         return result;
     } catch (InstanceNotFoundException e) {
         throw new RuntimeException(e);
     }
 }
示例#7
0
 @Override
 public void checkInvalidValuesCalendar(BaseCalendar entity)
         throws ValidationException {
     if (baseCalendarDAO.thereIsOtherWithSameName(entity)) {
         InvalidValue[] invalidValues2 = { new InvalidValue(_(
                 "{0} already exists", entity.getName()),
                 BaseCalendar.class, "name", entity.getName(), entity) };
         throw new ValidationException(invalidValues2,
                 _("Could not save the new calendar"));
     }
 }
    /**
     * Validate if a calendar name is not in use.
     * If it is throws an exception.
     * It not return the same name.
     *
     * @param name
     *            String with the name to validate.
     * @return String with the valid name.
     * @throws ValidationException
     */
    @Transactional
    private String validateName(String name) {

        List<BaseCalendar> calendars = baseCalendarDAO.findByName(name);

        if (calendars.isEmpty()) {
            return name;
        } else {
            throw new ValidationException(_("Calendar name already in use"));
        }

    }
示例#9
0
    @Override
    @Transactional(readOnly = true)
    public void setParent(BaseCalendar parent) {
        try {
            parent = baseCalendarDAO.find(parent.getId());
        } catch (InstanceNotFoundException e) {
            throw new RuntimeException(e);
        }
        forceLoad(parent);

        if (getBaseCalendar() != null) {
            getBaseCalendar().setParent(parent, selectedDate);
        }
    }
示例#10
0
 @Override
 @Transactional(readOnly = true)
 public void checkIsReferencedByOtherEntities(BaseCalendar calendar) throws ValidationException {
     baseCalendarDAO.checkIsReferencedByOtherEntities(calendar);
 }
示例#11
0
 @Transactional(rollbackFor = ValidationException.class)
 private void confirmSave(BaseCalendar calendar) throws ValidationException {
     checkInvalidValuesCalendar(calendar);
     baseCalendarDAO.save(calendar);
 }