Class NewsServiceImpl

java.lang.Object
transmatter.platform.administration.news.service.NewsServiceImpl
All Implemented Interfaces:
NewsService

@Service public class NewsServiceImpl extends Object implements NewsService
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) NewsDao
    This Field is a news Data Access Object that have a method to access directly to news database
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    This method is used to delete specific news using news id the method will be fetching the news to make sure if news is already existed after that it will delete the news
    This method is used to get all news from News Database
    org.springframework.data.domain.Page<News>
    getAllContents(org.springframework.data.domain.PageRequest page)
    This method is used to get all news from News Database with require a Pagination format that require page number and size of element
    org.springframework.data.domain.Page<News>
    getAllEmptyAltNews(org.springframework.data.domain.PageRequest page)
    this method used to get all Empty alternate text from News Database when this method called, it will create and empty list that will collect empty alternate text news after that, method will search through each individual news and check if news have an empty alternate text when the method check if news have empty alternate text it will add to the list after that finding empty alternate text ended, the method will push the list in to pagination format and return list of news that had empty alternate text as pagination format
    This method is used to get news from News Database to get individual news it will require an existed news if from news database
    org.springframework.data.domain.Page<News>
    getNewsBySource(String source, org.springframework.data.domain.PageRequest page)
    this method used to fetch the news by given source when this method called, it will fetch the news that have exact given source after the fetch finish, it will return the fetch news in pagination format
    org.springframework.data.domain.Page<News>
    searchNews(String title, org.springframework.data.domain.PageRequest page)
    this method used to search the news by given title when this method called, it will search news that contain a given title after the searching process finish, it will return the matched news in pagination format
    this method used to update the image alternated text by choosing the specific news id when this method called, it will fetch the news by given id then it will set the image alternate text value index by index after the update process finished it will return the updated news

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • newsDao

      @Autowired NewsDao newsDao
      This Field is a news Data Access Object that have a method to access directly to news database
  • Constructor Details

    • NewsServiceImpl

      public NewsServiceImpl()
  • Method Details

    • getContent

      public News getContent(String id)
      This method is used to get news from News Database to get individual news it will require an existed news if from news database
      Specified by:
      getContent in interface NewsService
      Parameters:
      id - the id of existed news from news Database
      Returns:
      individual news from news database
      Throws:
      NewsNotFoundException
    • getAllContents

      public org.springframework.data.domain.Page<News> getAllContents(org.springframework.data.domain.PageRequest page)
      This method is used to get all news from News Database with require a Pagination format that require page number and size of element
      Specified by:
      getAllContents in interface NewsService
      Parameters:
      page - pagination format
      Returns:
      all the news from News Database in pagination format
    • getAllContents

      public List<News> getAllContents()
      This method is used to get all news from News Database
      Specified by:
      getAllContents in interface NewsService
      Returns:
      all the news from News Database as List
    • deleteContent

      public News deleteContent(String id)
      This method is used to delete specific news using news id the method will be fetching the news to make sure if news is already existed after that it will delete the news
      Specified by:
      deleteContent in interface NewsService
      Parameters:
      id - the id of news that going to be deleted
      Returns:
      the deleted news
    • getAllEmptyAltNews

      public org.springframework.data.domain.Page<News> getAllEmptyAltNews(org.springframework.data.domain.PageRequest page)
      this method used to get all Empty alternate text from News Database when this method called, it will create and empty list that will collect empty alternate text news after that, method will search through each individual news and check if news have an empty alternate text when the method check if news have empty alternate text it will add to the list after that finding empty alternate text ended, the method will push the list in to pagination format and return list of news that had empty alternate text as pagination format
      Specified by:
      getAllEmptyAltNews in interface NewsService
      Parameters:
      page - pagination format
      Returns:
      list of news that had empty alternate text as pagination format
    • updateImageContent

      public News updateImageContent(String id, List<Image> ImageText)
      this method used to update the image alternated text by choosing the specific news id when this method called, it will fetch the news by given id then it will set the image alternate text value index by index after the update process finished it will return the updated news
      Specified by:
      updateImageContent in interface NewsService
      Parameters:
      id - the id of specific news
      ImageText - list of input of alternate text from user
      Returns:
      news that alternate text of news images are updated
    • searchNews

      public org.springframework.data.domain.Page<News> searchNews(String title, org.springframework.data.domain.PageRequest page)
      this method used to search the news by given title when this method called, it will search news that contain a given title after the searching process finish, it will return the matched news in pagination format
      Specified by:
      searchNews in interface NewsService
      Parameters:
      title - query of word that going to search news title
      page - pagination format
      Returns:
      list of news that matched query by given title in pagination format
    • getNewsBySource

      public org.springframework.data.domain.Page<News> getNewsBySource(String source, org.springframework.data.domain.PageRequest page)
      this method used to fetch the news by given source when this method called, it will fetch the news that have exact given source after the fetch finish, it will return the fetch news in pagination format
      Specified by:
      getNewsBySource in interface NewsService
      Parameters:
      source - source of news Thairath, Sanook, Dek-D
      page - pagination format
      Returns:
      list of news that fetched by given source in pagination format