From c7ac2db02a39cf349f9434186996c93eebc17a3c Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 23 Feb 2025 15:51:28 -0500 Subject: Created UserDAO and file as well as user class --- .../ufund/api/ufundapi/persistence/UserDAO.java | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java') diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java new file mode 100644 index 0000000..df797b9 --- /dev/null +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java @@ -0,0 +1,84 @@ +package com.ufund.api.ufundapi.persistence; + +import java.io.IOException; + +import com.ufund.api.ufundapi.model.Need; + +/** + * Defines the interface for Need object persistence + * + * @author Team 2B Jelly Solutions + */ +public interface UserDAO { + /** + * Retrieves all {@linkplain Need needs} + * + * @return An array of {@link Need need} objects, may be empty + * + * @throws IOException if an issue with underlying storage + */ + Need[] getUsers() throws IOException; + + /** + * Finds all {@linkplain Need needs} whose name contains the given text + * + * @param targetName The text to match against + * + * @return An array of {@link Need needs} whose names contains the given text, + * may be empty + * + * @throws IOException if an issue with underlying storage + */ + Need[] findUsers(String targetName) throws IOException; + + /** + * Retrieves a {@linkplain Need need} with the given name + * + * @param id The ID of the {@link Need need} to get + * + * @return a {@link Need need} object with the matching name + *
+ * null if no {@link Need need} with a matching name is found + * + * @throws IOException if an issue with underlying storage + */ + Need getUser(int id) throws IOException; + + /** + * Creates and saves a {@linkplain Need need} + * + * @param need {@linkplain Need need} object to be created and saved + *
+ * The id of the need object is automatically incremented. + * + * @return new {@link Need need} if successful, null otherwise + * + * @throws IOException if an issue with underlying storage + */ + Need createNeed(Need need) throws IOException; + + /** + * Updates and saves a {@linkplain Need need} + * + * @param need {@link Need need} object to be updated and saved + * + * @return updated {@link Need need} if successful, null if + * {@link Need need} could not be found + * + * @throws IOException if underlying storage cannot be accessed + */ + Need updateNeed(Need need) throws IOException; + + /** + * Deletes a {@linkplain Need need} with the given id + * + * @param id The id of the {@link Need need} + * + * @return true if the {@link Need need} was deleted + *
+ * false if the need with the given id does not exist + * + * @throws IOException if underlying storage cannot be accessed + */ + boolean deleteNeed(int id) throws IOException; +} -- cgit v1.2.3 From d775671c878a15a138d16efd70138e3a4fbec7d7 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Wed, 26 Feb 2025 12:36:51 -0500 Subject: Modified UserDAO to have correct methods and paramters for the userFileDAO --- .../ufund/api/ufundapi/persistence/UserDAO.java | 63 +++++++++------------- 1 file changed, 26 insertions(+), 37 deletions(-) (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java') diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java index df797b9..5926214 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java @@ -2,83 +2,72 @@ package com.ufund.api.ufundapi.persistence; import java.io.IOException; -import com.ufund.api.ufundapi.model.Need; +import com.ufund.api.ufundapi.model.User; + /** - * Defines the interface for Need object persistence + * Defines the interface for User object persistence * * @author Team 2B Jelly Solutions */ public interface UserDAO { /** - * Retrieves all {@linkplain Need needs} - * - * @return An array of {@link Need need} objects, may be empty - * - * @throws IOException if an issue with underlying storage - */ - Need[] getUsers() throws IOException; - - /** - * Finds all {@linkplain Need needs} whose name contains the given text - * - * @param targetName The text to match against + * Retrieves all {@linkplain User users} * - * @return An array of {@link Need needs} whose names contains the given text, - * may be empty + * @return An array of {@link User user} objects, may be empty * * @throws IOException if an issue with underlying storage */ - Need[] findUsers(String targetName) throws IOException; + User[] getUsers() throws IOException; /** - * Retrieves a {@linkplain Need need} with the given name + * Retrieves a {@linkplain User user} with the given name * - * @param id The ID of the {@link Need need} to get + * @param id The ID of the {@link User user} to get * - * @return a {@link Need need} object with the matching name + * @return a {@link User user} object with the matching name *
- * null if no {@link Need need} with a matching name is found + * null if no {@link User user} with a matching name is found * * @throws IOException if an issue with underlying storage */ - Need getUser(int id) throws IOException; + User getUser(String name) throws IOException; /** - * Creates and saves a {@linkplain Need need} + * Creates and saves a {@linkplain User user} * - * @param need {@linkplain Need need} object to be created and saved + * @param user {@linkplain User user} object to be created and saved *
- * The id of the need object is automatically incremented. + * The id of the user object is automatically incremented. * - * @return new {@link Need need} if successful, null otherwise + * @return new {@link User user} if successful, null otherwise * * @throws IOException if an issue with underlying storage */ - Need createNeed(Need need) throws IOException; + User createUser(User user) throws IOException; /** - * Updates and saves a {@linkplain Need need} + * Updates and saves a {@linkplain User user} * - * @param need {@link Need need} object to be updated and saved + * @param user {@link User user} object to be updated and saved * - * @return updated {@link Need need} if successful, null if - * {@link Need need} could not be found + * @return updated {@link User user} if successful, null if + * {@link User user} could not be found * * @throws IOException if underlying storage cannot be accessed */ - Need updateNeed(Need need) throws IOException; + User updateUser(User user) throws IOException; /** - * Deletes a {@linkplain Need need} with the given id + * Deletes a {@linkplain User user} with the given id * - * @param id The id of the {@link Need need} + * @param id The id of the {@link User user} * - * @return true if the {@link Need need} was deleted + * @return true if the {@link User user} was deleted *
- * false if the need with the given id does not exist + * false if the user with the given id does not exist * * @throws IOException if underlying storage cannot be accessed */ - boolean deleteNeed(int id) throws IOException; + boolean deleteUser(String name) throws IOException; } -- cgit v1.2.3 From cbcd49f2b96dffe359b99b8791ccfb62cbd4717f Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Wed, 26 Feb 2025 13:18:18 -0500 Subject: Updated and added more javadocs. Also modified updateUser method to take a string name to use to find desired user to update. --- .../src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java') diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java index 5926214..d456abc 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java @@ -49,14 +49,15 @@ public interface UserDAO { /** * Updates and saves a {@linkplain User user} * - * @param user {@link User user} object to be updated and saved + * @param newUser {@link User user} object to be updated and saved + * @param name {@link String name} name of object to be updated * * @return updated {@link User user} if successful, null if * {@link User user} could not be found * * @throws IOException if underlying storage cannot be accessed */ - User updateUser(User user) throws IOException; + User updateUser(User newUser, String name) throws IOException; /** * Deletes a {@linkplain User user} with the given id -- cgit v1.2.3