Class HistoryController


  • @RestController
    @RequestMapping("API/history")
    @CrossOrigin("*")
    public class HistoryController
    extends Object
    History Controller: represents all the history of the communication between the user and the chatbot logged in the database. This controller mainly communicates with the admin interface to get the data such as the history list and the training model to be altered.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeState​(org.springframework.ui.ModelMap historyElem)
      Gets the file based on the language selected and returns it to be downloaded by the user
      org.springframework.http.ResponseEntity<org.springframework.core.io.FileSystemResource> download​(String lang)
      Gets the file based on the language selected and returns it to be downloaded by the user
      List<org.springframework.ui.ModelMap> getAll()
      Gets all the history from the database to be displayed in the admin interface.
      boolean upload​(String lang, org.springframework.ui.ModelMap body)
      Uploads the file content and saves it to the model feeder based on the language selected and returns if the file has been updated or not
    • Constructor Detail

      • HistoryController

        public HistoryController()
    • Method Detail

      • getAll

        @GetMapping("/all")
        public List<org.springframework.ui.ModelMap> getAll()
        Gets all the history from the database to be displayed in the admin interface.
        Returns:
        Array of ModelMap the returned values are of type Array of modelMap and each element has the following strucutre:
        {
        id : String,
        input : String,
        lang : String,
        state : String,
        output : {
        probability : double,
        catCode : int,
        category : String
        }
        }
        The model is History and it uses CategoryResult
      • download

        @GetMapping("/download/{lang}")
        public org.springframework.http.ResponseEntity<org.springframework.core.io.FileSystemResource> download​(@PathVariable("lang")
                                                                                                                String lang)
        Gets the file based on the language selected and returns it to be downloaded by the user
        Parameters:
        lang - String the language to be used to retrieve the training model.
        Returns:
        Response Entity of FileSystem Ressource a response with a text file Blob
        See Also:
        ResponseEntity, FileSystemResource, HttpHeaders, HttpStatus
      • upload

        @PostMapping("/upload/{lang}")
        public boolean upload​(@PathVariable("lang")
                              String lang,
                              @RequestBody
                              org.springframework.ui.ModelMap body)
        Uploads the file content and saves it to the model feeder based on the language selected and returns if the file has been updated or not
        Parameters:
        lang - String the language to be used to retrieve the training model.
        body - ModelMap with the text attribute with the content of the updated file.
        Returns:
        boolean to make sure that the file has been correctly uploaded.
        See Also:
        FileWriter
      • changeState

        @PostMapping("/state")
        public void changeState​(@RequestBody
                                org.springframework.ui.ModelMap historyElem)
        Gets the file based on the language selected and returns it to be downloaded by the user
        Parameters:
        historyElem - ModelMap containing the state to be changed to and the id of the element to change.
        See Also:
        Optional, History, HttpHeaders, HistoryRepository