Class HistoryController
- java.lang.Object
-
- net.thexcoders.aladin_bot_backend.controllers.HistoryController
-
@RestController @RequestMapping("API/history") @CrossOrigin("*") public class HistoryController extends ObjectHistory 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.
-
-
Constructor Summary
Constructors Constructor Description HistoryController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeState(org.springframework.ui.ModelMap historyElem)Gets the file based on the language selected and returns it to be downloaded by the userorg.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 userList<org.springframework.ui.ModelMap>getAll()Gets all the history from the database to be displayed in the admin interface.booleanupload(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
-
-
-
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
Historyand it usesCategoryResult
-
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 Ressourcea 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
-
-