Class Activity
java.lang.Object
fr.utc.miage.sporttrack.entity.activity.Activity
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleCalculates the estimated calories burned during this activity, based on the duration and the sport's calories-per-hour rate.Returns the athlete who created this activity.Returns the display name of the athlete who created this activity.getDateA()Returns the date on which this activity took place.Returns the description of this activity.Returns the distance covered during this activity.doubleReturns the total duration of the activity.intgetId()Returns the unique identifier of this activity.Returns the city or location name where this activity was performed.Returns the number of repetitions performed during this activity.Returns the sport (and its type) associated with this activity.Returns the sport identifier, sourcing it from the transient field if available, or from the associatedSportentity otherwise.Returns the local start time of this activity.getTitle()Returns the title of this activity.Returns the weather report associated with this activity.booleanDetermines whether this activity's sport type is measured by distance.booleanDetermines whether this activity's sport type is measured by repetitions.voidsetComments(List<Comment> comments) voidsetCreatedBy(Athlete createdBy) Sets the athlete who created this activity.voidSets the date on which this activity took place.voidsetDescription(String description) Sets the description of this activity.voidsetDistance(Double distance) Sets the distance covered during this activity.voidsetDuration(double duration) Sets the total duration of the activity.voidsetId(int id) Sets the unique identifier of this activity.voidsetLocationCity(String locationCity) Sets the city or location name where this activity was performed.voidsetRepetition(Integer repetition) Sets the number of repetitions performed during this activity.voidsetSportAndType(Sport sport) Sets the sport associated with this activity and updates the transient sport identifier.voidsetSportId(Integer sportId) Sets the sport identifier and resolves the associatedSportproxy.voidsetStartTime(LocalTime startTime) Sets the local start time of this activity.voidSets the title of this activity.voidsetWeatherReport(WeatherReport weatherReport) Sets the weather report associated with this activity.
-
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
Returns the title of this activity.- Returns:
- the user-defined activity title
-
setTitle
Sets the title of this activity.- Parameters:
title- the title to assign
-
getDescription
Returns the description of this activity.- Returns:
- the textual description, or
nullif none was provided
-
setDescription
Sets the description of this activity.- Parameters:
description- the textual description to assign
-
getRepetition
Returns the number of repetitions performed during this activity.- Returns:
- the repetition count, or
nullif not applicable
-
setRepetition
Sets the number of repetitions performed during this activity.- Parameters:
repetition- the repetition count to assign
-
getDistance
Returns the distance covered during this activity.- Returns:
- the distance in kilometres, or
nullif not applicable
-
setDistance
Sets the distance covered during this activity.- Parameters:
distance- the distance in kilometres to assign
-
getDateA
Returns the date on which this activity took place.- Returns:
- the activity date
-
setDateA
Sets the date on which this activity took place.- Parameters:
dateA- the activity date to assign
-
getStartTime
Returns the local start time of this activity.- Returns:
- the start time
-
setStartTime
Sets the local start time of this activity.- Parameters:
startTime- the start time to assign
-
getLocationCity
Returns the city or location name where this activity was performed.- Returns:
- the location city name
-
setLocationCity
Sets the city or location name where this activity was performed.- Parameters:
locationCity- the location city name to assign
-
getCreatedBy
Returns the athlete who created this activity.- Returns:
- the owning athlete
-
setCreatedBy
Sets the athlete who created this activity.- Parameters:
createdBy- the owning athlete to assign
-
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
Returns the sport (and its type) associated with this activity.- Returns:
- the associated
Sport
-
setSportAndType
Sets the sport associated with this activity and updates the transient sport identifier.- Parameters:
sport- theSportto associate with this activity
-
getSportId
Returns the sport identifier, sourcing it from the transient field if available, or from the associatedSportentity otherwise.- Returns:
- the sport identifier, or
nullif no sport is associated
-
setSportId
Sets the sport identifier and resolves the associatedSportproxy. If the provided identifier isnullor 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:
trueif the sport type is repetition-based,falseotherwise
-
hasDistance
public boolean hasDistance()Determines whether this activity's sport type is measured by distance.- Returns:
trueif the sport type is distance-based,falseotherwise
-
getWeatherReport
Returns the weather report associated with this activity.- Returns:
- the
WeatherReport, ornullif none is available
-
setWeatherReport
Sets the weather report associated with this activity.- Parameters:
weatherReport- theWeatherReportto 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.0if the duration is invalid or no sport is associated
-
getComments
-
setComments
-