예제 #1
0
    /**
     * 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"));
     }
 }
예제 #8
0
    /**
     * 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);
 }