/** * Delete news by id * * @param idNews * @return true when the operation was successful, otherwise false * @throws ServiceException */ @Transactional(rollbackFor = ServiceException.class) @Override public boolean deleteNews(int idNews) throws ServiceException { boolean relationDeletedIsSuccessA = newsService.deleteRelationForAuthorAndNewsByNews(idNews); boolean relationDeletedIsSuccessT = newsService.deleteRelationForTagAndNewsByNews(idNews); boolean deletedNewsIsSuccess = newsService.deleteNews(idNews); return deletedNewsIsSuccess && relationDeletedIsSuccessA && relationDeletedIsSuccessT; }
/** * change tag in news * * @param idNews * @param tags * @return true when the operation was successful, otherwise false * @throws ServiceException */ @Transactional(rollbackFor = ServiceException.class) @Override public boolean editRelationsForTagAndNews(int idNews, List<Integer> tags) throws ServiceException { newsService.deleteRelationForTagAndNewsByNews(idNews); if (tags != null) { for (Integer tag : tags) { newsService.addRelationForTagAndNews(idNews, tag); } } return true; }