Class Challenge

java.lang.Object
fr.utc.miage.sporttrack.entity.event.Challenge

@Entity public class Challenge extends Object
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 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 challenge
      description - the textual description of the challenge
      startDate - the start date of the challenge
      endDate - the end date of the challenge
      metric - the performance metric used for ranking
  • Method Details

    • getOrganizer

      public Athlete getOrganizer()
      Returns the athlete who organised this challenge.
      Returns:
      the organiser Athlete
    • getName

      public String getName()
      Returns the display name of this challenge.
      Returns:
      the challenge name
    • setName

      public void setName(String name)
      Sets the display name of this challenge.
      Parameters:
      name - the challenge name to assign
    • getDescription

      public String getDescription()
      Returns the textual description of this challenge.
      Returns:
      the challenge description
    • setDescription

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

      public LocalDate getStartDate()
      Returns the start date of this challenge.
      Returns:
      the start date
    • setStartDate

      public void setStartDate(LocalDate startDate)
      Sets the start date of this challenge.
      Parameters:
      startDate - the start date to assign
    • getEndDate

      public LocalDate getEndDate()
      Returns the end date of this challenge.
      Returns:
      the end date
    • setEndDate

      public void setEndDate(LocalDate endDate)
      Sets the end date of this challenge.
      Parameters:
      endDate - the end date to assign
    • getParticipants

      public List<Athlete> getParticipants()
      Returns the list of athletes participating in this challenge.
      Returns:
      the list of participant Athletes
    • setParticipants

      public void setParticipants(List<Athlete> participants)
      Sets the list of athletes participating in this challenge.
      Parameters:
      participants - the list of participant Athletes to assign
    • getMetric

      public Metric getMetric()
      Returns the performance metric used for ranking in this challenge.
      Returns:
      the Metric
    • setMetric

      public void setMetric(Metric metric)
      Sets the performance metric used for ranking in this challenge.
      Parameters:
      metric - the Metric to assign
    • getSport

      public Sport getSport()
      Returns the sport associated with this challenge.
      Returns:
      the associated Sport
    • setOrganizer

      public void setOrganizer(Athlete organizer)
      Sets the athlete who organised this challenge.
      Parameters:
      organizer - the organiser Athlete to assign
    • setSport

      public void setSport(Sport sport)
      Sets the sport associated with this challenge.
      Parameters:
      sport - the Sport to associate
    • getRankings

      public List<ChallengeRanking> getRankings()
      Returns the ordered list of rankings for this challenge.
      Returns:
      the list of ChallengeRanking entries, sorted by rank position
    • getEndedNotifiedAt

      public LocalDateTime getEndedNotifiedAt()
      Returns the timestamp at which the end-of-challenge notification was sent.
      Returns:
      the notification timestamp, or null if not yet notified
    • setRankings

      public void setRankings(List<ChallengeRanking> rankings)
      Replaces the entire ranking list with the provided entries, maintaining the parent-child relationship on each ranking.
      Parameters:
      rankings - the new list of ChallengeRanking entries to assign; if null, the list is simply cleared
    • addRanking

      public void addRanking(ChallengeRanking ranking)
      Adds a single ranking entry to this challenge and establishes the bidirectional relationship.
      Parameters:
      ranking - the ChallengeRanking to add; ignored if null
    • setEndedNotifiedAt

      public void setEndedNotifiedAt(LocalDateTime endedNotifiedAt)
      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