- All Known Implementing Classes:
SqliteDAO
public interface IAppDAO
Interface defining the Data Access Object (DAO) contract for the application.
Provides abstract methods for CRUD (Create, Read, Update, Delete) operations
on
User and CrimeRecord entities within the persistent data store.-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddCrime(CrimeRecord crime) Records a new crime incident in the data store.booleanPersists a new user in the data store.booleandeleteCrime(int id) Removes a crime record from the data store based on its unique identifier.Retrieves every crime record currently stored in the system.getCrimeById(int id) Retrieves a specific crime record by its unique identifier.getCrimesByUser(String username) Retrieves all crime incidents reported by a specific user.booleanupdateCrime(CrimeRecord crime) Updates the details of an existing crime record.booleanupdateUser(User user) Updates an existing user's information in the data store.validateUser(String username, String password) Validates a user's credentials against the data store.
-
Method Details
-
validateUser
Validates a user's credentials against the data store. Typically used during the login process to verify identity.- Parameters:
username- The unique username to validate.password- The password provided for validation.- Returns:
- A
Userobject if credentials are correct; null if validation fails.
-
addUser
Persists a new user in the data store.- Parameters:
user- TheUserobject containing the account details to be saved.- Returns:
- true if the user was successfully added; false if the username is taken or an error occurred.
-
updateUser
Updates an existing user's information in the data store.- Parameters:
user- TheUserobject containing the updated profile data.- Returns:
- true if the update was successful; false otherwise.
-
addCrime
Records a new crime incident in the data store.- Parameters:
crime- TheCrimeRecordobject containing the incident details.- Returns:
- true if the record was successfully created; false if an error occurred.
-
updateCrime
Updates the details of an existing crime record.- Parameters:
crime- TheCrimeRecordobject containing the updated incident data.- Returns:
- true if the record was found and updated successfully; false otherwise.
-
deleteCrime
boolean deleteCrime(int id) Removes a crime record from the data store based on its unique identifier.- Parameters:
id- The unique primary key of the crime record to be removed.- Returns:
- true if the record was deleted; false if the ID was not found or an error occurred.
-
getCrimeById
Retrieves a specific crime record by its unique identifier.- Parameters:
id- The unique primary key of the desired crime.- Returns:
- The
CrimeRecordmatching the ID, or null if no such record exists.
-
getCrimesByUser
Retrieves all crime incidents reported by a specific user.- Parameters:
username- The username of the reporter to filter by.- Returns:
- A
ListofCrimeRecordobjects; returns an empty list if the user has no reports.
-
getAllCrimes
List<CrimeRecord> getAllCrimes()Retrieves every crime record currently stored in the system.- Returns:
- A
Listcontaining allCrimeRecordobjects in the data store.
-