@Transactional @Override public boolean addHoliday(Holiday holiday) { try { holiday.setStatus(ConfigConstants.STATUS_FLAG_EFFECTIVE); holiday.setCancelFlag(ConfigConstants.LOGICAL_CANCEL_FLAG_NOT_CANCEL); holiday.setYr(getCurrentYear()); holiday.setCreateBy(accountService.getCurrentUser().getLoginName()); holiday.setCreateDate(new Date()); holiday.setUpdateBy(accountService.getCurrentUser().getLoginName()); holiday.setUpdateDate(new Date()); holidayRepository.save(holiday); return true; } catch (Exception e) { logger.error(e.getLocalizedMessage()); return false; } }
@Transactional @Override public boolean deleteHoliday(Long id) { try { if (holidayRepository.exists(id)) { Holiday holiday = holidayRepository.findOne(id); holiday.setCancelFlag(ConfigConstants.LOGICAL_CANCEL_FLAG_CANCEL); holiday.setUpdateBy(accountService.getCurrentUser().getLoginName()); holiday.setUpdateDate(new Date()); holidayRepository.save(holiday); } } catch (Exception e) { logger.error(e.getLocalizedMessage()); return false; } return true; }
@Transactional @Override public boolean updateHoliday(Holiday holiday) { try { Holiday hld = holidayRepository.findOne(holiday.getId()); hld.setName(holiday.getName()); hld.setStartDate(holiday.getStartDate()); hld.setEndDate(holiday.getEndDate()); HolidayType holidayType = holidayTypeRepository.findOne(holiday.getHolidayType().getId()); hld.setHolidayType(holidayType); hld.setUpdateBy(accountService.getCurrentUser().getLoginName()); hld.setUpdateDate(new Date()); holidayRepository.save(hld); return true; } catch (Exception e) { logger.error(e.getLocalizedMessage()); return false; } }