Class TicketRepository

java.lang.Object
com.example.skeddly.business.database.repository.GenericRepository<Ticket>
com.example.skeddly.business.database.repository.TicketRepository

public class TicketRepository extends GenericRepository<Ticket>
A class to handle retrieving tickets from Firestore. This class is associated with a particular event, which is relevant when performing aggregate retrievals.
  • Field Details

  • Constructor Details

    • TicketRepository

      public TicketRepository(com.google.firebase.firestore.FirebaseFirestore firestore, String eventId, String userId)
      Create a new TicketRepository. The repository is associated with a particular event, and user, unless either are null.
      Parameters:
      firestore - The FirebaseFirestore instance to use.
      eventId - The event id that this repository is associated with.
      userId - The user id that this repository is associated with.
    • TicketRepository

      public TicketRepository(com.google.firebase.firestore.FirebaseFirestore firestore, String eventId)
      Create a new TicketRepository. The repository is associated with a particular event, unless the eventId is null. If it is, the repository shall retrieve tickets for all events.
      Parameters:
      firestore - The FirebaseFirestore instance to use.
      eventId - The event id that this repository is associated with.
  • Method Details

    • getAllByStatus

      public com.google.android.gms.tasks.Task<List<Ticket>> getAllByStatus(TicketStatus status)
      Retrieves all the tickets related to this event that contain a certain status.
      Parameters:
      status - The status to retrieve tickets by.
      Returns:
      A task that when complete, contains all the requested tickets in a list.
    • getAllByStatuses

      public com.google.android.gms.tasks.Task<List<Ticket>> getAllByStatuses(List<TicketStatus> statuses)
      Retrieves all the tickets related to this event that contain certain statuses.
      Parameters:
      statuses - The statuses to retrieve tickets by.
      Returns:
      A task that when complete, contains all the requested tickets in a list.
    • updateStatus

      public com.google.android.gms.tasks.Task<Void> updateStatus(String ticketId, TicketStatus newStatus)
      Updates the status of a given ticket id.
      Parameters:
      ticketId - The ticketId to update
      newStatus - The new status to update it to
      Returns:
      A task that is completed when the update has finished on the DB side
    • getCollectionPath

      protected com.google.firebase.firestore.CollectionReference getCollectionPath()
      Description copied from class: GenericRepository
      This method retrieves the reference to the collection of documents it handles
      Specified by:
      getCollectionPath in class GenericRepository<Ticket>
      Returns:
      A CollectionReference to the collection of documents it handles.
    • getQuery

      protected com.google.firebase.firestore.Query getQuery()
      Description copied from class: GenericRepository
      This method retrieves a query for getting all the documents handled by this repository. This is commonly overridden in repositories that filter out documents by fields.
      Overrides:
      getQuery in class GenericRepository<Ticket>
      Returns:
      A query that can retrieve multiple documents.