Class TicketRepository
java.lang.Object
com.example.skeddly.business.database.repository.GenericRepository<Ticket>
com.example.skeddly.business.database.repository.TicketRepository
A class to handle retrieving tickets from Firestore. This class is associated with a particular
event, which is relevant when performing aggregate retrievals.
-
Field Summary
FieldsFields inherited from class com.example.skeddly.business.database.repository.GenericRepository
clazz -
Constructor Summary
ConstructorsConstructorDescriptionTicketRepository(com.google.firebase.firestore.FirebaseFirestore firestore, String eventId) Create a new TicketRepository.TicketRepository(com.google.firebase.firestore.FirebaseFirestore firestore, String eventId, String userId) Create a new TicketRepository. -
Method Summary
Modifier and TypeMethodDescriptiongetAllByStatus(TicketStatus status) Retrieves all the tickets related to this event that contain a certain status.getAllByStatuses(List<TicketStatus> statuses) Retrieves all the tickets related to this event that contain certain statuses.protected com.google.firebase.firestore.CollectionReferenceThis method retrieves the reference to the collection of documents it handlesprotected com.google.firebase.firestore.QuerygetQuery()This method retrieves a query for getting all the documents handled by this repository.com.google.android.gms.tasks.Task<Void> updateStatus(String ticketId, TicketStatus newStatus) Updates the status of a given ticket id.Methods inherited from class com.example.skeddly.business.database.repository.GenericRepository
count, delete, get, getAll, getAllByQuery, listen, listenAll, set
-
Field Details
-
COLLECTION_PATH
- See Also:
-
-
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
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
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 updatenewStatus- 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:GenericRepositoryThis method retrieves the reference to the collection of documents it handles- Specified by:
getCollectionPathin classGenericRepository<Ticket>- Returns:
- A CollectionReference to the collection of documents it handles.
-
getQuery
protected com.google.firebase.firestore.Query getQuery()Description copied from class:GenericRepositoryThis 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:
getQueryin classGenericRepository<Ticket>- Returns:
- A query that can retrieve multiple documents.
-