Class CrimeRecord

java.lang.Object
com.example.cab302project.CrimeRecord

public class CrimeRecord extends Object
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 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 - The CrimeCategory defining 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

      public CrimeCategory getCategory()
      Retrieves the category classification of the crime.
      Returns:
      The CrimeCategory of this record.
    • getTimestamp

      public LocalDateTime getTimestamp()
      Retrieves the date and time associated with the report.
      Returns:
      The LocalDateTime associated 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

      public String getDescription()
      Retrieves the full text description of the report.
      Returns:
      The detailed description of the incident.
    • getReporter

      public String 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

      public void setCategory(CrimeCategory category)
      Sets the crime category classification.
      Parameters:
      category - The new CrimeCategory to assign.
    • setTimestamp

      public void setTimestamp(LocalDateTime timestamp)
      Sets the timestamp for the incident.
      Parameters:
      timestamp - The new LocalDateTime to assign.
    • setDescription

      public void setDescription(String description)
      Sets the descriptive text for the incident.
      Parameters:
      description - The new text description for the report.
    • setReporter

      public void setReporter(String reporter)
      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

      public String getReporterDisplayName()
      Helper method for UI components.
      Returns:
      The reporter's name, or "Anonymous" if null or empty.
    • getTimestampForDb

      public String getTimestampForDb()
      Helper method for DAO: Returns the timestamp as a String for SQLite
      Returns:
      A formatted string of the timestamp.