From 63b0badef193d88faacaa3fbf653619150621fe6 Mon Sep 17 00:00:00 2001 From: Philip Kunz Date: Sun, 27 Aug 2023 11:52:33 +0200 Subject: [PATCH 1/2] doc: Implemented README.md and other documentation Signed-off-by: Philip Kunz --- analyze/README.md | 54 ++++++++++++++++++- analyze/pom.xml | 8 ++- .../analyze/service/MunicipalityService.java | 2 +- .../analyze/service/SurveyService.java | 45 ++++++++++++++++ 4 files changed, 104 insertions(+), 5 deletions(-) diff --git a/analyze/README.md b/analyze/README.md index 1ccc4af..69eb2ab 100644 --- a/analyze/README.md +++ b/analyze/README.md @@ -1,3 +1,53 @@ -# Analyzer +# NoScope360 Analyze Service -The analyzer reads the data from Elasticsearch, transforms it according to the indicator definitions and makes it available to the frontend in a unified format as a REST API. \ No newline at end of file +The NoScope360 Analyze Service is a robust Spring Boot application designed to handle operations related to +municipalities and surveys, offering capabilities such as fetching detailed municipality insights, computing average +ratings, managing and processing survey data, and more. + +### Features + +* **Municipality Operations:** Get a comprehensive overview of municipalities, detailed information on specific + municipalities based on ID, and compute statistics for all municipalities. +* **Survey Management:** Access a broad overview of all available surveys, fetch specific surveys by ID, view statistics + related to surveys, and process answers for given surveys. +* **Exception Handling:** Custom exception handling to handle scenarios such as invalid inputs and not-found resources. + +### Dependencies + +* **Spring Boot:** The backbone of our service, facilitating quick and efficient development. +* **SLF4J:** Logging framework integrated to provide insights into operations and assist with debugging. +* **Repositories:** Interaction with the database is facilitated using various repositories like + QuantitativeDataRepository, QualitativeDataRepository, MunicipalityRepository, and more. +* **SurveyClient:** An external client used for interactions related to survey operations. + +### Quick Start + +1. Clone the repository: + +```bash +git clone [repository_url] +``` + +2. Navigate to the project directory: + +```bash +cd noscope360-analyze-service +``` + +3. Build the project: + +```bash +mvn clean install +``` + +4. Run the application: + +```bash +mvn spring-boot:run +``` + +### Future Enhancements + +* Implement the outstanding `TODO` features in the `SurveyService`. +* Extend the application to incorporate more granular insights related to municipalities and surveys. +* Integrate with more data sources to enhance the comprehensiveness of our analysis. \ No newline at end of file diff --git a/analyze/pom.xml b/analyze/pom.xml index 26edc7e..0356d45 100644 --- a/analyze/pom.xml +++ b/analyze/pom.xml @@ -2,20 +2,24 @@ 4.0.0 + org.springframework.boot spring-boot-starter-parent 3.1.3 + io.natron.noscope360 analyze - 0.0.1-SNAPSHOT + 1.1.1 analyze - analyze + A comprehensive Spring Boot service for analyzing municipality data and managing surveys. + 17 + org.springframework.boot diff --git a/analyze/src/main/java/io/natron/noscope360/analyze/service/MunicipalityService.java b/analyze/src/main/java/io/natron/noscope360/analyze/service/MunicipalityService.java index c43d1cd..ddd3a44 100644 --- a/analyze/src/main/java/io/natron/noscope360/analyze/service/MunicipalityService.java +++ b/analyze/src/main/java/io/natron/noscope360/analyze/service/MunicipalityService.java @@ -88,7 +88,7 @@ public List getMunicipalities() { * @return {@link MunicipalityStatsDto} representing the statistics of all municipalities. */ public MunicipalityStatsDto getMunicipalitiesStats() { - log.info("Computing statistics for all municipalities..."); + log.info("Computing statistics over all municipalities..."); List municipalities = getMunicipalities(); int totalMunicipalities = municipalities.size(); diff --git a/analyze/src/main/java/io/natron/noscope360/analyze/service/SurveyService.java b/analyze/src/main/java/io/natron/noscope360/analyze/service/SurveyService.java index bf94593..352a1b3 100644 --- a/analyze/src/main/java/io/natron/noscope360/analyze/service/SurveyService.java +++ b/analyze/src/main/java/io/natron/noscope360/analyze/service/SurveyService.java @@ -14,6 +14,9 @@ import java.util.List; +/** + * Service responsible for managing and processing survey data. + */ @Service public class SurveyService { @@ -22,24 +25,65 @@ public class SurveyService { private final SurveyClient surveyClient; private final QualitativeDataRepository qualitativeDataRepository; + /** + * Constructor to initialize the SurveyService with the required dependencies. + * + * @param surveyClient client to interact with survey API. + * @param qualitativeDataRepository repository to fetch qualitative data. + */ public SurveyService(SurveyClient surveyClient, QualitativeDataRepository qualitativeDataRepository) { this.surveyClient = surveyClient; this.qualitativeDataRepository = qualitativeDataRepository; + + log.info("SurveyService initialized."); } + /** + * Fetches an overview of all available surveys. + * + * @return a list of SurveyOverviewDto representing all surveys. + */ public List getSurveys() { + log.info("Fetching overview for all surveys..."); + // TODO: Implement the logic to get the surveys overview. Not implemented due to time constraints. return null; } + /** + * Provides statistics related to surveys. + * + * @return a SurveyStatsDto containing survey statistics. + */ public SurveyStatsDto getSurveyStats() { + log.info("Computing statistics over all surveys..."); + // TODO: Implement the logic to get the survey stats. Not implemented due to time constraints. return null; } + /** + * Fetches a specific survey by its ID. + * + * @param id the unique identifier of the survey. + * @return a SurveyDto representing the requested survey. + */ public SurveyDto getSurveyById(String id) { + log.info("Fetching details for survey with ID: {}", id); + // TODO: Implement the logic to get a details of a survey by ID. Not implemented due to time constraints. return null; } + /** + * Generates answers for a survey. + * + * @param id the unique identifier of the survey. + * @param surveyAnswersDto the DTO containing the survey answers data. + * @return a SurveyAnswersDto containing the processed survey answers. + * @throws SurveyNotFoundException if the survey is not found. + * @throws InvalidInputException if the provided ID and ID in the request body are not matching. + */ public SurveyAnswersDto makeSurveyAnswers(String id, SurveyAnswersDto surveyAnswersDto) throws SurveyNotFoundException, InvalidInputException { + log.info("Adding answers for survey with ID: {}", id); + if (!surveyClient.callSurveyAPI(id)) { throw new SurveyNotFoundException("Survey not found: " + id); } @@ -47,6 +91,7 @@ public SurveyAnswersDto makeSurveyAnswers(String id, SurveyAnswersDto surveyAnsw throw new InvalidInputException("Given ID and ID in the request body are not matching."); } + // TODO: Implement the logic to add answers for a survey. Not implemented due to time constraints. return null; } } From 6c5888fdb17363d74c37eb3dad08b18055f402b3 Mon Sep 17 00:00:00 2001 From: Philip Kunz Date: Sun, 27 Aug 2023 11:52:59 +0200 Subject: [PATCH 2/2] doc: Updated version in pom Signed-off-by: Philip Kunz --- analyze/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze/pom.xml b/analyze/pom.xml index 0356d45..5cc9779 100644 --- a/analyze/pom.xml +++ b/analyze/pom.xml @@ -12,7 +12,7 @@ io.natron.noscope360 analyze - 1.1.1 + 1.1.2 analyze A comprehensive Spring Boot service for analyzing municipality data and managing surveys.