leukschrauber / ITProjectManagement

IT Project Management Class Group 7
0 stars 0 forks source link

Save and retrieve FAQ Vectorized Data #18

Open leukschrauber opened 6 months ago

leukschrauber commented 6 months ago

This task is about loading the FAQs from a ZIP-File into our FAQ Database. The entry point for this operation is https://github.com/leukschrauber/ITProjectManagement/blob/main/service/src/main/java/at/uni/innsbruck/htibot/rest/HTIBotApiImpl.java.

In the method upadteKnowledgeDB, a Zip-File is given as a parameter (InputStream) via HTTP. The method will get the question and answer out of every HTML File, as well as related resources from a resource folder within the ZIP File. The question will be transformed into a feature vector and saved to the database using a JpaService. You can implement this service similar to https://github.com/leukschrauber/ITProjectManagement/blob/main/service/src/main/java/at/uni/innsbruck/htibot/jpa/core/business/services/JpaConversationService.java, which takes care of CRUD Operations on the JpaConversation Object. The new service https://github.com/leukschrauber/ITProjectManagement/blob/main/service/src/main/java/at/uni/innsbruck/htibot/jpa/core/business/services/JpaKnowledgeService.java will take care of JpaKnowledge and JpaKnowledgeResource.

If the boolean parameter cleanUp is specified as true, old knowledge gets deleted after the succesful upload of the new FAQ Data.

Note: I did not try out whether the upload of a zip file is easy to get to work via HTTP. It may be necessary to use another Approach: Configure a new file path property in https://github.com/leukschrauber/ITProjectManagement/blob/main/service/src/main/resources/at/uni/innsbruck/htibot/config.properties, which can be used by accessing the class https://github.com/leukschrauber/ITProjectManagement/blob/main/service/src/main/java/at/uni/innsbruck/htibot/core/util/properties/ConfigProperties.java. Then, instead of exposing a HTTP API, we will just initialize the FAQ Database everytime after starting the server. In this case, the logic will not be implemented in HTIBotApiImpl, but in https://github.com/leukschrauber/ITProjectManagement/blob/main/service/src/main/java/at/uni/innsbruck/htibot/core/SetupListener.java. Just try with HTTP and if you can't get it to work, this approach works 100 %.