Class Activity

java.lang.Object
fr.utc.miage.sporttrack.entity.activity.Activity

@Entity public class Activity extends Object
JPA entity representing a sport activity recorded by an athlete within the SportTrack application.

An activity captures key performance data such as duration, distance, repetitions, and the associated sport type. It may also reference a WeatherReport and a list of comments from other athletes.

Author:
SportTrack Team
  • Constructor Details

    • Activity

      public Activity()
      No-argument constructor required by JPA.
  • Method Details

    • getId

      public int getId()
      Returns the unique identifier of this activity.
      Returns:
      the activity's database identifier
    • setId

      public void setId(int id)
      Sets the unique identifier of this activity.
      Parameters:
      id - the database identifier to assign
    • getDuration

      public double getDuration()
      Returns the total duration of the activity.
      Returns:
      the duration in hours
    • setDuration

      public void setDuration(double duration)
      Sets the total duration of the activity.
      Parameters:
      duration - the duration in hours
    • getTitle

      public String getTitle()
      Returns the title of this activity.
      Returns:
      the user-defined activity title
    • setTitle

      public void setTitle(String title)
      Sets the title of this activity.
      Parameters:
      title - the title to assign
    • getDescription

      public String getDescription()
      Returns the description of this activity.
      Returns:
      the textual description, or null if none was provided
    • setDescription

      public void setDescription(String description)
      Sets the description of this activity.
      Parameters:
      description - the textual description to assign
    • getRepetition

      public Integer getRepetition()
      Returns the number of repetitions performed during this activity.
      Returns:
      the repetition count, or null if not applicable
    • setRepetition

      public void setRepetition(Integer repetition)
      Sets the number of repetitions performed during this activity.
      Parameters:
      repetition - the repetition count to assign
    • getDistance

      public Double getDistance()
      Returns the distance covered during this activity.
      Returns:
      the distance in kilometres, or null if not applicable
    • setDistance

      public void setDistance(Double distance)
      Sets the distance covered during this activity.
      Parameters:
      distance - the distance in kilometres to assign
    • getDateA

      public LocalDate getDateA()
      Returns the date on which this activity took place.
      Returns:
      the activity date
    • setDateA

      public void setDateA(LocalDate dateA)
      Sets the date on which this activity took place.
      Parameters:
      dateA - the activity date to assign
    • getStartTime

      public LocalTime getStartTime()
      Returns the local start time of this activity.
      Returns:
      the start time
    • setStartTime

      public void setStartTime(LocalTime startTime)
      Sets the local start time of this activity.
      Parameters:
      startTime - the start time to assign
    • getLocationCity

      public String getLocationCity()
      Returns the city or location name where this activity was performed.
      Returns:
      the location city name
    • setLocationCity

      public void setLocationCity(String locationCity)
      Sets the city or location name where this activity was performed.
      Parameters:
      locationCity - the location city name to assign
    • getCreatedBy

      public Athlete getCreatedBy()
      Returns the athlete who created this activity.
      Returns:
      the owning athlete
    • setCreatedBy

      public void setCreatedBy(Athlete createdBy)
      Sets the athlete who created this activity.
      Parameters:
      createdBy - the owning athlete to assign
    • getCreatedByDisplayName

      public String getCreatedByDisplayName()
      Returns the display name of the athlete who created this activity. Falls back to the username or email if the full name is unavailable.
      Returns:
      the creator's display name, or "Inconnu" if unknown
    • getSportAndType

      public Sport getSportAndType()
      Returns the sport (and its type) associated with this activity.
      Returns:
      the associated Sport
    • setSportAndType

      public void setSportAndType(Sport sport)
      Sets the sport associated with this activity and updates the transient sport identifier.
      Parameters:
      sport - the Sport to associate with this activity
    • getSportId

      public Integer getSportId()
      Returns the sport identifier, sourcing it from the transient field if available, or from the associated Sport entity otherwise.
      Returns:
      the sport identifier, or null if no sport is associated
    • setSportId

      public void setSportId(Integer sportId)
      Sets the sport identifier and resolves the associated Sport proxy. If the provided identifier is null or non-positive, the sport association is cleared.
      Parameters:
      sportId - the sport identifier to assign
    • hasRepetitions

      public boolean hasRepetitions()
      Determines whether this activity's sport type is measured by repetitions.
      Returns:
      true if the sport type is repetition-based, false otherwise
    • hasDistance

      public boolean hasDistance()
      Determines whether this activity's sport type is measured by distance.
      Returns:
      true if the sport type is distance-based, false otherwise
    • getWeatherReport

      public WeatherReport getWeatherReport()
      Returns the weather report associated with this activity.
      Returns:
      the WeatherReport, or null if none is available
    • setWeatherReport

      public void setWeatherReport(WeatherReport weatherReport)
      Sets the weather report associated with this activity.
      Parameters:
      weatherReport - the WeatherReport to associate
    • getCaloriesBurned

      public double getCaloriesBurned()
      Calculates the estimated calories burned during this activity, based on the duration and the sport's calories-per-hour rate.
      Returns:
      the estimated calories burned, or 0.0 if the duration is invalid or no sport is associated
    • getComments

      public List<Comment> getComments()
    • setComments

      public void setComments(List<Comment> comments)