java.lang.Object
com.example.cab302project.CrimeRecord
Represents a single crime report within the system.
This class serves as a Data Transfer Object (DTO) containing information about
the type of crime, its location, the reporting user, and its current status.
-
Constructor Summary
ConstructorsConstructorDescriptionCrimeRecord(int id, CrimeCategory category, LocalDateTime timestamp, double latitude, double longitude, String description, String reporter, boolean actioned) Constructs a new CrimeRecord with full details. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the category classification of the crime.Retrieves the full text description of the report.intgetId()Retrieves the database primary key ID.doubleRetrieves the latitude of the reported incident.doubleRetrieves the longitude of the reported incident.Retrieves the identifier of the reporting user.Helper method for UI components.Retrieves the date and time associated with the report.Helper method for DAO: Returns the timestamp as a String for SQLitebooleanChecks if the report has been marked as actioned by authorities.voidsetActioned(boolean actioned) Sets the current actioned status of the report.voidsetCategory(CrimeCategory category) Sets the crime category classification.voidsetDescription(String description) Sets the descriptive text for the incident.voidsetLocation(double lat, double lon) Updates the geographic coordinates of the incident using validation.voidsetReporter(String reporter) Sets the identifier for the reporting user.voidsetTimestamp(LocalDateTime timestamp) Sets the timestamp for the incident.
-
Constructor Details
-
CrimeRecord
public CrimeRecord(int id, CrimeCategory category, LocalDateTime timestamp, double latitude, double longitude, String description, String reporter, boolean actioned) Constructs a new CrimeRecord with full details.Note on ID Management:
- New Records: If you are creating a record to be added to the database, the ID provided here will be overwritten by the database's auto-incrementing primary key.
- Existing Records: If updating an existing record, ensure you provide the original ID value to ensure the correct database entry is modified.
- Parameters:
id- The unique identifier for the record.category- TheCrimeCategorydefining the type and severity of the crime.timestamp- The date and time the incident occurred or was reported.latitude- The GPS latitude coordinate (-90 to 90).longitude- The GPS longitude coordinate (-180 to 180).description- A detailed text description of the incident.reporter- The name or ID of the user reporting the crime.actioned- Whether the report has been addressed by authorities.
-
-
Method Details
-
getId
public int getId()Retrieves the database primary key ID.- Returns:
- The unique database identifier for this record.
-
getCategory
Retrieves the category classification of the crime.- Returns:
- The
CrimeCategoryof this record.
-
getTimestamp
Retrieves the date and time associated with the report.- Returns:
- The
LocalDateTimeassociated with the report.
-
getLatitude
public double getLatitude()Retrieves the latitude of the reported incident.- Returns:
- The latitude coordinate of the incident.
-
getLongitude
public double getLongitude()Retrieves the longitude of the reported incident.- Returns:
- The longitude coordinate of the incident.
-
getDescription
Retrieves the full text description of the report.- Returns:
- The detailed description of the incident.
-
getReporter
Retrieves the identifier of the reporting user.- Returns:
- The name or identifier of the reporter.
-
isActioned
public boolean isActioned()Checks if the report has been marked as actioned by authorities.- Returns:
- true if the incident has been actioned, false otherwise.
-
setCategory
Sets the crime category classification.- Parameters:
category- The newCrimeCategoryto assign.
-
setTimestamp
Sets the timestamp for the incident.- Parameters:
timestamp- The newLocalDateTimeto assign.
-
setDescription
Sets the descriptive text for the incident.- Parameters:
description- The new text description for the report.
-
setReporter
Sets the identifier for the reporting user.- Parameters:
reporter- The name of the user reporting the incident.
-
setActioned
public void setActioned(boolean actioned) Sets the current actioned status of the report.- Parameters:
actioned- The new status indicating if the report is addressed.
-
setLocation
public void setLocation(double lat, double lon) Updates the geographic coordinates of the incident using validation.- Parameters:
lat- Latitude between -90 and 90.lon- Longitude between -180 and 180.
-
getReporterDisplayName
Helper method for UI components.- Returns:
- The reporter's name, or "Anonymous" if null or empty.
-
getTimestampForDb
Helper method for DAO: Returns the timestamp as a String for SQLite- Returns:
- A formatted string of the timestamp.
-