/** * Adding the author by name * * @param nameOfAuthor * @return authorID * @throws ServiceException */ @Override public int addAuthorByName(String nameOfAuthor) throws ServiceException { Author author = new Author(nameOfAuthor); author.setStatus("active"); try { return authorDAO.create(author); } catch (DAOException ex) { throw new ServiceException(ex.getMessage()); } }
/** * Add news with author and tags * * @param news * @param author * @param tags * @return newsId * @throws ServiceException */ @Transactional(rollbackFor = ServiceException.class) @Override public int addNews(News news, Author author, List<Integer> tags) throws ServiceException { int idNews = newsService.addNews( news.getShortText(), news.getFullText(), news.getTitle(), news.getCreationDate()); newsService.addRelationForAuthorAndNews(idNews, author.getAuthorId()); if (tags != null) { for (Integer tag : tags) { newsService.addRelationForTagAndNews(idNews, tag); } } return idNews; }