/** * 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); } }
@Override @Transactional(readOnly = true) public boolean isParent(BaseCalendar calendar) { if (calendar == null) { return false; } return !baseCalendarDAO.findByParent(calendar).isEmpty(); }
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())); }
@Override @Transactional(readOnly = true) public List<BaseCalendar> getBaseCalendars() { List<BaseCalendar> baseCalendars = baseCalendarDAO.getBaseCalendars(); for (BaseCalendar each : baseCalendars) { forceLoad(each); } return baseCalendars; }
@Override @Transactional public void confirmRemove(BaseCalendar calendar) { try { baseCalendarDAO.remove(calendar.getId()); } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } }
@Transactional(readOnly = true) private BaseCalendar getFromDB(Long id) { try { BaseCalendar result = baseCalendarDAO.find(id); return result; } catch (InstanceNotFoundException e) { throw new RuntimeException(e); } }
@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")); } }
@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); } }
@Override @Transactional(readOnly = true) public void checkIsReferencedByOtherEntities(BaseCalendar calendar) throws ValidationException { baseCalendarDAO.checkIsReferencedByOtherEntities(calendar); }
@Transactional(rollbackFor = ValidationException.class) private void confirmSave(BaseCalendar calendar) throws ValidationException { checkInvalidValuesCalendar(calendar); baseCalendarDAO.save(calendar); }