Class Challenge
java.lang.Object
fr.utc.miage.sporttrack.entity.event.Challenge
JPA entity representing a competitive challenge within the SportTrack application.
A challenge is organised by an athlete and allows other athletes to compete
against one another based on a specific sport and performance metric (e.g.,
total distance run, total duration). Rankings are maintained as an ordered
list of ChallengeRanking entries. The challenge has defined start and
end dates, after which the final standings are determined.
- Author:
- SportTrack Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRanking(ChallengeRanking ranking) Adds a single ranking entry to this challenge and establishes the bidirectional relationship.Returns the textual description of this challenge.Returns the end date of this challenge.Returns the timestamp at which the end-of-challenge notification was sent.intgetId()Returns the unique identifier of this challenge.Returns the performance metric used for ranking in this challenge.getName()Returns the display name of this challenge.Returns the athlete who organised this challenge.Returns the list of athletes participating in this challenge.Returns the ordered list of rankings for this challenge.getSport()Returns the sport associated with this challenge.Returns the start date of this challenge.voidsetDescription(String description) Sets the textual description of this challenge.voidsetEndDate(LocalDate endDate) Sets the end date of this challenge.voidsetEndedNotifiedAt(LocalDateTime endedNotifiedAt) Sets the timestamp at which the end-of-challenge notification was sent.voidSets the performance metric used for ranking in this challenge.voidSets the display name of this challenge.voidsetOrganizer(Athlete organizer) Sets the athlete who organised this challenge.voidsetParticipants(List<Athlete> participants) Sets the list of athletes participating in this challenge.voidsetRankings(List<ChallengeRanking> rankings) Replaces the entire ranking list with the provided entries, maintaining the parent-child relationship on each ranking.voidSets the sport associated with this challenge.voidsetStartDate(LocalDate startDate) Sets the start date of this challenge.
-
Constructor Details
-
Challenge
public Challenge()No-argument constructor required by JPA. -
Challenge
public Challenge(String name, String description, LocalDate startDate, LocalDate endDate, Metric metric) Constructs a new challenge with the specified name, description, date range, and metric.- Parameters:
name- the display name of the challengedescription- the textual description of the challengestartDate- the start date of the challengeendDate- the end date of the challengemetric- the performance metric used for ranking
-
-
Method Details
-
getOrganizer
Returns the athlete who organised this challenge.- Returns:
- the organiser
Athlete
-
getName
Returns the display name of this challenge.- Returns:
- the challenge name
-
setName
Sets the display name of this challenge.- Parameters:
name- the challenge name to assign
-
getDescription
Returns the textual description of this challenge.- Returns:
- the challenge description
-
setDescription
Sets the textual description of this challenge.- Parameters:
description- the description to assign
-
getStartDate
Returns the start date of this challenge.- Returns:
- the start date
-
setStartDate
Sets the start date of this challenge.- Parameters:
startDate- the start date to assign
-
getEndDate
Returns the end date of this challenge.- Returns:
- the end date
-
setEndDate
Sets the end date of this challenge.- Parameters:
endDate- the end date to assign
-
getParticipants
Returns the list of athletes participating in this challenge.- Returns:
- the list of participant
Athletes
-
setParticipants
Sets the list of athletes participating in this challenge.- Parameters:
participants- the list of participantAthletes to assign
-
getMetric
Returns the performance metric used for ranking in this challenge.- Returns:
- the
Metric
-
setMetric
Sets the performance metric used for ranking in this challenge.- Parameters:
metric- theMetricto assign
-
getSport
Returns the sport associated with this challenge.- Returns:
- the associated
Sport
-
setOrganizer
Sets the athlete who organised this challenge.- Parameters:
organizer- the organiserAthleteto assign
-
setSport
Sets the sport associated with this challenge.- Parameters:
sport- theSportto associate
-
getRankings
Returns the ordered list of rankings for this challenge.- Returns:
- the list of
ChallengeRankingentries, sorted by rank position
-
getEndedNotifiedAt
Returns the timestamp at which the end-of-challenge notification was sent.- Returns:
- the notification timestamp, or
nullif not yet notified
-
setRankings
Replaces the entire ranking list with the provided entries, maintaining the parent-child relationship on each ranking.- Parameters:
rankings- the new list ofChallengeRankingentries to assign; ifnull, the list is simply cleared
-
addRanking
Adds a single ranking entry to this challenge and establishes the bidirectional relationship.- Parameters:
ranking- theChallengeRankingto add; ignored ifnull
-
setEndedNotifiedAt
Sets the timestamp at which the end-of-challenge notification was sent.- Parameters:
endedNotifiedAt- the notification timestamp to assign
-
getId
public int getId()Returns the unique identifier of this challenge.- Returns:
- the challenge's database identifier
-