diff --git a/.idea/misc.xml b/.idea/misc.xml index ba18a6c33941ef11eae66cf92f7dc410afae5c27..14613fe5e03b18ddd991ae2d6469785815981a8c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,5 +8,5 @@ </list> </option> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-20" project-jdk-type="JavaSDK" /> + <component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="openjdk-20" project-jdk-type="JavaSDK" /> </project> \ No newline at end of file diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java index 8c238f9a2cf906d2cecd9626de76b690a14c3590..1a228e45e1da8670f4515e2dd0606a24086f7ae4 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java @@ -12,9 +12,8 @@ import java.util.Arrays; /** * Cors configuration for application - * @author Birk - * @version 1.0 - * @since 04.04.2023 + * @author Birk, Anders + * @version 1.1 */ @Configuration @AllArgsConstructor @@ -35,7 +34,6 @@ public class CorsConfig { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins(Arrays.asList("https://localhost", - "https://10.24.38.136", domainProperty.domain() ).toArray(String[]::new)) .allowedMethods(Arrays.asList( diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/SecurityConfig.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/SecurityConfig.java index 5aa3c4bf6d6725296b93f9d92c1a017b1a83a8d6..446e5800a250bc12d9dd18f118dfa7f150a61a58 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/SecurityConfig.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/SecurityConfig.java @@ -13,7 +13,6 @@ import org.springframework.security.web.SecurityFilterChain; * Configs for security and authentication * @author Birk * @version 1.0 - * @since 04.04.2023 */ @Configuration @AllArgsConstructor @@ -23,8 +22,6 @@ public class SecurityConfig { * Configures the HttpSecurity for the application. * Dose not need ot have csrf enabled, because we are using jwt * and the application is stateless - * <p> - * TODO: Enable CORS policy when possible! * * @param http HttpSecurity to configure * @return SecurityFilterChain with configured HttpSecurity diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/authentiation/AuthenticationConfig.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/authentiation/AuthenticationConfig.java index 6a12193c63ff9f1bdea776058772aa4d122fcf13..e7158b2ab8621fced8663150620d6ddd6e3709b6 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/authentiation/AuthenticationConfig.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/authentiation/AuthenticationConfig.java @@ -26,7 +26,6 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager; * Configures the authentication for the application. * @author Anders and birk * @version 1.1 - * @since 05.04.2023 */ @Configuration public class AuthenticationConfig { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/properties/DomainProperty.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/properties/DomainProperty.java index 3ec7bbdbb41cd1b04f3122d3704eb0ce970667ea..5a096094525d2f9c4c69ebbd386bc8c35a14f3ef 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/properties/DomainProperty.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/properties/DomainProperty.java @@ -6,7 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * Configuration properties for the domain of the application * @author Birk * @version 1.0 - * @since 04.04.2023 */ @ConfigurationProperties(prefix = "domain") public record DomainProperty (String domain){ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AllergyController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AllergyController.java index a8cbdf8c0b1d5c47161f586ccb3a5b2e5f5b1e08..578ce1f9658a4bd90d11e1089f6b83d854769605 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AllergyController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AllergyController.java @@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.*; /** * Controller for allergies * @author Stian Lyng - * @version 1.0 */ @AllArgsConstructor @RestController diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AuthenticationController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AuthenticationController.java index 8791924bbf026cfee268abafc81bdb52f47bcb04..f2d40cf818cb95ebf70e54e392cb16d6dc8472ec 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AuthenticationController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/AuthenticationController.java @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController; * * @author Anders * @version 1.0 - * @since 19.04.2023 */ @RestController diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/RecipeController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/RecipeController.java index aaa3bb28549b40b75fcbe98bea8e92e713f32f4f..4d737a31efa32a475a99768944a6bca2c8fc8424 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/RecipeController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/RecipeController.java @@ -23,9 +23,6 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/api/recipe") public class RecipeController { - /** - * The recipe service - */ private final RecipeService recipeService; /** diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java index 8f5b6021b7748b41ee9dbc6d6c2aa737a363fb9c..5888530361ed719265366859bc75d407a8bc7fea 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java @@ -45,6 +45,7 @@ public class ShoppingListController { * Gets a shopping list by its ID * * @param id the shopping list ID + * @param authentication The authentication object of the user. * @return the shopping list, or an error if the ID is invalid, * or the user dose not have the rights to edit the shopping list */ @@ -65,6 +66,7 @@ public class ShoppingListController { * Gets a shopping list by its group ID * * @param id the request containing the group ID + * @param authentication The authentication object of the user. * @return the shopping list, or an error if the ID is invalid */ @GetMapping("/group/{groupId}") @@ -150,6 +152,7 @@ public class ShoppingListController { * * @param shoppingListId the shopping list ID * @param ean the product EAN + * @param auth The authentication object of the user. * @return the shopping list with the removed product, or an error if the shopping list ID or EAN is invalid */ @DeleteMapping("/removeProduct/{shoppingListId}/{ean}") diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/WeeklyMenuController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/WeeklyMenuController.java index 74c65bb752e6c341f80bbb40b772591c5b0c34fb..66e959088c0931da21e24aafeeed4262a904b361 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/WeeklyMenuController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/WeeklyMenuController.java @@ -14,28 +14,24 @@ import ntnu.idatt2016.v233.SmartMat.dto.response.WeeklyMenuResponse; import ntnu.idatt2016.v233.SmartMat.service.RecipeService; import ntnu.idatt2016.v233.SmartMat.service.WeeklyMenuService; +/** + * Controller for weekly menu + * + * @author Stian Lyng + * @version 1.0 + */ @AllArgsConstructor @RestController @RequestMapping("/api/weeklymenu") public class WeeklyMenuController { - - /* - private WeeklyMenuService weeklyMenuService; - - @GetMapping("/{fridgeId}") - public ResponseEntity<List<WeeklyMenuResponse>> getWeeklyMenu(@PathVariable("fridgeId") Long fridgeId) { - List<WeeklyMenuResponse> weeklyMenu = weeklyMenuService.getWeeklyMenu(fridgeId); - - if (weeklyMenu.isEmpty()) { - return ResponseEntity.notFound().build(); - } else { - return ResponseEntity.ok(weeklyMenu); - } - } - */ final private RecipeService recipeService; + /** + * Gets weekly menu for a fridge + * @param fridgeId the id of the fridge + * @return the weekly menu for the fridge + */ @GetMapping("/{fridgeId}") public ResponseEntity<Object> compareWeeklyMenuAndRecipeProducts(@PathVariable("fridgeId") Integer fridgeId) { List<RecipeWithMatchCount> weeklyMenuDetails = recipeService.getWeeklyMenu(fridgeId); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/FridgeController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/FridgeController.java index 2869134cce960b8fec71b015b5a38303cdbe2b75..20bde998469e42d9ffaa1e8133d1f32c9ff7d17b 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/FridgeController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/FridgeController.java @@ -58,7 +58,8 @@ public class FridgeController { /** * Gets the fridge by its fridge id - * @param fridgeId the id of the fridge + * @param fridgeId the id of the fridge to get + * @param authentication a user authentication object for validation of user authorization * @return the fridge if it exists, or a 404 if it doesn't, or a 403 if the user is not in the fridge */ @GetMapping("/fridge/{fridgeId}") @@ -79,6 +80,7 @@ public class FridgeController { * Adds a product to the fridge of a group * * @param request the request containing the group id and product id + * @param authentication a user authentication object for validation of user authorization * @return success if the product was added, bad request if the product was already in the fridge, or not found if the group or product doesn't exist */ @PostMapping("/group/product") @@ -107,6 +109,7 @@ public class FridgeController { /** * Updates a product in a fridge * @param request the request containing the group id and product id + * @param authentication a user authentication object for validation of user authorization * @return success if the product was added, bad request if the product was already in the fridge, * or not found if the group or product doesn't exist */ @@ -174,6 +177,7 @@ public class FridgeController { /** * Deletes a product from the fridge * @param fridgeProductId the id of the fridge product association + * @param authentication the authentication of the user * @return success if the product was deleted, bad request if the product wasn't found * , or forbidden if the user is not in the group */ @@ -207,6 +211,7 @@ public class FridgeController { * Deletes a product from the fridge and creates a waste object from it. * * @param fridgeProductId The id of the fridge product association to be deleted + * @param authentication The authentication of the user * @return A ResponseEntity with status code 200 if successful, * or status code 404 if the specified fridge product association was not found. * or status code 403 if the user is not in the group diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/GroupController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/GroupController.java index 7ed47a10025a1540748fd5ce957fbeef04d615be..48c6829c7aa046d113a6e836ba774fa721ad6789 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/GroupController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/GroupController.java @@ -37,6 +37,7 @@ public class GroupController { /** * Gets a group by its id * @param groupId the id of the group + * @param auth the authentication of the user * @return a ResponseEntity containing the group if it exists, or a 404 if it doesn't */ @GetMapping("/{groupId}") @@ -72,6 +73,7 @@ public class GroupController { * Creates a new group * * @param groupRequest the group to create + * @param auth the authentication of the user * @return a ResponseEntity containing the created group if it was created successfully, * or a 400 if the group name is invalid or already exists, or if the username is invalid */ @@ -130,6 +132,7 @@ public class GroupController { * Gets the level of a group * * @param groupId the id of the group + * @param auth the authentication of the user * @return a ResponseEntity containing the level of the group if it exists, or a 404 if it doesn't */ @GetMapping("/{groupId}/level") @@ -174,6 +177,7 @@ public class GroupController { * Updates the open/closed status of the group with the specified ID. * * @param groupId the ID of the group to update + * @param auth the authentication of the user * @return a ResponseEntity with a Boolean value indicating whether the operation was successful */ @PutMapping("/{groupId}/changeOpen") @@ -196,6 +200,7 @@ public class GroupController { * Handles the HTTP PUT request to change the primary group of a user. * * @param newPrimaryGroupId the ID of the new primary group + * @param auth the authentication of the user * @return a ResponseEntity object containing an HTTP status code and the updated UserGroupAsso object, * or a ResponseEntity object with an HTTP status code indicating that the request was not successful */ @@ -244,6 +249,7 @@ public class GroupController { * Handles the HTTP POST request to add a new connection between a user and a group. * * @param groupConnectionRequest the request object containing the username and link code of the user and group to be connected + * @param auth the authentication of the user * @return a ResponseEntity object containing an HTTP status code and the newly created UserGroupAsso object, * or a ResponseEntity object with an HTTP status code indicating that the request was not successful */ @@ -294,6 +300,7 @@ public class GroupController { * Changes the authority level of a user in a group. * * @param authorityRequest the request object containing the username and group ID of the user to change the authority of + * @param auth the authentication of the user * @return a ResponseEntity object containing the updated UserGroupAsso object and an HTTP status code of 200, * or a ResponseEntity object with an HTTP status code of 403 if the user is not authorized to change the authority, * or a ResponseEntity object with an HTTP status code of 404 if the group or user does not exist diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/WasteController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/WasteController.java index 0c804cf2c54fec9c99ebb66a036f7625ade2801b..444287ff655c7dde446d25ab059dc906d92c92c4 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/WasteController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/group/WasteController.java @@ -144,6 +144,7 @@ public class WasteController { * The amount is calculated based on the total cost of the expired products. * * @param groupId the ID of the group to retrieve the lost money from + * @param authentication The authentication of the user. * @return a ResponseEntity with the lost money as a Double if found, or a ResponseEntity with status 404 if the group is not found */ @GetMapping("/statistic/lostMoney/{groupId}") @@ -159,6 +160,7 @@ public class WasteController { * Retrieves the amount of CO2 emitted annually per person in a specific group. * * @param groupId the ID of the group to retrieve the statistic for + * @param authentication The authentication of the user. * @return a ResponseEntity containing the amount of CO2 emitted annually per person in the group, * or a ResponseEntity with HTTP status 404 (not found) if the group or data is not found */ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/product/ProductController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/product/ProductController.java index abda8869cf2dbbd2246bebf9c0d61ed969455237..742a2ca7741ab24ac1a770bfcafbc4fd229cab77 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/product/ProductController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/product/ProductController.java @@ -23,7 +23,6 @@ import java.util.Optional; * It uses the product service to handle the requests. * @version 1.0 * @Author Birk - * @since 26.04.2023 */ @RestController @AllArgsConstructor @@ -130,7 +129,7 @@ public class ProductController { /** * Returns all products in the database. - * @return All products in the database. + * @return A list of all products in the database. */ @GetMapping("/") public ResponseEntity<List<Product>> getAllProducts() { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/AchievementController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/AchievementController.java index 2b49fd4bf793e6eb19a986fec14f686e9ac0e03d..30de98804780198e9882f48b6ec6b777ef820e24 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/AchievementController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/AchievementController.java @@ -18,7 +18,6 @@ import java.util.Optional; * * @author Anders * @version 1.0 - * @sinc 20.04.2023 */ @AllArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/UserController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/UserController.java index c591bc54401b07bd06f35da399741dead7593f9b..df6a56d68705f5785f3a657061785bf871d8d30e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/UserController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/user/UserController.java @@ -26,7 +26,6 @@ import java.util.stream.Collectors; * It uses the user service to handle the requests. * @author Birk * @version 1.2 - * @since 20.04.2023 */ @AllArgsConstructor @RestController @@ -38,16 +37,6 @@ public class UserController { PasswordEncoder passwordEncoder; /** - * Use this JSON format: - * { - * "username":"kari123", - * "password":"sjokoladekake", - * "email":"kari.nordman@gmail.com", - * "firstName":"kari", - * "lastName":"nordmann", - * "birthDate":"2001-12-12" - * } - * * create a new user in the database * uses the user service * @param user The user to be registered. @@ -88,6 +77,7 @@ public class UserController { /** * Get a user from the database. * @param username The username of the user to be fetched. + * @param authentication The authentication object of the user. * @return The user with the given username. */ @GetMapping("/get/{username}") @@ -110,6 +100,7 @@ public class UserController { * Adds the specified allergy to the user with the given username. * * @param allergyRequest the request object containing the username and allergy name + * @param authentication The authentication object of the user. * @return a ResponseEntity with a boolean indicating whether the operation was successful */ @PostMapping("/addAllergy") @@ -126,6 +117,7 @@ public class UserController { * Deletes the specified allergy from the user with the given username. * * @param allergyRequest the request object containing the username and allergy name + * @param authentication The authentication object of the user. * @return a ResponseEntity with a boolean indicating whether the operation was successful */ @DeleteMapping("/deleteAllergy") diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/enums/Authority.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/enums/Authority.java index d2aa0f3773a2410fd2cdf880861ff52db1ddd354..aff64ff991eab2da6f4553cdb753b5e41e43768c 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/enums/Authority.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/enums/Authority.java @@ -5,7 +5,6 @@ package ntnu.idatt2016.v233.SmartMat.dto.enums; * * @author Birk * @version 2.0 - * @since 19.04.2023 * */ public enum Authority{ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/FridgeProductRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/FridgeProductRequest.java index 0df58b4fe4b21788385ec234ef449307c5b7239c..48da0a316c85c3030849196301685c3352f4a45f 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/FridgeProductRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/FridgeProductRequest.java @@ -2,7 +2,12 @@ package ntnu.idatt2016.v233.SmartMat.dto.request; /** * FridgeProductRequest is a record class representing a request to add a product to a fridge. + * @param fridgeProductId the id of the fridge product * @param groupId the id of the group + * @param ean the ean of the product + * @param amount the amount of the product + * @param days the days before expiry date of the product + * @param price the price of the product */ public record FridgeProductRequest(long fridgeProductId, long groupId, long ean, int amount, int days, double price) { } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/LoginRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/LoginRequest.java index f9ca9f78a4caff50ab06be9735f153429131c26d..709e502b3161fb3163881c5828c2868ae038c84e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/LoginRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/LoginRequest.java @@ -2,11 +2,6 @@ package ntnu.idatt2016.v233.SmartMat.dto.request; /** * LoginRequest is a record class representing a login request. - * - * @author Anders - * @version 1.0 - * @since 18.04.2023 - * * @param username * @param password */ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/ProductRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/ProductRequest.java index 372634c71f36ac0a32ededea9377e7b84e3366ba..4e067b92fb65f5a12eb1945370fda2dca928a2cd 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/ProductRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/ProductRequest.java @@ -4,6 +4,15 @@ import lombok.Builder; import java.util.List; +/** + * ProductRequest is a record class representing a request to create a product. + * @param ean the ean of the product + * @param name the name of the product + * @param description the description of the product + * @param image the image of the product + * @param price the price of the product + * @param allergies the allergies of the product + */ @Builder public record ProductRequest(long ean, String name, String description, String image, double price, List<String> allergies) { } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/RegisterUserRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/RegisterUserRequest.java index 988d732d8692292306c642337a4f6a8a50f799ec..6df60e0ff9f3f4762475bf4a5253999f1791c3f1 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/RegisterUserRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/RegisterUserRequest.java @@ -7,7 +7,9 @@ import java.sql.Date; * @param username the username of the user * @param password the password of the user * @param email the email of the user - * + * @param firstName the first name of the user + * @param lastName the last name of the user + * @param birthDate the birth date of the user */ public record RegisterUserRequest(String username, String password, String email, String firstName, String lastName, Date birthDate){ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/UpdateUserRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/UpdateUserRequest.java index 159107c397361cc9931851ef3935e3f2cc4acd13..2e7e6ccd9e9f2d9765aff9e50d7c3fd78954f747 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/UpdateUserRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/UpdateUserRequest.java @@ -5,9 +5,6 @@ import java.util.List; /** * This class represents a request to update a user - * @author Birk - * @version 1.0 - * @since 26.04.2023 * * @param firstName the first name of the user * @param lastName the last name of the user diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/WasteRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/WasteRequest.java index dbf75a2666516cdd367d02c58f30ae4f714611f7..929fc9a5a51f83fc0812cc82ba6fdf3bef1408ce 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/WasteRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/WasteRequest.java @@ -1,5 +1,12 @@ package ntnu.idatt2016.v233.SmartMat.dto.request; +/** + * WasteRequest is a record class representing a request to add a product to a fridge. + * @param groupId the id of the group + * @param ean the ean of the product + * @param amount the amount of the product + * @param unit the unit of the product + */ public record WasteRequest(long groupId, long ean, double amount, String unit) { } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/group/ChangeAuthorityRequest.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/group/ChangeAuthorityRequest.java index ae7282ae1bb3e9f436dbca53a6e817aa14176d3b..2a4457e9b77439d29213d15db1e37c1dc04adbb7 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/group/ChangeAuthorityRequest.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/request/group/ChangeAuthorityRequest.java @@ -1,4 +1,10 @@ package ntnu.idatt2016.v233.SmartMat.dto.request.group; +/** + * ChangeAuthorityRequest is a record class representing a request to change the authority of a user in a group. + * @param username the username of the user + * @param groupId the id of the group + * @param authority the new authority of the user + */ public record ChangeAuthorityRequest(String username, long groupId, String authority) {} diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponse.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponse.java index 66b2f728ae93a85bdf01a528305a2ce209adec33..fcf34981233259778721089e4377f3171c3529b6 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponse.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponse.java @@ -6,7 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * This class represents a response for a weekly menu. + * This class represents an allergy response */ @Data @Builder diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetails.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetails.java index 2fd6f3f2a1d670bbdfc427226b9d7d3fa9ad6345..f02cb54c3d000e676ab235d17f89337c166e8cbb 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetails.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetails.java @@ -6,7 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * This class represents a response for a weekly menu. + * This class represents recipe details response */ @Data @Builder diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCount.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCount.java index 0dbdf6859200cac70b6fd1c73640a3e123d44d1d..72ad5a44533b9661d9e0bfc795cdea7740d88186 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCount.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCount.java @@ -6,7 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * This class represents a response for a weekly menu. + * This class represents recipe response with match count */ @Data @Builder diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/GroupDetailsResponse.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/GroupDetailsResponse.java index 38016d4483fdc93b461f2d30e4d6833b1f23f52d..e2e1c7dd1e46d6b7bf055b2d1cb9caf50b293bf2 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/GroupDetailsResponse.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/GroupDetailsResponse.java @@ -5,6 +5,9 @@ import ntnu.idatt2016.v233.SmartMat.entity.group.Group; import java.util.List; +/** + * GroupDetailsResponse is a class representing a response containing details about a group. + */ @Data public class GroupDetailsResponse { private long groupId; diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/UserAuthorityInfo.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/UserAuthorityInfo.java index 260607e221010a347b09abd68d3ddd2033831832..96f404c17400dcb8c61d9b1dce52b4cb8f54e663 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/UserAuthorityInfo.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/dto/response/group/UserAuthorityInfo.java @@ -1,3 +1,8 @@ package ntnu.idatt2016.v233.SmartMat.dto.response.group; +/** + * UserAuthorityInfo is a record class representing a response to a group request. + * @param username the username of the user + * @param authority the authority of the user + */ public record UserAuthorityInfo(String username, String authority) {} diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Recipe.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Recipe.java index b4ce8bf285511ec93e0bb6fdd45affb96aad094f..ab7b573795477e2000362eb2c2725ea793e107f5 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Recipe.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Recipe.java @@ -17,10 +17,8 @@ import ntnu.idatt2016.v233.SmartMat.entity.user.User; /** * Recipe is an entity class representing a recipe in the system. * - * @author Anders & Stian + Birk - * @version 1.1 - * @since 25.04.2023 - * + * @author Anders, Stian, Birk + * @version 1.7 */ @NoArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/ShoppingList.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/ShoppingList.java index 339e86cfac410c68a4c974766eca63950944c5ef..1a8166737aec9ea5980fca8a7d4116f1d613004f 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/ShoppingList.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/ShoppingList.java @@ -14,10 +14,8 @@ import java.util.List; /** * This class represents a shopping list * - * @author Stian Lyng and Anders - * @version 1.0.001 - * @since 19.04.2023 - * + * @author Stian Lyng, Anders, Birk + * @version 1.3 */ @NoArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Waste.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Waste.java index 567f074c7863a26219a5ac9227019bdc9ad94203..716a3db2566b1fff782cf055e05e5a5ac76165bb 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Waste.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/Waste.java @@ -15,10 +15,8 @@ import java.sql.Timestamp; /** * This class represents a waste made by a group. * - * @author Stian Lyng and Anders - * @version 1.0.001 - * @since 19.04.2023 - * + * @author Anders, Birk, Pedro + * @version 1.3 */ @NoArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java index eb660c4948666ee397d16796bc5ee2e57a528640..368ce1c69b4660ea99b1bc0cf2e18fda625b4bf1 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java @@ -11,6 +11,12 @@ import ntnu.idatt2016.v233.SmartMat.entity.product.Product; import java.sql.Date; +/** + * FridgeProductAsso is an entity class representing a fridge product association. + * + * @author Birk, Pedro + * @version 1.1 + */ @AllArgsConstructor @NoArgsConstructor @Data diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Achievement.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Achievement.java index 1e692d3a28d0b1fe9126e6b8ed746b98211b1e35..28fe3d04dd1d1f05db821eec55d895ee1b5c8d65 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Achievement.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Achievement.java @@ -14,9 +14,8 @@ import java.util.List; /** * Achievement is an entity class representing an achievement in the system. * - * @author Anders - * @version 1.0 - * @since 19.04.2023 + * @author Anders, Birk + * @version 1.1 * */ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Fridge.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Fridge.java index 537c640223ddc5cfe829c703a37ea2965f20e941..0e07d4b6065e8102054a777df5941b849586462a 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Fridge.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Fridge.java @@ -20,7 +20,6 @@ import org.hibernate.annotations.OnDeleteAction; * * @author Anders & Birk * @version 1.2 - * @since 25.04.2023 */ @NoArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Group.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Group.java index 9a87de61a0cdf093cc3043aa2b1103b7d4828f8d..ad150509697077816d53dc47a97c9aa52b08a94a 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Group.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/Group.java @@ -16,11 +16,10 @@ import java.util.ArrayList; import java.util.List; /** - * Group is an entity class representing a group in the system. + * Group is an entity class representing a user group in the system. * - * @author Stian Lyng, Anders Austlid - * @version 1.0.1 - * @since 20.04.2023 + * @author Stian Lyng, Anders Austlid, Birk, Pedro + * @version 1.3 */ @NoArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupAsso.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupAsso.java index cf3b0fca6be1baeaa5cb6570cd0210d947799a1d..e60d36b4f8aa838a215ebbe05beed606dbefafc8 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupAsso.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupAsso.java @@ -9,9 +9,8 @@ import ntnu.idatt2016.v233.SmartMat.entity.user.User; /** * UserGroupTable is a class representing the user_group table in the database. * It is used to represent the many-to-many relationship between users and groups. - * @Author Birk - * @Version 1.0 - * @Since 25.04 + * @Author Birk, Pedro + * @Version 1.2 */ @Entity @AllArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupId.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupId.java index a9698b22e631d954bc2b8512bf871216fb7a06f3..9eec6d34b16eeab89e32dbe79750f7243c141156 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupId.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/group/UserGroupId.java @@ -10,6 +10,12 @@ import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Objects; +/** + * This class represents a user group id + * + * @author Birk + * @version 1.0 + */ @AllArgsConstructor @NoArgsConstructor @Data @@ -21,7 +27,6 @@ public class UserGroupId implements Serializable { @Column(name = "group_id") private long groupId; - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Allergy.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Allergy.java index b3b87d9a84a1006c6c974436cc3d86e944c7335f..79ffc537458180188a0e8a4a7258d99fa72f71e4 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Allergy.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Allergy.java @@ -17,8 +17,6 @@ import java.util.List; * * @author Stian Lyng and Anders * @version 1.3 - * @since 24.04.2023 - * */ @NoArgsConstructor @@ -62,6 +60,10 @@ public class Allergy{ } + /** + * adds a product to the allergy + * @param product adds a product to the list of products with this allergy + */ public void addProduct(Product product) { if (products == null) products = new ArrayList<>(); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Category.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Category.java index d460d91555e64c54c0cc100f747e19838da96fc2..aef8bfaf120c1004c6bb6c0a14f2d1e624891a1e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Category.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Category.java @@ -10,6 +10,12 @@ import lombok.NoArgsConstructor; import java.util.List; +/** + * Category is an entity class representing a product category + * + * @author Pedro, Birk + * @version 1.1 + */ @NoArgsConstructor @AllArgsConstructor @Builder @@ -26,6 +32,10 @@ public class Category { @JsonIgnore private List<Product> products; + /** + * adds a product to the category + * @param product adds a product to the list of products in this category + */ public void addProduct(Product product) { if (products == null) products = List.of(product); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java index 45efc15f82d56754a013e126571ed087eb37658e..febadac7f378791155c7cc320db0d8642fa6010e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java @@ -22,9 +22,8 @@ import java.util.List; * Product is an entity class representing a product in the system. * All other info about the product is fetched from api call on fronted. * this ensures that the product is always up to date. - * @author Birk and Anders - * @version 1.1.001 - * @since 19.04.2023 + * @author Birk, Anders, Pedro + * @version 1.4 */ @Data @NoArgsConstructor @@ -116,6 +115,10 @@ public class Product{ shoppingLists.add(shoppingList); } + /** + * Adds an allergy to the product + * @param allergy the allergy to add to the product + */ public void addAllergy(Allergy allergy){ if (allergies == null){ allergies = new ArrayList<>(); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/user/User.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/user/User.java index 4129c44420e16c0b7fbfe83612d2e1b110cbc671..ff2635a7b446773b566b912ab37efc4bb2db8345 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/user/User.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/user/User.java @@ -20,10 +20,8 @@ import java.util.*; * User is a class representing a user in the system. * It implements the UserDetails interface. * - * @author Anders and Birk + * @author Anders, Birk, Pedro * @version 2.0.3 - * @since 25.04.2023 - * */ @Data diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java index 94a4bf58a8ff87f2765a36abf4c3510971ef566d..539e6349851f9dee0c3aee195e8e11f2e1ea6b59 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java @@ -12,7 +12,6 @@ import java.util.Optional; * * @author Stian Lyng and birk * @version 1.2 - * @since 21.04.2023 */ public interface AllergyRepository extends JpaRepository<Allergy, String> { /** diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java index d85894c2d48bb672c13cface578b18cdc3861d41..ace138c6f0374c10191072d2fee5d013e795e3dd 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java @@ -11,7 +11,7 @@ import org.springframework.data.repository.query.Param; * This interface defines the methods for the recipe repository * * @author Stian Lyng - * @version 1.0 + * @version 2.0 */ public interface RecipeRepository extends JpaRepository<Recipe, Long> { @@ -22,6 +22,11 @@ public interface RecipeRepository extends JpaRepository<Recipe, Long> { */ List<Recipe> findAllByName(String name); + /** + * Gets a weekly menu for a fridge + * @param fridgeId the id of the fridge + * @return a list of objects containing the name of the product and the id of the fridge + */ @Query( value = """ select p2.item_name, f.fridge_id from fridge f @@ -29,7 +34,11 @@ public interface RecipeRepository extends JpaRepository<Recipe, Long> { inner join product p2 on p2.ean = fp.ean """, nativeQuery = true) List<Object[]> findWeeklyMenu(long fridgeId); - + + /** + * Gets a list of recipes with their products + * @return a list of objects containing the recipe id, name, description, image url and product name + */ @Query( value = """ SELECT r.recipe_id, r.recipe_name, r.recipe_description, r.image_url, p.item_name FROM recipe r diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ShoppingListRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ShoppingListRepository.java index b4dfbe259e81c36e2a8bfbd9170f9b7945d6d9d6..f0dd168099ad926833f0f6a438c60d98614a632b 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ShoppingListRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ShoppingListRepository.java @@ -9,10 +9,8 @@ import org.springframework.data.jpa.repository.JpaRepository; /** * This interface defines the methods for the shopping list repository * - * @author Stian Lyng + * @author Stian Lyng, Birk * @version 1.2 - * @since 19.04.2023 - * */ public interface ShoppingListRepository extends JpaRepository<ShoppingList, Long> { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/FridgeRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/FridgeRepository.java index 8d8ed7ded3e4713b23773c21af78a19115274074..fe270076e359b5650631e126a3f60a8f4769de1f 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/FridgeRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/FridgeRepository.java @@ -5,6 +5,12 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; +/** + * Repository interface for the Fridge entity + * + * @author Anders, Birk + * @version 1.1 + */ public interface FridgeRepository extends JpaRepository<Fridge, Long> { /** * Gets the fridge of a group diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/GroupRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/GroupRepository.java index e1f3278481f0b498efb7b1b4ba4beb203f3a39ec..42fb031fcc95c27fba7ac916af3e2ebcf566e07f 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/GroupRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/GroupRepository.java @@ -14,9 +14,8 @@ import java.util.Optional; /** * Repository for groups * - * @author Stian Lyng, Anders Austlid + * @author Stian Lyng, Anders Austlid, Pedro Cardona * @version 1.3 - * @since 24.04.2023 */ public interface GroupRepository extends JpaRepository<Group, Long> { /** @@ -42,11 +41,25 @@ public interface GroupRepository extends JpaRepository<Group, Long> { */ Optional<Group> findByGroupId(long id); + /** + * Gets link codes of all groups + * @return a list of all link codes + */ @Query(value = "SELECT link_code FROM groups", nativeQuery = true) List<String> findAllLinkCode(); + /** + * Gets a group with a given link code + * @param linkCode the link code of the group + * @return the group with the given link code if it exists + */ Optional<Group> findByLinkCode(String linkCode); + /** + * Gets the amount of users in a group with a given group id + * @param groupId the id of the group + * @return the amount of users in the group + */ @Query(value = "SELECT count(*) FROM user_group where group_id = :groupId", nativeQuery = true) int countAllUserInGroup(@Param("groupId") long groupId); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/UserGroupAssoRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/UserGroupAssoRepository.java index 07d3739543d9d39527e01eac24b404b0e3621d2e..9122768a25afb84e1692f9b5a86afb54279878d0 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/UserGroupAssoRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/UserGroupAssoRepository.java @@ -10,6 +10,12 @@ import org.springframework.data.jpa.repository.Query; import java.util.List; import java.util.Optional; +/** + * Repository interface for the UserGroupAsso association entity + * + * @author Pedro, Birk, Anders + * @version 1.3 + */ public interface UserGroupAssoRepository extends JpaRepository<UserGroupAsso, UserGroupId> { @@ -70,7 +76,7 @@ public interface UserGroupAssoRepository extends JpaRepository<UserGroupAsso, Us * Finds the authority level of a user in a group * @param username the username of the user * @param groupId the id of the group - * @return + * @return the authority level of the user in the group */ String findAuthorityByUser_UsernameAndGroup_GroupId(String username, long groupId); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/WasteRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/WasteRepository.java index 02b4266434c4dcddd63c9a7fe411a058c6a4a182..aaa41eb7248df4b21f53cbb0298226ecf7d64fa3 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/WasteRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/group/WasteRepository.java @@ -9,6 +9,12 @@ import org.springframework.data.repository.query.Param; import java.util.Optional; +/** + * Repository for waste + * + * @author Anders, Pedro + * @version 1.1 + */ public interface WasteRepository extends JpaRepository<Waste, Long> { Optional<List<Waste>> findByGroupId( Group groupId); @@ -25,6 +31,10 @@ public interface WasteRepository extends JpaRepository<Waste, Long> { Optional<List<Waste>> findAllWasteOfOneCategoryFromGroup(@Param("groupId") long groupId, @Param("categoryName") String categoryName); + /** + * Gets the last added waste item + * @return the id of the last added waste item + */ @Query(value = "SELECT waste_id FROM wastes ORDER BY waste_id ASC",nativeQuery = true) long getLastWaste(); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/CategoryRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/CategoryRepository.java index 6c7db2f19f4f3f155d02b4eefb92043d14c64d96..eb0f9642cf5d3e1239b88dfcfc8b0d9e1403816e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/CategoryRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/CategoryRepository.java @@ -3,5 +3,11 @@ package ntnu.idatt2016.v233.SmartMat.repository.product; import ntnu.idatt2016.v233.SmartMat.entity.product.Category; import org.springframework.data.jpa.repository.JpaRepository; +/** + * Repository for categories + * + * @author Birk + * @version 1.0 + */ public interface CategoryRepository extends JpaRepository<Category, String> { } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/FridgeProductAssoRepo.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/FridgeProductAssoRepo.java index 6cddba89479f9259f779d6c2604dc8d8c8debb28..f0e2d84a880d1aef1fd578eb1f5dbecf66e3b345 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/FridgeProductAssoRepo.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/FridgeProductAssoRepo.java @@ -5,6 +5,17 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; +/** + * Repository for fridge product associations + * + * @author Birk, Pedro + * @version 1.1 + */ public interface FridgeProductAssoRepo extends JpaRepository<FridgeProductAsso, Long> { + /** + * Finds all fridge product associations by id + * @param id the id of the fridge product association + * @return an optional holding the fridge product association with the given id if it exists + */ Optional<FridgeProductAsso> findAllById(long id); } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/ProductRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/ProductRepository.java index ea88f235df4a6238b1f31ee7cc6d649859ac5630..ccf04933af2ed2946209fb486c3b18fc532d3a52 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/ProductRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/product/ProductRepository.java @@ -9,8 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; /** * Repository for Products * @author Birk & Stian - * @version 1.0 - * @since 19.04.2023 + * @version 1.1 */ public interface ProductRepository extends JpaRepository<Product, Long> { @@ -20,4 +19,5 @@ public interface ProductRepository extends JpaRepository<Product, Long> { * @param name the name of the group * @return an optional containing the product if it exists */ - Optional<Product> getByName(String name);} + Optional<Product> getByName(String name); +} diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/AchievementRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/AchievementRepository.java index bcad340539d23afec160bcc4b0e9b2d7a429b24c..b702e3496b105cb93d8146b7d0dafb959944ea5d 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/AchievementRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/AchievementRepository.java @@ -10,7 +10,6 @@ import java.util.Optional; * * @author Anders * @version 1.0 - * @since 19.04.2023 */ public interface AchievementRepository extends JpaRepository<Achievement, String> { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/UserRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/UserRepository.java index 79aa716ab297b1116bfb4d217b3ce6df720a2fbf..20ef5b7ccbc83475a4ec5e4fd15cd503fa602626 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/UserRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/user/UserRepository.java @@ -7,11 +7,8 @@ import java.util.Optional; /** * repo for user entity - * uses mysql from server when ran - * uses h2 in memory database when testing * @author birk * @version 1.1 - * @since 20.04.2023 */ public interface UserRepository extends JpaRepository<User, Long>{ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/AllergyService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/AllergyService.java index 168345c8a53d7e79a2bf83643a6bd88cc7557401..20fa670787178e384f2964f0a7c3c68b0e27d6c0 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/AllergyService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/AllergyService.java @@ -14,14 +14,10 @@ import ntnu.idatt2016.v233.SmartMat.repository.AllergyRepository; /** * Service for allergies * @author Stian Lyng - * @version 1.0 */ @Service public class AllergyService { - - /** - * Repository for allergies - */ + @Autowired private AllergyRepository allergyRepository; diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java index 4d894a1a1905a22fb8279885ca3c4d4d65ae953d..04a38cb5573a47d211777de2a5945a1861ebe391 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java @@ -24,15 +24,12 @@ import org.springframework.stereotype.Service; /** * This class defines the methods for the recipe service * - * @author Stian Lyng - * @version 1.0 + * @author Stian Lyng, Birk + * @version 1.1 */ @Service public class RecipeService { - - /** - * The recipe repository - */ + @Autowired private RecipeRepository recipeRepository; @@ -41,7 +38,7 @@ public class RecipeService { /** * Creates a new recipe service - * @param recipeRepository + * @param recipeRepository the recipe repository */ public RecipeService (RecipeRepository recipeRepository) { this.recipeRepository = recipeRepository; @@ -177,14 +174,11 @@ public class RecipeService { * @return A list of RecipeWithMatchCount objects representing the weekly menu */ public List<RecipeWithMatchCount> getWeeklyMenu(Integer fridgeId) { - // Get the results from both repository methods List<Object[]> weeklyMenu = recipeRepository.findWeeklyMenu(fridgeId); List<Object[]> recipeProducts = recipeRepository.findRecipeProductsWithName(); - // Prepare a map to store RecipeDetails with their match count Map<RecipeDetails, Integer> recipeMatchCountMap = new HashMap<>(); - // Compare the item_name on both lists for (Object[] menuRow : weeklyMenu) { String menuRowItemName = ((String) menuRow[0]).toLowerCase(); for (Object[] recipeProductRow : recipeProducts) { @@ -206,18 +200,15 @@ public class RecipeService { } } - // Get a list of unique RecipeDetails from recipeProducts List<RecipeDetails> uniqueRecipeDetails = recipeProducts.stream() .map(row -> new RecipeDetails(((Integer) row[0]).intValue(), (String) row[1], (String) row[2], (String) row[3])) .distinct() .collect(Collectors.toList()); - // Convert the map to a list of RecipeWithMatchCount List<RecipeWithMatchCount> commonRecipes = recipeMatchCountMap.entrySet().stream() .map(entry -> new RecipeWithMatchCount(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); - // Add additional recipes from uniqueRecipeDetails with a count of 0 if the list has less than 5 recipes List<RecipeWithMatchCount> zeroMatchRecipes = new ArrayList<>(); for (RecipeDetails recipeDetails : uniqueRecipeDetails) { if (commonRecipes.size() < 5 && !recipeMatchCountMap.containsKey(recipeDetails)) { @@ -225,10 +216,8 @@ public class RecipeService { } } - // Shuffle the zeroMatchRecipes list Collections.shuffle(zeroMatchRecipes); - // Combine the commonRecipes and zeroMatchRecipes lists for (RecipeWithMatchCount zeroMatchRecipe : zeroMatchRecipes) { if (commonRecipes.size() < 5) { commonRecipes.add(zeroMatchRecipe); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/ShoppingListService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/ShoppingListService.java index c56b1c27c84caf834059a9eccb485e35b354354e..2d5701c93820fd18f97dc73b27b9776ba580c8b1 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/ShoppingListService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/ShoppingListService.java @@ -13,7 +13,7 @@ import ntnu.idatt2016.v233.SmartMat.repository.ShoppingListRepository; /** * Service for the shopping list * - * @author Stian Lyng + * @author Stian Lyng, Birk * @version 1.1 */ @Service diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/TokenService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/TokenService.java index e2caee18c54df6a6d0b923726aa2d925fe17b512..6f83285bf463003a8b8901b1089ad2ce5519ac80 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/TokenService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/TokenService.java @@ -15,7 +15,6 @@ import java.util.stream.Collectors; * This class is used to generate a JWT token. * @author Anders * @version 1.0 - * @since 22.03.2023 */ @Service public class TokenService { @@ -24,7 +23,6 @@ public class TokenService { /** * Creates a new TokenService object. - * The encoder object is injected by Spring. * * @param encoder the JwtEncoder object to use */ diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java index 8965be1d7bf2c390a0420fffd4f13a01b9593c33..2fedb932097f72b492e003266d59c5788f42a3ed 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java @@ -26,7 +26,7 @@ public class WeeklyMenuService { * Retrieves the top 5 recipes with products that have a match with items in the given fridge. * Returns a list of RecipeWithProductsDTO objects with recipe details and product information. * - * @param groupId the ID of the fridge to use for matching products + * @param fridgeId the ID of the fridge to use for matching products * @return a list of RecipeWithProductsDTO objects with recipe and product details */ public List<WeeklyMenuResponse> getWeeklyMenu(long fridgeId) { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/FridgeService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/FridgeService.java index 74295864fe25b35a3b7e1c2f5c32c0e17c7906a4..e7ae96f171e7aedb2624f7a5f8363f474e53c0ec 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/FridgeService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/FridgeService.java @@ -28,7 +28,6 @@ import java.util.Optional; * * @author Anders Austlid & Birk * @version 2 - * @since 05.05.2023 */ @AllArgsConstructor @Service @@ -92,7 +91,12 @@ public class FridgeService { return product; } - + + /** + * Updates a product in the fridge of a group + * @param request the fridge product request + * @return the product that was added to the fridge + */ public Optional<FridgeProductAsso> updateProductInFridge(FridgeProductRequest request) { Optional<FridgeProductAsso> fridgeProductAsso = fridgeProductAssoRepo.findById(request.fridgeProductId()); if (fridgeProductAsso.isEmpty()) return Optional.empty(); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/GroupService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/GroupService.java index e8b2b4d6797a8e2c219f4ae05cb245564bdb22fc..fb3e22f7e9958b0878bb09fe236237f896648002 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/GroupService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/GroupService.java @@ -20,9 +20,8 @@ import java.util.Optional; /** * Service for groups * - * @author Anders Austlid & Birk - * @version 1.2 - * @since 26.04.2023 + * @author Anders Austlid, Birk, Pedro + * @version 1.3 */ @AllArgsConstructor @Service @@ -166,6 +165,11 @@ public class GroupService { return Optional.of(groupRepository.save(group)); } + /** + * Gets a group by its link code + * @param linkCode the link code of the group + * @return an optional containing the group if it exists + */ public Optional<Group> getGroupByLinkCode(String linkCode) { return groupRepository.findByLinkCode(linkCode); } @@ -219,6 +223,12 @@ public class GroupService { return userGroupAssoRepository.findById(userGroupId); } + /** + * Gets the authority of a user group association + * @param username the username of the user + * @param groupId the id of the group + * @return the authority of the user group association + */ public String getUserGroupAssoAuthority(String username, long groupId) { Optional<UserGroupAsso> userGroupAsso = getUserGroupAsso(username, groupId); return userGroupAsso.map(UserGroupAsso::getGroupAuthority).orElseThrow(() -> new IllegalArgumentException("User is not associated with group")); @@ -236,8 +246,7 @@ public class GroupService { /** * removes user_group relatioon - * @param username the username of the user - * @param groupId the id of the group + * @param userGroup the user group association to remove * @return true if the user is the owner of the group, false otherwise */ @Transactional diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/WasteService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/WasteService.java index 3272f026f1921a22e53f2a727492346abe2a8713..20615c62e65ba9805211656fc5c924d57dca563c 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/WasteService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/group/WasteService.java @@ -20,9 +20,8 @@ import java.util.Optional; /** * Service for waste - * @author Pedro, Birk + * @author Anders, Pedro, Birk * @version 1.1 - * @since 04.05.2023 */ @Service @AllArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/CategoryService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/CategoryService.java index 3e6698264d242fa99c11a51627d15e5b7a024ba2..48765c3578f908b1474a74fe444b26e38dc460f8 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/CategoryService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/CategoryService.java @@ -11,7 +11,6 @@ import java.util.Optional; * Service for Categories * @version 1.0 * @Author Birk - * @since 26.04.2020 */ @Service @AllArgsConstructor diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/ProductService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/ProductService.java index 9e55d02b86903873e82b2b3ebabf2d5629c0cb78..1d526e4924d78f85f2ae9320b50990a74225355e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/ProductService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/product/ProductService.java @@ -13,7 +13,6 @@ import java.util.Optional; * uses both the ProductRepository and the ProductUtil * @author Birk * @version 1.1 - * @since 05.04.2023 */ @Service public class ProductService { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/AchievementService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/AchievementService.java index 83a781c445438cbb20148da93d8ee93519ce5762..7ef5c28bb2f00ca939d49679fdf75d6a54440c0e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/AchievementService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/AchievementService.java @@ -13,7 +13,6 @@ import java.util.Optional; * * @author Anders * @version 1.0 - * @since 19.04.2023 */ @Service @@ -31,6 +30,10 @@ public class AchievementService { return achievementRepository.findByAchievementName(achievementName); } + /** + * Gets all achievements from the database + * @return a list of all achievements + */ public List<Achievement> getAchievements(){ return achievementRepository.findAll(); } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/JpaUserDetailsService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/JpaUserDetailsService.java index d260ad8c01416997ec95480a761d2154a09a23ee..d256685ad22395e6ad97e1391a34f16f3c54cb0e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/JpaUserDetailsService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/JpaUserDetailsService.java @@ -10,7 +10,6 @@ import org.springframework.stereotype.Service; * JpaUserDetailsService is a class that implements the UserDetailsService interface. * @author Birk * @version 1.0 - * @since 05.04.2023 */ @Service @AllArgsConstructor @@ -21,7 +20,7 @@ public class JpaUserDetailsService implements UserDetailsService { * gets user from username out of database * @param username username of user * @return user - * @throws UsernameNotFoundException + * @throws UsernameNotFoundException if user is not found */ @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/UserService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/UserService.java index 3c21d1971e071e2498c5432d7c982662ebd39799..7dc252ed2df343c200ede3430235873aae6bf2bf 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/UserService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/UserService.java @@ -21,9 +21,8 @@ import java.util.Optional; /** * UserService is a class that implements the UserDetailsService interface. - * @author Birk + * @author Birk, Stian * @version 1.1 - * @since 20.04.2023 */ @Service @AllArgsConstructor @@ -43,6 +42,10 @@ public class UserService { public Optional<User> getUserFromUsername(String username){ return userRepository.findByUsername(username); } + + /** + * Gets all users from the database + */ public List<User> getUsers(){ return userRepository.findAll(); } diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/CategoryUtil.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/CategoryUtil.java index 17b4771d51248c2e39d2e2f6733d83fb2c02f179..233458c218084c6b0b6a9d855c10d805cd9f5f3f 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/CategoryUtil.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/CategoryUtil.java @@ -6,7 +6,6 @@ import java.util.*; * Utility class for category * @author Pedro Pablo Cardona * @version 1.0 - * @since 21.04.2023 */ public class CategoryUtil { @@ -29,6 +28,11 @@ public class CategoryUtil { "grappa", "kirsebærbrannvin", "sherry", "sider", "mjød" ); + /** + * Static method that returns a list of keywords for a given category. + * @param category The category to get keywords for. + * @return A list of keywords. + */ private static List<String> getCategoryKeywords(String category) { return switch (category) { case "meat, fish and chicken" -> MEAT; diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/GroupUtil.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/GroupUtil.java index 7e586b6161198f4cb5b80587d372d37181f1c28e..013af0e5896692cb2226ccc8c33aa1c2c0a8b28c 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/GroupUtil.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/GroupUtil.java @@ -9,7 +9,6 @@ import java.util.UUID; * * @author Pedro Cardona * @version 1.0 - * @since 25.04.2023 */ public class GroupUtil { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/ProductUtil.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/ProductUtil.java index d83bf6cf2cc8533484f972294c7185f7b096fbd4..a9e9242ada9542d37bcffd1d66b3dd0078949387 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/ProductUtil.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/ProductUtil.java @@ -11,12 +11,16 @@ import java.util.regex.Pattern; /** * Utility class for products - * @author Birk - * @version 1.0 - * @since 04.04.2023 + * @author Birk, Pedro + * @version 1.1 */ public class ProductUtil { + /** + * Gets volume from a product + * @param product the product to get volume from + * @return an optional containing a list of the volume and unit if it exists + */ public static Optional<List<String>> getVolumeFromProduct(Product product) { String total = product.getName() + " " + product.getDescription(); double amount = parseAmount(total); @@ -32,6 +36,11 @@ public class ProductUtil { return Optional.of(List.of(amount + "", unit)); } + /** + * Parses unit from a string + * @param input the string to parse unit from + * @return the unit + */ private static String parseUnit(String input) { Pattern pattern = Pattern.compile("(\\d+(\\.\\d+)?)\\s*(g|kg|l|ml|dl|cl|Kg|L|STK)\\b", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(input); @@ -44,6 +53,11 @@ public class ProductUtil { return "STK"; } + /** + * Parses amount from a string + * @param input the string to parse amount from + * @return the amount + */ private static double parseAmount(String input) { Pattern pattern = Pattern.compile("(\\d+(\\.\\d+)?)\\s*(g|kg|l|ml|dl|cl|Kg|L|STK)\\b", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(input); diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/StatisticUtil.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/StatisticUtil.java index 10fc25577b40d6320557ec62c6ebb2bb3171999a..9ef7a57c7de6cc2845fc8c44bb3dbb0fc9ecb64a 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/StatisticUtil.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/StatisticUtil.java @@ -15,7 +15,6 @@ import java.util.List; * A utility class for calculating statistics related to waste and CO2 emissions. * @author Pedro Cardona * @version 1.0 - * @since 03.05.2023 */ public class StatisticUtil { diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/Jwks.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/Jwks.java index 59f309bc244e4e66943e3f5e8b8904c1b0b941e1..31f3bc73c0582816e371e230ad88cf9ae38b2edf 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/Jwks.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/Jwks.java @@ -9,15 +9,11 @@ import java.util.UUID; /** * Jwks is a utility class for generating RSA keys for JSON Web Key Set (JWKS) support. * It provides a method to generate an RSA key pair and create an RSAKey object. - * @author Anders (young buck) + * @author Anders * @version 1.0 - * @since 04.04.2023 */ public class Jwks { - /** - * Private constructor to prevent instantiation of this utility class. - */ private Jwks() {} /** diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/KeyGeneratorUtils.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/KeyGeneratorUtils.java index cd36005771fe2594fe470c536526c026d23b4b89..029f38e2eb397ce3396bbb1c3b2399f8628b5315 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/KeyGeneratorUtils.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/util/rsa/KeyGeneratorUtils.java @@ -8,16 +8,12 @@ import java.security.KeyPairGenerator; * KeyGeneratorUtils is a utility class for generating key pairs, specifically RSA key pairs. * This class is marked as a Spring component to allow its use in the Spring framework. * - * @author Anders (young buck) + * @author Anders * @version 1.0 - * @since 04.04.2023 */ @Component final class KeyGeneratorUtils { - /** - * Private constructor to prevent instantiation of this utility class. - */ private KeyGeneratorUtils() {} /**